diff --git a/cpp/testIncremental.cpp b/cpp/testIncremental.cpp index cfffb2ee8..c489d0457 100644 --- a/cpp/testIncremental.cpp +++ b/cpp/testIncremental.cpp @@ -27,21 +27,19 @@ typedef BayesTree GaussianBayesTree; /* ************************************************************************* */ -void update(SymbolicBayesTree& bayesTree, const FactorGraph factorGraph) { +void update(SymbolicBayesTree& bayesTree, const FactorGraph& factorGraph) { + // Remove the contaminated part of the Bayes tree FactorGraph factors; SymbolicBayesTree::Cliques orphans; + BOOST_FOREACH(boost::shared_ptr factor, factorGraph) { - BOOST_FOREACH(FactorGraph::sharedFactor factor, factorGraph) { - // Remove the contaminated part of the Bayes tree FactorGraph newFactors; SymbolicBayesTree::Cliques newOrphans; boost::tie(newFactors, newOrphans) = bayesTree.removeTop(factor); - orphans.insert(orphans.begin(), newOrphans.begin(), newOrphans.end()); - const FactorGraph test = newFactors; - BOOST_FOREACH(FactorGraph::sharedFactor newFactor, (const FactorGraph)newFactors) - factors.push_back(newFactor); + factors.push_back(newFactors); + orphans.splice (orphans.begin(), newOrphans); } // create an ordering for the new and contaminated factors @@ -50,14 +48,14 @@ void update(SymbolicBayesTree& bayesTree, const FactorGraph fact // eliminate into a Bayes net SymbolicBayesNet bayesNet = eliminate(factors,ordering); - // turn back into a Bayes Tree + // insert conditionals back in, straight into the topless bayesTree SymbolicBayesNet::const_reverse_iterator rit; for ( rit=bayesNet.rbegin(); rit != bayesNet.rend(); ++rit ) bayesTree.insert(*rit); // add orphans to the bottom of the new tree BOOST_FOREACH(SymbolicBayesTree::sharedClique orphan, orphans) { - string key = *(orphan->separator_.begin()); // todo: assumes there is a separator... + string key = orphan->separator_.front(); // todo: assumes there is a separator... SymbolicBayesTree::sharedClique parent = bayesTree[key]; parent->children_ += orphan; }