Strengthened test and now checks problemSize_
parent
c3811a5488
commit
5237c74928
|
@ -64,35 +64,39 @@ using symbol_shorthand::L;
|
|||
|
||||
/* ************************************************************************* *
|
||||
Bayes tree for smoother with "nested dissection" ordering:
|
||||
C1 x5 x6 x4
|
||||
C2 x3 x2 : x4
|
||||
C3 x1 : x2
|
||||
C4 x7 : x6
|
||||
*/
|
||||
TEST( GaussianJunctionTreeB, constructor2 )
|
||||
{
|
||||
C1 x5 x6 x4
|
||||
C2 x3 x2 : x4
|
||||
C3 x1 : x2
|
||||
C4 x7 : x6
|
||||
*/
|
||||
TEST( GaussianJunctionTreeB, constructor2 ) {
|
||||
// create a graph
|
||||
NonlinearFactorGraph nlfg;
|
||||
Values values;
|
||||
boost::tie(nlfg,values) = createNonlinearSmoother(7);
|
||||
boost::tie(nlfg, values) = createNonlinearSmoother(7);
|
||||
SymbolicFactorGraph::shared_ptr symbolic = nlfg.symbolic();
|
||||
|
||||
// linearize
|
||||
GaussianFactorGraph::shared_ptr fg = nlfg.linearize(values);
|
||||
|
||||
Ordering ordering; ordering += X(1),X(3),X(5),X(7),X(2),X(6),X(4);
|
||||
Ordering ordering;
|
||||
ordering += X(1), X(3), X(5), X(7), X(2), X(6), X(4);
|
||||
|
||||
// create an ordering
|
||||
GaussianEliminationTree etree(*fg, ordering);
|
||||
SymbolicEliminationTree stree(*symbolic,ordering);
|
||||
SymbolicEliminationTree stree(*symbolic, ordering);
|
||||
GTSAM_PRINT(stree);
|
||||
GaussianJunctionTree actual(etree);
|
||||
GTSAM_PRINT(actual);
|
||||
|
||||
Ordering o324; o324 += X(3), X(2), X(4);
|
||||
Ordering o56; o56 += X(5), X(6);
|
||||
Ordering o7; o7 += X(7);
|
||||
Ordering o1; o1 += X(1);
|
||||
Ordering o324;
|
||||
o324 += X(3), X(2), X(4);
|
||||
Ordering o56;
|
||||
o56 += X(5), X(6);
|
||||
Ordering o7;
|
||||
o7 += X(7);
|
||||
Ordering o1;
|
||||
o1 += X(1);
|
||||
|
||||
// Can no longer test these:
|
||||
// Ordering sep1;
|
||||
|
@ -102,26 +106,31 @@ TEST( GaussianJunctionTreeB, constructor2 )
|
|||
|
||||
GaussianJunctionTree::sharedNode x324 = actual.roots().front();
|
||||
LONGS_EQUAL(2, x324->children.size());
|
||||
#if defined(__APPLE__) // tie-breaking seems different :-(
|
||||
GaussianJunctionTree::sharedNode x1 = x324->children[0];
|
||||
GaussianJunctionTree::sharedNode x56 = x324->children[1];
|
||||
#else
|
||||
GaussianJunctionTree::sharedNode x1 = x324->children[1];
|
||||
GaussianJunctionTree::sharedNode x56 = x324->children[0];
|
||||
#endif
|
||||
if (x1->children.size() > 0)
|
||||
x1.swap(x56); // makes it work with different tie-breakers
|
||||
|
||||
LONGS_EQUAL(0, x1->children.size());
|
||||
LONGS_EQUAL(1, x56->children.size());
|
||||
GaussianJunctionTree::sharedNode x7 = x56->children[0];
|
||||
LONGS_EQUAL(0, x7->children.size());
|
||||
|
||||
EXPECT(assert_equal(o324, x324->orderedFrontalKeys));
|
||||
EXPECT_LONGS_EQUAL (5, x324->factors.size());
|
||||
EXPECT(assert_equal(o56, x56->orderedFrontalKeys));
|
||||
EXPECT_LONGS_EQUAL (4, x56->factors.size());
|
||||
EXPECT(assert_equal(o7, x7->orderedFrontalKeys));
|
||||
EXPECT_LONGS_EQUAL (2, x7->factors.size());
|
||||
EXPECT(assert_equal(o1, x1->orderedFrontalKeys));
|
||||
EXPECT_LONGS_EQUAL (2, x1->factors.size());
|
||||
EXPECT_LONGS_EQUAL(5, x324->factors.size());
|
||||
EXPECT_LONGS_EQUAL(9, x324->problemSize_);
|
||||
|
||||
EXPECT(assert_equal(o56, x56->orderedFrontalKeys));
|
||||
EXPECT_LONGS_EQUAL(4, x56->factors.size());
|
||||
EXPECT_LONGS_EQUAL(9, x56->problemSize_);
|
||||
|
||||
EXPECT(assert_equal(o7, x7->orderedFrontalKeys));
|
||||
EXPECT_LONGS_EQUAL(2, x7->factors.size());
|
||||
EXPECT_LONGS_EQUAL(4, x7->problemSize_);
|
||||
|
||||
EXPECT(assert_equal(o1, x1->orderedFrontalKeys));
|
||||
EXPECT_LONGS_EQUAL(2, x1->factors.size());
|
||||
EXPECT_LONGS_EQUAL(4, x1->problemSize_);
|
||||
}
|
||||
|
||||
///* ************************************************************************* */
|
||||
|
@ -266,6 +275,9 @@ TEST( GaussianJunctionTreeB, constructor2 )
|
|||
//}
|
||||
|
||||
/* ************************************************************************* */
|
||||
int main() { TestResult tr; return TestRegistry::runAllTests(tr);}
|
||||
int main() {
|
||||
TestResult tr;
|
||||
return TestRegistry::runAllTests(tr);
|
||||
}
|
||||
/* ************************************************************************* */
|
||||
|
||||
|
|
Loading…
Reference in New Issue