severe bug fixed in updating of Bayestree

release/4.3a0
Michael Kaess 2009-12-13 20:54:48 +00:00
parent a4f73ee04f
commit 0116b3a515
1 changed files with 8 additions and 3 deletions

View File

@ -214,8 +214,9 @@ namespace gtsam {
BOOST_FOREACH(sharedClique child, clique->children_) BOOST_FOREACH(sharedClique child, clique->children_)
child->parent_.reset(); child->parent_.reset();
BOOST_FOREACH(string key, clique->ordering()) BOOST_FOREACH(string key, clique->ordering()) {
nodes_.erase(key); nodes_.erase(key);
}
} }
/* ************************************************************************* */ /* ************************************************************************* */
@ -380,7 +381,7 @@ namespace gtsam {
// remove path above me // remove path above me
boost::tie(factors,orphans) = removePath<Factor>(clique->parent_); boost::tie(factors,orphans) = removePath<Factor>(clique->parent_);
// add children to list of orphans // add children to list of orphans (splice also removed them from clique->children_)
orphans.splice (orphans.begin(), clique->children_); orphans.splice (orphans.begin(), clique->children_);
// add myself to factors // add myself to factors
@ -454,11 +455,15 @@ namespace gtsam {
for ( rit=bayesNet.rbegin(); rit != bayesNet.rend(); ++rit ) for ( rit=bayesNet.rbegin(); rit != bayesNet.rend(); ++rit )
insert(*rit); insert(*rit);
int count = 0;
// add orphans to the bottom of the new tree // add orphans to the bottom of the new tree
BOOST_FOREACH(sharedClique orphan, orphans) { BOOST_FOREACH(sharedClique orphan, orphans) {
string key = orphan->separator_.front(); // todo: assumes there is a separator...
string key = orphan->separator_.front();
sharedClique parent = (*this)[key]; sharedClique parent = (*this)[key];
parent->children_ += orphan; parent->children_ += orphan;
orphan->parent_ = parent; // set new parent!
} }
} }