parent
c2a86cfccd
commit
67f77c3361
@ -1,11 +1,16 @@ |
||||
use std::collections::BTreeSet; |
||||
use crate::params; |
||||
|
||||
pub enum DomainType { |
||||
Discrete(Vec<String>) |
||||
} |
||||
|
||||
pub struct Node { |
||||
pub domain: DomainType, |
||||
pub params: Box<dyn params::Params>, |
||||
pub label: String |
||||
} |
||||
|
||||
impl PartialEq for Node { |
||||
fn eq(&self, other: &Node) -> bool{ |
||||
self.label == other.label |
||||
} |
||||
} |
||||
|
||||
|
||||
|
@ -1,15 +1,39 @@ |
||||
use ndarray::prelude::*; |
||||
use std::collections::{HashMap, BTreeSet}; |
||||
use petgraph::prelude::*; |
||||
|
||||
pub struct CIM { |
||||
cim: Array3<f64>, |
||||
} |
||||
|
||||
pub struct M { |
||||
transitions: Array3<u64>, |
||||
|
||||
pub trait Params { |
||||
|
||||
fn add_parent(&mut self, p: &petgraph::stable_graph::NodeIndex); |
||||
} |
||||
|
||||
pub struct T { |
||||
residence_time: Array2<f64>, |
||||
pub struct DiscreteStatesContinousTimeParams { |
||||
domain: BTreeSet<String>, |
||||
parents: BTreeSet<petgraph::stable_graph::NodeIndex>, |
||||
cim: Option<Array3<f64>>, |
||||
transitions: Option<Array3<u64>>, |
||||
residence_time: Option<Array2<f64>> |
||||
} |
||||
|
||||
impl DiscreteStatesContinousTimeParams { |
||||
fn init(domain: BTreeSet<String>) -> DiscreteStatesContinousTimeParams { |
||||
DiscreteStatesContinousTimeParams { |
||||
domain: domain, |
||||
parents: BTreeSet::new(), |
||||
cim: Option::None, |
||||
transitions: Option::None, |
||||
residence_time: Option::None |
||||
} |
||||
} |
||||
} |
||||
|
||||
impl Params for DiscreteStatesContinousTimeParams { |
||||
fn add_parent(&mut self, p: &petgraph::stable_graph::NodeIndex) { |
||||
self.parents.insert(p.clone()); |
||||
self.cim = Option::None; |
||||
self.transitions = Option::None; |
||||
self.residence_time = Option::None; |
||||
} |
||||
} |
||||
|
@ -0,0 +1,30 @@ |
||||
use ndarray::prelude::*; |
||||
use crate::network; |
||||
use petgraph::prelude::*; |
||||
use rand::Rng; |
||||
|
||||
pub struct Trajectory { |
||||
time: Array1<f64>, |
||||
events: Array2<u32> |
||||
} |
||||
|
||||
pub struct Dataset { |
||||
trajectories: Vec<Trajectory> |
||||
} |
||||
|
||||
|
||||
fn trajectory_generator(net: &Box<dyn network::Network>, n_trajectories: u64, t_end: f64) -> Dataset { |
||||
let mut dataset = Dataset{ |
||||
trajectories: Vec::new() |
||||
}; |
||||
for _ in 0..n_trajectories { |
||||
let mut rng = rand::thread_rng(); |
||||
let t = 0.0; |
||||
let mut time: Vec<f64> = Vec::new(); |
||||
let mut events: Vec<Vec<u32>> = Vec::new(); |
||||
let current_state: Vec<u32> = net.get_node_indices().map(|x| rng.gen_range(0..2)).collect(); |
||||
|
||||
} |
||||
|
||||
dataset |
||||
} |
Loading…
Reference in new issue