More complex example

release/4.3a0
Frank Dellaert 2010-07-15 01:41:11 +00:00
parent 65661d20ad
commit 4ffc55d8a2
1 changed files with 16 additions and 11 deletions

View File

@ -26,27 +26,32 @@ template class EliminationTree<SymbolicFactorGraph>;
typedef EliminationTree<SymbolicFactorGraph> SymbolicEliminationTree; typedef EliminationTree<SymbolicFactorGraph> SymbolicEliminationTree;
/* ************************************************************************* * /* ************************************************************************* *
* graph: x1 - x2 - x3 - x4 * graph: f(1,2) f(1,3) f(2,5) f(3,5) f(4,5)
* tree: x1 -> x2 -> x3 <- x4 (arrow is parent pointer) * tree: x1 -> x2 -> x3 -> x5 <- x4 (arrow is parent pointer)
****************************************************************************/ ****************************************************************************/
TEST( EliminationTree, constructor ) TEST( EliminationTree, constructor )
{ {
Ordering ordering; ordering += "x1","x2","x4","x3"; Ordering ordering; ordering += "x1","x2","x3","x4","x5";
/** build expected tree using constructor variant 1 */ /** build expected tree using constructor variant 1 */
SymbolicEliminationTree::OrderedGraphs orderedGraphs; SymbolicEliminationTree::OrderedGraphs graphs;
SymbolicFactorGraph c1; c1.push_factor("x1","x2"); orderedGraphs += make_pair("x1",c1); SymbolicFactorGraph c1,c2,c3,c4,c5;
SymbolicFactorGraph c2; c2.push_factor("x2","x3"); orderedGraphs += make_pair("x2",c2); c1.push_factor("x1","x2"); c1.push_factor("x1","x3"); graphs += make_pair("x1",c1);
SymbolicFactorGraph c4; c4.push_factor("x4","x3"); orderedGraphs += make_pair("x4",c4); c2.push_factor("x2","x5"); graphs += make_pair("x2",c2);
SymbolicFactorGraph c3; orderedGraphs += make_pair("x3",c3); c3.push_factor("x3","x5"); graphs += make_pair("x3",c3);
SymbolicEliminationTree expected(orderedGraphs); c4.push_factor("x4","x5"); graphs += make_pair("x4",c4);
graphs += make_pair("x5",c5);
SymbolicEliminationTree expected(graphs);
/** build actual tree from factor graph (variant 2) */ /** build actual tree from factor graph (variant 2) */
SymbolicFactorGraph fg; SymbolicFactorGraph fg;
fg.push_factor("x1","x2"); fg.push_factor("x1","x2");
fg.push_factor("x2","x3"); fg.push_factor("x1","x3");
fg.push_factor("x3","x4"); fg.push_factor("x2","x5");
fg.push_factor("x3","x5");
fg.push_factor("x4","x5");
SymbolicEliminationTree actual(fg, ordering); SymbolicEliminationTree actual(fg, ordering);
// GTSAM_PRINT(actual);
CHECK(assert_equal<SymbolicEliminationTree>(expected, actual)); CHECK(assert_equal<SymbolicEliminationTree>(expected, actual));
} }