CtmpProcess

Struct CtmpProcess 

Source
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§

Trait Implementations§

Source§

impl NetworkProcess for CtmpProcess

Source§

fn initialize_adj_matrix(&mut self)

Source§

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)

Add a directed edge between a two nodes of the network. Read more
Source§

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

Get the numbers of nodes contained in the network.
Source§

fn get_node(&self, node_idx: usize) -> &Params

Get the node param. Read more
Source§

fn get_node_mut(&mut self, node_idx: usize) -> &mut Params

Get the node param. Read more
Source§

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 more
Source§

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 more
Source§

fn get_parent_set(&self, node: usize) -> BTreeSet<usize>

Get the parent set of a given node. Read more
Source§

fn get_children_set(&self, node: usize) -> BTreeSet<usize>

Get the children set of a given node. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

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

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V