remove_path now also returns list of orphaned subtree roots; compile problem...

release/4.3a0
Michael Kaess 2009-11-21 23:41:43 +00:00
parent 82aae3c161
commit 4449cfd30c
3 changed files with 22 additions and 14 deletions

View File

@ -344,26 +344,32 @@ namespace gtsam {
ordering += key1, key2;
return eliminate<Factor,Conditional>(fg,ordering);
}
#if 0
/* ************************************************************************* */
template<class Conditional>
template<class Factor>
FactorGraph<Factor>
std::pair<FactorGraph<Factor>, std::list<sharedClique> >
BayesTree<Conditional>::removePath(sharedClique clique) {
// base case is NULL, return empty factor graph
if (clique==NULL) return FactorGraph<Factor>();
if (clique==NULL) {
list<sharedClique> orphans;
return make_pair<FactorGraph<Factor>(), orphans>;
}
// remove path above me
FactorGraph<Factor> factors = removePath<Factor>(clique->parent_);
std::pair<FactorGraph<Factor>, std::list<sharedClique> > factors_orphans = removePath<Factor>(clique->parent_);
// add children to list of orphans
factors_orphans.second.insert(factors_orphans.second.begin(), clique->children_.begin(), clique->children_.end());
// remove me and add my factors
removeClique(clique);
factors.push_back(*clique);
return factors;
return factors_orphans;
}
#endif
/* ************************************************************************* */
}

View File

@ -154,11 +154,11 @@ namespace gtsam {
/** return joint on two variables as a BayesNet */
template<class Factor>
BayesNet<Conditional> jointBayesNet(const std::string& key1, const std::string& key2) const;
/** Remove path from clique to root and return that path as factors */
#if 0
/** Remove path from clique to root and return that path as factors plus a list of orphaned subtree roots */
template<class Factor>
FactorGraph<Factor> removePath(sharedClique clique);
std::pair<FactorGraph<Factor>, std::list<sharedClique> > removePath(sharedClique clique);
#endif
}; // BayesTree
} /// namespace gtsam

View File

@ -331,16 +331,18 @@ TEST( BayesTree, removePath )
expected.push_factor("A","B");
expected.push_factor("A");
expected.push_factor("A","C");
SymbolicFactorGraph actual = bayesTree.removePath<SymbolicFactor>(bayesTree["C"]);
CHECK(assert_equal(expected, actual));
#if 0
std::pair<FactorGraph<Factor>, std::list<sharedClique> > actual =
bayesTree.removePath<SymbolicFactor>(bayesTree["C"]);
CHECK(assert_equal(expected, actual.first));
// remove E: factor graph with EB; E|B removed from second orphan tree
SymbolicFactorGraph expected3;
expected3.push_factor("B","E");
actual = bayesTree.removePath<SymbolicFactor>(bayesTree["E"]);
CHECK(assert_equal(expected3, actual));
CHECK(assert_equal(expected3, actual.first));
#endif
}
/* ************************************************************************* */