From ea5df7cad6485742905f2a0297a95cfc6cf2f801 Mon Sep 17 00:00:00 2001 From: meliurwen Date: Tue, 20 Dec 2022 12:36:28 +0100 Subject: [PATCH] Solved another issue with `candidate_parent_set` variable in CTPC --- .../constraint_based_algorithm.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/reCTBN/src/structure_learning/constraint_based_algorithm.rs b/reCTBN/src/structure_learning/constraint_based_algorithm.rs index d94c793..8949aa5 100644 --- a/reCTBN/src/structure_learning/constraint_based_algorithm.rs +++ b/reCTBN/src/structure_learning/constraint_based_algorithm.rs @@ -46,15 +46,15 @@ impl StructureLearningAlgorithm for CTPC

{ .into_iter() .filter(|x| x != &child_node) .collect(); - let mut b = 0; - while b < candidate_parent_set.len() { - let mut not_parent_node: usize = child_node; + let mut separation_set_size = 0; + while separation_set_size < candidate_parent_set.len() { + let mut candidate_parent_set_TMP = candidate_parent_set.clone(); for parent_node in candidate_parent_set.iter() { for separation_set in candidate_parent_set .iter() .filter(|x| x != &parent_node) .map(|x| *x) - .combinations(b) + .combinations(separation_set_size) { let separation_set = separation_set.into_iter().collect(); if self.Ftest.call( @@ -70,18 +70,13 @@ impl StructureLearningAlgorithm for CTPC

{ &separation_set, &mut self.cache, ) { - not_parent_node = parent_node.clone(); + candidate_parent_set_TMP.remove(parent_node); break; } } - if not_parent_node != child_node { - break; - } - } - if not_parent_node != child_node { - candidate_parent_set.remove(¬_parent_node); } - b = b + 1; + candidate_parent_set = candidate_parent_set_TMP; + separation_set_size += 1; } for parent_node in candidate_parent_set.iter() { net.add_edge(*parent_node, child_node);