From e440767db913d67b54136459a5c3b7a70bcbe6a5 Mon Sep 17 00:00:00 2001 From: Frank Dellaert Date: Fri, 20 Nov 2009 05:23:47 +0000 Subject: [PATCH] Use [involves], and now updating orphan list --- cpp/testIncremental.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/cpp/testIncremental.cpp b/cpp/testIncremental.cpp index 810df6f51..0b90e7c67 100644 --- a/cpp/testIncremental.cpp +++ b/cpp/testIncremental.cpp @@ -31,16 +31,27 @@ SymbolicBayesTree update(const SymbolicBayesTree& initial, // create an empty factor graph SymbolicFactorGraph factorGraph; + // the list of orphaned subtrees + std::list orphans; + // process each key of the new factor BOOST_FOREACH(string key, newFactor->keys()) { // todo: add path to root // only add if key is not yet in the factor graph - std::list keys = factorGraph.keys(); - if (find(keys.begin(), keys.end(), key) == keys.end()) { + if (!factorGraph.involves(key)) { // get the clique SymbolicBayesTree::sharedClique clique = initial[key]; + + // if in orphans, remove the clique + orphans.remove(clique); + + // add children to orphans + BOOST_FOREACH(SymbolicBayesTree::sharedClique child, clique->children_) + orphans.push_back(child); + + // convert to factors FactorGraph clique_factors(*clique); // add it to the factor graph @@ -48,12 +59,6 @@ SymbolicBayesTree update(const SymbolicBayesTree& initial, } } - // todo: automatically generate list of orphans, including subtrees! - std::list orphans; - SymbolicBayesTree::sharedClique TEL = initial["T"]; - SymbolicBayesTree::sharedClique XE = initial["X"]; - orphans += TEL, XE; - // now add the new factor factorGraph.push_back(newFactor);