testSymbolicISAM.cpp
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
20 
22 
23 #include <boost/assign/std/list.hpp> // for operator +=
24 using namespace boost::assign;
25 
26 using namespace std;
27 using namespace gtsam;
28 
29 /* ************************************************************************* */
30 // Some numbers that should be consistent among all smoother tests
31 
32 //static double sigmax1 = 0.786153, sigmax2 = 0.687131 ,sigmax3 = 0.671512,
33 //sigmax4 = 0.669534, sigmax5 = sigmax3,, sigmax7 = sigmax1, sigmax6 = sigmax2;
34 
35 /* ************************************************************************* */
36 
38 //SymbolicConditional::shared_ptr x3(new SymbolicConditional("x3")),
39 // x2(new SymbolicConditional("x2","x3")),
40 // x1(new SymbolicConditional("x1","x2","x3")),
41 // l1(new SymbolicConditional("l1","x1","x2")),
42 // l2(new SymbolicConditional("l2","x1","x3"));
43 //
45 //SymbolicISAM createSlamSymbolicISAM(){
46 // // Create using insert
47 // SymbolicISAM bayesTree_slam;
48 // bayesTree_slam.insert(x3);
49 // bayesTree_slam.insert(x2);
50 // bayesTree_slam.insert(x1);
51 // bayesTree_slam.insert(l2);
52 // bayesTree_slam.insert(l1);
53 // return bayesTree_slam;
54 //}
55 
56 /* ************************************************************************* */
57 
59 //SymbolicConditional::shared_ptr
60 // B(new SymbolicConditional("B")),
61 // L(new SymbolicConditional("L", "B")),
62 // E(new SymbolicConditional("E", "B", "L")),
63 // S(new SymbolicConditional("S", "L", "B")),
64 // T(new SymbolicConditional("T", "E", "L")),
65 // X(new SymbolicConditional("X", "E"));
66 //
68 //SymbolicISAM createAsiaSymbolicISAM() {
69 // SymbolicISAM bayesTree;
70 // bayesTree.insert(B);
71 // bayesTree.insert(L);
72 // bayesTree.insert(E);
73 // bayesTree.insert(S);
74 // bayesTree.insert(T);
75 // bayesTree.insert(X);
76 // return bayesTree;
77 //}
78 
79 /* ************************************************************************* */
81 {
82  // Now we modify the Bayes tree by inserting a new factor over B and S
83 
84  SymbolicFactorGraph fullGraph;
85  fullGraph += asiaGraph;
86  fullGraph += SymbolicFactor(_B_, _S_);
87 
88  // This ordering is chosen to match the one chosen by COLAMD during the ISAM update
89  Ordering ordering(list_of(_X_)(_B_)(_S_)(_E_)(_L_)(_T_));
90  SymbolicBayesTree expected = *fullGraph.eliminateMultifrontal(ordering);
91 
92  // Add factor on B and S
93  SymbolicISAM actual = *asiaGraph.eliminateMultifrontal();
94 
95  // Check whether the same
96  EXPECT(assert_equal(expected, (const SymbolicBayesTree&)actual));
97 }
98 
99 /* ************************************************************************* */
100 //TEST( ISAM, iSAM_slam )
101 //{
102 // // Create using insert
103 // SymbolicISAM bayesTree_slam = createSlamSymbolicISAM();
104 //
105 // //New conditionals for the expected Bayes tree
106 // SymbolicConditional::shared_ptr
107 // l1_(new SymbolicConditional("l1","x1","x2","x3"));
108 //
109 // // Create expected Bayes tree
110 // SymbolicISAM expected_slam;
111 // expected_slam.insert(x3);
112 // expected_slam.insert(x2);
113 // expected_slam.insert(x1);
114 // expected_slam.insert(l1_);
115 // expected_slam.insert(l2);
116 //
117 //
118 // // create new factors to be inserted
119 // SymbolicFactorGraph factorGraph_slam;
120 // factorGraph_slam.push_factor("x3","l1");
121 // factorGraph_slam.push_factor("x3");
122 //
123 // // do incremental inference
124 // bayesTree_slam.update(factorGraph_slam);
125 //
126 // // Check whether the same
127 // CHECK(assert_equal(expected_slam,bayesTree_slam));
128 //}
129 
130 /* ************************************************************************* */
131 int main() { TestResult tr; return TestRegistry::runAllTests(tr);}
132 /* ************************************************************************* */
static int runAllTests(TestResult &result)
static enum @843 ordering
Matrix expected
Definition: testMatrix.cpp:974
boost::shared_ptr< BayesTreeType > eliminateMultifrontal(OptionalOrderingType orderingType=boost::none, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex=boost::none) const
TEST(SymbolicISAM, iSAM)
Definition: Half.h:150
static const Key _L_
#define EXPECT(condition)
Definition: Test.h:151
int main()
static const Key _B_
traits
Definition: chartTesting.h:28
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
Definition: Matrix.cpp:42


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:49:57