A new, blazing-fast learning engine for Continuous Time Bayesian Networks. Written in pure Rust. 🦀
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
reCTBN/src/tools.rs

47 lines
1.2 KiB

3 years ago
use ndarray::prelude::*;
use petgraph::prelude::*;
use crate::network;
use crate::node;
use crate::params;
use crate::params::Params;
3 years ago
pub struct Trajectory {
time: Array1<f64>,
events: Array2<u32>
}
pub struct Dataset {
trajectories: Vec<Trajectory>
}
pub fn trajectory_generator(net: &Box<dyn network::Network>, n_trajectories: u64, t_end: f64) -> Dataset {
3 years ago
let mut dataset = Dataset{
trajectories: Vec::new()
};
let node_idx: Vec<_> = net.get_node_indices().collect();
3 years ago
for _ in 0..n_trajectories {
let t = 0.0;
let mut time: Vec<f64> = Vec::new();
let mut events: Vec<Vec<params::StateType>> = Vec::new();
let mut current_state: Vec<params::StateType> = 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<Option<f64>> = (0..node_idx.len()).map(|_| Option::None).collect();
events.push(current_state.clone());
time.push(t.clone());
while t < t_end {
}
3 years ago
}
dataset
}