use ndarray::prelude::*; use petgraph::prelude::*; use crate::network; use crate::node; use crate::params; use crate::params::Params; pub struct Trajectory { time: Array1, events: Array2 } pub struct Dataset { trajectories: Vec } pub fn trajectory_generator(net: &Box, n_trajectories: u64, t_end: f64) -> Dataset { let mut dataset = Dataset{ trajectories: Vec::new() }; let node_idx: Vec<_> = net.get_node_indices().collect(); for _ in 0..n_trajectories { let t = 0.0; let mut time: Vec = Vec::new(); let mut events: Vec> = Vec::new(); let mut current_state: Vec = node_idx.iter().map(|x| { match net.get_node(&x).get_params() { node::NodeType::DiscreteStatesContinousTime(params) => params.get_random_state_uniform() } }).collect(); let next_transitions: Vec> = (0..node_idx.len()).map(|_| Option::None).collect(); events.push(current_state.clone()); time.push(t.clone()); while t < t_end { next_transitions.iter_mut().zip(net.get_node_indices()).map(|x| { if let None = x.0 { *(x.0) = Some(match net.get_node(&x.1).get_params(){ node::NodeType::DiscreteStatesContinousTime(params) => params.get_random_residence_time(x.1, net.get_param_index_network(&x.1, ¤t_state)).unwrap() }); }}); } } dataset }