From 6e90458418c8d3d6b9c9107faa8ec4ef77a238e6 Mon Sep 17 00:00:00 2001 From: meliurwen Date: Mon, 28 Nov 2022 11:08:20 +0100 Subject: [PATCH] Laying grounds for CTPC --- .../constraint_based_algorithm.rs | 40 +++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) 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 + } +}