From 6c2077ccc5bc43117320afe12811f23903b0c30a Mon Sep 17 00:00:00 2001 From: Richard Roberts Date: Tue, 19 Nov 2013 00:26:18 +0000 Subject: [PATCH] Updated unit tests for clique finding fix --- gtsam/symbolic/tests/symbolicExampleGraphs.h | 6 ++++- .../symbolic/tests/testSymbolicBayesTree.cpp | 25 +++++++++++-------- .../tests/testSymbolicFactorGraph.cpp | 3 ++- tests/testGaussianBayesTree.cpp | 2 +- tests/testGaussianISAM2.cpp | 2 +- 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/gtsam/symbolic/tests/symbolicExampleGraphs.h b/gtsam/symbolic/tests/symbolicExampleGraphs.h index 8b7c32bd9..b70595ac9 100644 --- a/gtsam/symbolic/tests/symbolicExampleGraphs.h +++ b/gtsam/symbolic/tests/symbolicExampleGraphs.h @@ -105,7 +105,11 @@ namespace gtsam { SymbolicBayesTree result; result.insertRoot(boost::make_shared( boost::make_shared( - SymbolicConditional::FromKeys(boost::assign::list_of(_S_)(_E_)(_L_)(_B_), 4)))); + SymbolicConditional::FromKeys(boost::assign::list_of(_E_)(_L_)(_B_), 3)))); + result.addClique(boost::make_shared( + boost::make_shared( + SymbolicConditional::FromKeys(boost::assign::list_of(_S_)(_B_) (_L_), 1))), + result.roots().front()); result.addClique(boost::make_shared( boost::make_shared( SymbolicConditional::FromKeys(boost::assign::list_of(_T_)(_E_)(_L_), 1))), diff --git a/gtsam/symbolic/tests/testSymbolicBayesTree.cpp b/gtsam/symbolic/tests/testSymbolicBayesTree.cpp index 52e13e3d2..ab4f2d259 100644 --- a/gtsam/symbolic/tests/testSymbolicBayesTree.cpp +++ b/gtsam/symbolic/tests/testSymbolicBayesTree.cpp @@ -145,19 +145,19 @@ TEST( BayesTree, removePath2 ) // Check expected outcome SymbolicFactorGraph expected; - expected += SymbolicFactor(_S_,_E_,_L_,_B_); + expected += SymbolicFactor(_E_,_L_,_B_); CHECK(assert_equal(expected, factors)); SymbolicBayesTree::Cliques expectedOrphans; - expectedOrphans += bayesTree[_T_], bayesTree[_X_]; + expectedOrphans += bayesTree[_S_], bayesTree[_T_], bayesTree[_X_]; CHECK(assert_container_equal(expectedOrphans|indirected, orphans|indirected)); } /* ************************************************************************* */ -TEST( BayesTree, removePath3 ) +TEST(BayesTree, removePath3) { SymbolicBayesTree bayesTree = asiaBayesTree; - // Call remove-path with clique S + // Call remove-path with clique T SymbolicBayesNet bn; SymbolicBayesTree::Cliques orphans; bayesTree.removePath(bayesTree[_T_], bn, orphans); @@ -165,11 +165,11 @@ TEST( BayesTree, removePath3 ) // Check expected outcome SymbolicFactorGraph expected; - expected += SymbolicFactor(_S_,_E_,_L_,_B_); - expected += SymbolicFactor(_T_,_E_,_L_); + expected += SymbolicFactor(_E_, _L_, _B_); + expected += SymbolicFactor(_T_, _E_, _L_); CHECK(assert_equal(expected, factors)); SymbolicBayesTree::Cliques expectedOrphans; - expectedOrphans += bayesTree[_X_]; + expectedOrphans += bayesTree[_S_], bayesTree[_X_]; CHECK(assert_container_equal(expectedOrphans|indirected, orphans|indirected)); } @@ -248,7 +248,8 @@ TEST( BayesTree, removeTop ) // Check expected outcome SymbolicBayesNet expected; - expected += SymbolicConditional::FromKeys(list_of(_S_)(_E_)(_L_)(_B_), 4); + expected += SymbolicConditional::FromKeys(list_of(_E_)(_L_)(_B_), 3); + expected += SymbolicConditional::FromKeys(list_of(_S_)(_B_)(_L_), 1); CHECK(assert_equal(expected, bn)); SymbolicBayesTree::Cliques expectedOrphans; @@ -284,12 +285,12 @@ TEST( BayesTree, removeTop2 ) // Check expected outcome SymbolicBayesNet expected = list_of - (SymbolicConditional::FromKeys(list_of(_S_)(_E_)(_L_)(_B_), 4)) + (SymbolicConditional::FromKeys(list_of(_E_)(_L_)(_B_), 3)) (SymbolicConditional::FromKeys(list_of(_T_)(_E_)(_L_), 1)); CHECK(assert_equal(expected, bn)); SymbolicBayesTree::Cliques expectedOrphans; - expectedOrphans += bayesTree[_X_]; + expectedOrphans += bayesTree[_S_], bayesTree[_X_]; CHECK(assert_container_equal(expectedOrphans|indirected, orphans|indirected)); } @@ -414,7 +415,9 @@ TEST( SymbolicBayesTree, thinTree ) { // check shortcut P(S8||R) to root SymbolicBayesTree::Clique::shared_ptr c = bayesTree[8]; SymbolicBayesNet shortcut = c->shortcut(R); - SymbolicBayesNet expected = list_of(SymbolicConditional(14, 11, 13)); + SymbolicBayesNet expected = list_of + (SymbolicConditional(12, 14)) + (SymbolicConditional(14, 11, 13)); EXPECT(assert_equal(expected, shortcut)); } diff --git a/gtsam/symbolic/tests/testSymbolicFactorGraph.cpp b/gtsam/symbolic/tests/testSymbolicFactorGraph.cpp index c2eabdd20..a5ad7519c 100644 --- a/gtsam/symbolic/tests/testSymbolicFactorGraph.cpp +++ b/gtsam/symbolic/tests/testSymbolicFactorGraph.cpp @@ -270,7 +270,8 @@ TEST( SymbolicFactorGraph, constructFromBayesTree ) { // create expected factor graph SymbolicFactorGraph expected; - expected.push_factor(_S_, _E_, _L_, _B_); + expected.push_factor(_E_, _L_, _B_); + expected.push_factor(_S_, _B_, _L_); expected.push_factor(_T_, _E_, _L_); expected.push_factor(_X_, _E_); diff --git a/tests/testGaussianBayesTree.cpp b/tests/testGaussianBayesTree.cpp index 8ca7259ba..e63d613d1 100644 --- a/tests/testGaussianBayesTree.cpp +++ b/tests/testGaussianBayesTree.cpp @@ -127,7 +127,7 @@ TEST( GaussianBayesTree, balanced_smoother_marginals ) VectorValues expectedSolution = VectorValues::Zero(actualSolution); EXPECT(assert_equal(expectedSolution,actualSolution,tol)); - LONGS_EQUAL(3, (long)bayesTree.size()); + LONGS_EQUAL(4, (long)bayesTree.size()); double tol=1e-5; diff --git a/tests/testGaussianISAM2.cpp b/tests/testGaussianISAM2.cpp index e438f4753..85c332e6a 100644 --- a/tests/testGaussianISAM2.cpp +++ b/tests/testGaussianISAM2.cpp @@ -847,7 +847,7 @@ TEST(ISAM2, marginalCovariance) TEST(ISAM2, calculate_nnz) { ISAM2 isam = createSlamlikeISAM2(); - int expected = 262; + int expected = 241; int actual = calculate_nnz(isam.roots().front()); EXPECT_LONGS_EQUAL(expected, actual);