Solved issue with `candidate_parent_set` variable in CTPC and added loop to fill the adjacency matrix

pull/79/head
Meliurwen 2 years ago
parent 6d952f8c07
commit 6d42d8a805
Signed by: meliurwen
GPG Key ID: 818A8B35E9F1CE10
  1. 21
      reCTBN/src/structure_learning/constraint_based_algorithm.rs

@ -48,6 +48,7 @@ impl<P: ParameterLearning> StructureLearningAlgorithm for CTPC<P> {
.collect();
let mut b = 0;
while b < candidate_parent_set.len() {
let mut not_parent_node: usize = child_node;
for parent_node in candidate_parent_set.iter() {
for separation_set in candidate_parent_set
.iter()
@ -62,16 +63,30 @@ impl<P: ParameterLearning> StructureLearningAlgorithm for CTPC<P> {
*parent_node,
&separation_set,
&mut self.cache,
) && self.Chi2test.call(&net, child_node, *parent_node, &separation_set, &mut self.cache) {
candidate_parent_set.remove(&parent_node);
) && self.Chi2test.call(
&net,
child_node,
*parent_node,
&separation_set,
&mut self.cache,
) {
not_parent_node = parent_node.clone();
break;
}
}
if not_parent_node != child_node {
break;
}
}
if not_parent_node != child_node {
candidate_parent_set.remove(&not_parent_node);
}
b = b + 1;
}
for parent_node in candidate_parent_set.iter() {
net.add_edge(*parent_node, child_node);
}
}
net
}
}

Loading…
Cancel
Save