pub struct CtmpProcess { /* private fields */ }Expand description
This structure represents a Continuous Time Markov process
-
Arguments
-
param- An Option containing the parameters of the process
use std::collections::BTreeSet;
use reCTBN::process::NetworkProcess;
use reCTBN::params;
use reCTBN::process::ctbn::*;
use ndarray::arr3;
//Create the domain for a discrete node
let mut domain = BTreeSet::new();
domain.insert(String::from("A"));
domain.insert(String::from("B"));
//Create the parameters for a discrete node using the domain
let param = params::DiscreteStatesContinousTimeParams::new("X1".to_string(), domain);
//Create the node using the parameters
let X1 = params::Params::DiscreteStatesContinousTime(param);
let mut domain = BTreeSet::new();
domain.insert(String::from("A"));
domain.insert(String::from("B"));
let param = params::DiscreteStatesContinousTimeParams::new("X2".to_string(), domain);
let X2 = params::Params::DiscreteStatesContinousTime(param);
//Initialize a ctbn
let mut net = CtbnNetwork::new();
//Add nodes
let X1 = net.add_node(X1).unwrap();
let X2 = net.add_node(X2).unwrap();
//Add an edge
net.add_edge(X1, X2);
match &mut net.get_node_mut(X1) {
params::Params::DiscreteStatesContinousTime(param) => {
assert_eq!(Ok(()), param.set_cim(arr3(&[[[-0.1, 0.1], [1.0, -1.0]]])));
}
}
match &mut net.get_node_mut(X2) {
params::Params::DiscreteStatesContinousTime(param) => {
assert_eq!(
Ok(()),
param.set_cim(arr3(&[
[[-0.01, 0.01], [5.0, -5.0]],
[[-5.0, 5.0], [0.01, -0.01]]
]))
);
}
}
//Amalgamate the ctbn into a CtmpProcess
let ctmp = net.amalgamation();
//Extract the amalgamated params from the ctmp
let params::Params::DiscreteStatesContinousTime(p_ctmp) = &ctmp.get_node(0);
let p_ctmp = p_ctmp.get_cim().as_ref().unwrap();
//The shape of the params for an amalgamated ctmp can be computed as a Cartesian product of the
//domains variables of the ctbn
assert_eq!(p_ctmp.shape()[1], 4);Implementations§
Source§impl CtmpProcess
impl CtmpProcess
pub fn new() -> CtmpProcess
Trait Implementations§
Source§impl NetworkProcess for CtmpProcess
impl NetworkProcess for CtmpProcess
fn initialize_adj_matrix(&mut self)
Source§fn add_node(&mut self, n: Params) -> Result<usize, NetworkError>
fn add_node(&mut self, n: Params) -> Result<usize, NetworkError>
Add a node to the network Read more
Source§fn add_edge(&mut self, _parent: usize, _child: usize)
fn add_edge(&mut self, _parent: usize, _child: usize)
Add a directed edge between a two nodes of the network. Read more
Source§fn get_node_indices(&self) -> Range<usize>
fn get_node_indices(&self) -> Range<usize>
Get all the indices of the nodes contained inside the network.
Source§fn get_number_of_nodes(&self) -> usize
fn get_number_of_nodes(&self) -> usize
Get the numbers of nodes contained in the network.
Source§fn get_param_index_network(
&self,
node: usize,
current_state: &NetworkProcessState,
) -> usize
fn get_param_index_network( &self, node: usize, current_state: &NetworkProcessState, ) -> usize
Compute the index that must be used to access the parameters of a
node, given a specific
configuration of the network. Read moreSource§fn get_param_index_from_custom_parent_set(
&self,
_current_state: &NetworkProcessState,
_parent_set: &BTreeSet<usize>,
) -> usize
fn get_param_index_from_custom_parent_set( &self, _current_state: &NetworkProcessState, _parent_set: &BTreeSet<usize>, ) -> usize
Compute the index that must be used to access the parameters of a
node, given a specific
configuration of the network and a generic parent_set. Read moreAuto Trait Implementations§
impl Freeze for CtmpProcess
impl RefUnwindSafe for CtmpProcess
impl Send for CtmpProcess
impl Sync for CtmpProcess
impl Unpin for CtmpProcess
impl UnwindSafe for CtmpProcess
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.