diff --git a/reCTBN/src/structure_learning/constraint_based_algorithm.rs b/reCTBN/src/structure_learning/constraint_based_algorithm.rs index 670c8ed..d931f78 100644 --- a/reCTBN/src/structure_learning/constraint_based_algorithm.rs +++ b/reCTBN/src/structure_learning/constraint_based_algorithm.rs @@ -1,5 +1,39 @@ //! Module containing constraint based algorithms like CTPC and Hiton. -//pub struct CTPC { -// -//} +use super::hypothesis_test::*; +use crate::structure_learning::StructureLearningAlgorithm; +use crate::{process, tools}; +use crate::parameter_learning::{Cache, ParameterLearning}; + +pub struct CTPC { + Ftest: F, + Chi2test: ChiSquare, + cache: Cache

, + +} + +impl CTPC

{ + pub fn new(Ftest: F, Chi2test: ChiSquare, cache: Cache

) -> CTPC

{ + CTPC { + Chi2test, + Ftest, + cache, + } + } +} + +impl StructureLearningAlgorithm for CTPC

{ + fn fit_transform(&self, net: T, dataset: &tools::Dataset) -> T + where + T: process::NetworkProcess, + { + //Check the coherence between dataset and network + if net.get_number_of_nodes() != dataset.get_trajectories()[0].get_events().shape()[1] { + panic!("Dataset and Network must have the same number of variables.") + } + + //Make the network mutable. + let mut net = net; + net + } +}