testDiscreteBayesTree.cpp
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3 * GTSAM Copyright 2010-2020, 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 
12 /*
13  * @file testDiscreteBayesTree.cpp
14  * @date sept 15, 2012
15  * @author Frank Dellaert
16  */
17 
18 #include <gtsam/base/Vector.h>
19 #include <gtsam/inference/Symbol.h>
24 
26 
27 #include <iostream>
28 #include <vector>
29 
30 using namespace gtsam;
31 static constexpr bool debug = false;
32 
33 /* ************************************************************************* */
34 struct TestFixture {
36  std::vector<DiscreteValues> assignments;
38  std::shared_ptr<DiscreteBayesTree> bayesTree;
39 
45  // Define variables.
46  for (int i = 0; i < 15; i++) {
47  DiscreteKey key_i(i, 2);
48  keys.push_back(key_i);
49  }
50 
51  // Enumerate all assignments.
53 
54  // Create thin-tree Bayesnet.
55  bayesNet.add(keys[14] % "1/3");
56 
57  bayesNet.add(keys[13] | keys[14] = "1/3 3/1");
58  bayesNet.add(keys[12] | keys[14] = "3/1 3/1");
59 
60  bayesNet.add((keys[11] | keys[13], keys[14]) = "1/4 2/3 3/2 4/1");
61  bayesNet.add((keys[10] | keys[13], keys[14]) = "1/4 3/2 2/3 4/1");
62  bayesNet.add((keys[9] | keys[12], keys[14]) = "4/1 2/3 F 1/4");
63  bayesNet.add((keys[8] | keys[12], keys[14]) = "T 1/4 3/2 4/1");
64 
65  bayesNet.add((keys[7] | keys[11], keys[13]) = "1/4 2/3 3/2 4/1");
66  bayesNet.add((keys[6] | keys[11], keys[13]) = "1/4 3/2 2/3 4/1");
67  bayesNet.add((keys[5] | keys[10], keys[13]) = "4/1 2/3 3/2 1/4");
68  bayesNet.add((keys[4] | keys[10], keys[13]) = "2/3 1/4 3/2 4/1");
69 
70  bayesNet.add((keys[3] | keys[9], keys[12]) = "1/4 2/3 3/2 4/1");
71  bayesNet.add((keys[2] | keys[9], keys[12]) = "1/4 8/2 2/3 4/1");
72  bayesNet.add((keys[1] | keys[8], keys[12]) = "4/1 2/3 3/2 1/4");
73  bayesNet.add((keys[0] | keys[8], keys[12]) = "2/3 1/4 3/2 4/1");
74 
75  // Create a BayesTree out of the Bayes net.
77  }
78 };
79 
80 /* ************************************************************************* */
81 // Check that BN and BT give the same answer on all configurations
82 TEST(DiscreteBayesTree, ThinTree) {
83  TestFixture self;
84 
85  if (debug) {
86  GTSAM_PRINT(self.bayesNet);
87  self.bayesNet.saveGraph("/tmp/discreteBayesNet.dot");
88  }
89 
90  // create a BayesTree out of a Bayes net
91  if (debug) {
92  GTSAM_PRINT(*self.bayesTree);
93  self.bayesTree->saveGraph("/tmp/discreteBayesTree.dot");
94  }
95 
96  // Check frontals and parents
97  for (size_t i : {13, 14, 9, 3, 2, 8, 1, 0, 10, 5, 4}) {
98  auto clique_i = (*self.bayesTree)[i];
99  EXPECT_LONGS_EQUAL(i, *(clique_i->conditional_->beginFrontals()));
100  }
101 
102  for (const auto& x : self.assignments) {
103  double expected = self.bayesNet.evaluate(x);
104  double actual = self.bayesTree->evaluate(x);
105  DOUBLES_EQUAL(expected, actual, 1e-9);
106  }
107 }
108 
109 /* ************************************************************************* */
110 // Check calculation of separator marginals
111 TEST(DiscreteBayesTree, SeparatorMarginals) {
112  TestFixture self;
113 
114  // Calculate some marginals for DiscreteValues==all1
115  double marginal_14 = 0, joint_8_12 = 0;
116  for (auto& x : self.assignments) {
117  double px = self.bayesTree->evaluate(x);
118  if (x[8] && x[12]) joint_8_12 += px;
119  if (x[14]) marginal_14 += px;
120  }
121  DiscreteValues all1 = self.assignments.back();
122 
123  // check separator marginal P(S0)
124  auto clique = (*self.bayesTree)[0];
125  DiscreteFactorGraph separatorMarginal0 =
126  clique->separatorMarginal(EliminateDiscrete);
127  DOUBLES_EQUAL(joint_8_12, separatorMarginal0(all1), 1e-9);
128 
129  // check separator marginal P(S9), should be P(14)
130  clique = (*self.bayesTree)[9];
131  DiscreteFactorGraph separatorMarginal9 =
132  clique->separatorMarginal(EliminateDiscrete);
133  DOUBLES_EQUAL(marginal_14, separatorMarginal9(all1), 1e-9);
134 
135  // check separator marginal of root, should be empty
136  clique = (*self.bayesTree)[11];
137  DiscreteFactorGraph separatorMarginal11 =
138  clique->separatorMarginal(EliminateDiscrete);
139  LONGS_EQUAL(0, separatorMarginal11.size());
140 }
141 
142 /* ************************************************************************* */
143 // Check shortcuts in the tree
144 TEST(DiscreteBayesTree, Shortcuts) {
145  TestFixture self;
146 
147  // Calculate some marginals for DiscreteValues==all1
148  double joint_11_13 = 0, joint_11_13_14 = 0, joint_11_12_13_14 = 0,
149  joint_9_11_12_13 = 0, joint_8_11_12_13 = 0;
150  for (auto& x : self.assignments) {
151  double px = self.bayesTree->evaluate(x);
152  if (x[11] && x[13]) {
153  joint_11_13 += px;
154  if (x[8] && x[12]) joint_8_11_12_13 += px;
155  if (x[9] && x[12]) joint_9_11_12_13 += px;
156  if (x[14]) {
157  joint_11_13_14 += px;
158  if (x[12]) {
159  joint_11_12_13_14 += px;
160  }
161  }
162  }
163  }
164  DiscreteValues all1 = self.assignments.back();
165 
166  auto R = self.bayesTree->roots().front();
167 
168  // check shortcut P(S9||R) to root
169  auto clique = (*self.bayesTree)[9];
170  DiscreteBayesNet shortcut = clique->shortcut(R, EliminateDiscrete);
171  LONGS_EQUAL(1, shortcut.size());
172  DOUBLES_EQUAL(joint_11_13_14 / joint_11_13, shortcut.evaluate(all1), 1e-9);
173 
174  // check shortcut P(S8||R) to root
175  clique = (*self.bayesTree)[8];
176  shortcut = clique->shortcut(R, EliminateDiscrete);
177  DOUBLES_EQUAL(joint_11_12_13_14 / joint_11_13, shortcut.evaluate(all1), 1e-9);
178 
179  // check shortcut P(S2||R) to root
180  clique = (*self.bayesTree)[2];
181  shortcut = clique->shortcut(R, EliminateDiscrete);
182  DOUBLES_EQUAL(joint_9_11_12_13 / joint_11_13, shortcut.evaluate(all1), 1e-9);
183 
184  // check shortcut P(S0||R) to root
185  clique = (*self.bayesTree)[0];
186  shortcut = clique->shortcut(R, EliminateDiscrete);
187  DOUBLES_EQUAL(joint_8_11_12_13 / joint_11_13, shortcut.evaluate(all1), 1e-9);
188 
189  if (debug) {
190  // print all shortcuts to root
191  DiscreteBayesTree::Nodes cliques = self.bayesTree->nodes();
192  for (auto clique : cliques) {
193  DiscreteBayesNet shortcut = clique.second->shortcut(R, EliminateDiscrete);
194  clique.second->conditional_->printSignature();
195  shortcut.print("shortcut:");
196  }
197  }
198 }
199 
200 /* ************************************************************************* */
201 // Check all marginals
202 TEST(DiscreteBayesTree, MarginalFactors) {
203  TestFixture self;
204 
205  // Caclulate marginals with brute force enumeration.
206  Vector marginals = Vector::Zero(15);
207  for (size_t i = 0; i < self.assignments.size(); ++i) {
208  DiscreteValues& x = self.assignments[i];
209  double px = self.bayesTree->evaluate(x);
210  for (size_t i = 0; i < 15; i++)
211  if (x[i]) marginals[i] += px;
212  }
213 
214  // Check all marginals
215  DiscreteValues all1 = self.assignments.back();
216  for (size_t i = 0; i < 15; i++) {
217  auto marginalFactor = self.bayesTree->marginalFactor(i, EliminateDiscrete);
218  double actual = (*marginalFactor)(all1);
219  DOUBLES_EQUAL(marginals[i], actual, 1e-9);
220  }
221 }
222 
223 /* ************************************************************************* */
224 // Check a number of joint marginals.
226  TestFixture self;
227 
228  // Calculate some marginals for DiscreteValues==all1
229  Vector marginals = Vector::Zero(15);
230  double joint_12_14 = 0, joint_9_12_14 = 0, joint_8_12_14 = 0, joint82 = 0,
231  joint12 = 0, joint24 = 0, joint45 = 0, joint46 = 0, joint_4_11 = 0;
232  for (size_t i = 0; i < self.assignments.size(); ++i) {
233  DiscreteValues& x = self.assignments[i];
234  double px = self.bayesTree->evaluate(x);
235  for (size_t i = 0; i < 15; i++)
236  if (x[i]) marginals[i] += px;
237  if (x[12] && x[14]) {
238  joint_12_14 += px;
239  if (x[9]) joint_9_12_14 += px;
240  if (x[8]) joint_8_12_14 += px;
241  }
242  if (x[2]) {
243  if (x[8]) joint82 += px;
244  if (x[1]) joint12 += px;
245  }
246  if (x[4]) {
247  if (x[2]) joint24 += px;
248  if (x[5]) joint45 += px;
249  if (x[6]) joint46 += px;
250  if (x[11]) joint_4_11 += px;
251  }
252  }
253 
254  // regression tests:
255  DOUBLES_EQUAL(joint_12_14, 0.1875, 1e-9);
256  DOUBLES_EQUAL(joint_8_12_14, 0.0375, 1e-9);
257  DOUBLES_EQUAL(joint_9_12_14, 0.15, 1e-9);
258 
259  DiscreteValues all1 = self.assignments.back();
260  DiscreteBayesNet::shared_ptr actualJoint;
261 
262  // Check joint P(8, 2)
263  actualJoint = self.bayesTree->jointBayesNet(8, 2, EliminateDiscrete);
264  DOUBLES_EQUAL(joint82, actualJoint->evaluate(all1), 1e-9);
265 
266  // Check joint P(1, 2)
267  actualJoint = self.bayesTree->jointBayesNet(1, 2, EliminateDiscrete);
268  DOUBLES_EQUAL(joint12, actualJoint->evaluate(all1), 1e-9);
269 
270  // Check joint P(2, 4)
271  actualJoint = self.bayesTree->jointBayesNet(2, 4, EliminateDiscrete);
272  DOUBLES_EQUAL(joint24, actualJoint->evaluate(all1), 1e-9);
273 
274  // Check joint P(4, 5)
275  actualJoint = self.bayesTree->jointBayesNet(4, 5, EliminateDiscrete);
276  DOUBLES_EQUAL(joint45, actualJoint->evaluate(all1), 1e-9);
277 
278  // Check joint P(4, 6)
279  actualJoint = self.bayesTree->jointBayesNet(4, 6, EliminateDiscrete);
280  DOUBLES_EQUAL(joint46, actualJoint->evaluate(all1), 1e-9);
281 
282  // Check joint P(4, 11)
283  actualJoint = self.bayesTree->jointBayesNet(4, 11, EliminateDiscrete);
284  DOUBLES_EQUAL(joint_4_11, actualJoint->evaluate(all1), 1e-9);
285 }
286 
287 /* ************************************************************************* */
289  TestFixture self;
290  std::string actual = self.bayesTree->dot();
291  // print actual:
292  if (debug) std::cout << actual << std::endl;
293  EXPECT(actual ==
294  "digraph G{\n"
295  "0[label=\"13, 11, 6, 7\"];\n"
296  "0->1\n"
297  "1[label=\"14 : 11, 13\"];\n"
298  "1->2\n"
299  "2[label=\"9, 12 : 14\"];\n"
300  "2->3\n"
301  "3[label=\"3 : 9, 12\"];\n"
302  "2->4\n"
303  "4[label=\"2 : 9, 12\"];\n"
304  "2->5\n"
305  "5[label=\"8 : 12, 14\"];\n"
306  "5->6\n"
307  "6[label=\"1 : 8, 12\"];\n"
308  "5->7\n"
309  "7[label=\"0 : 8, 12\"];\n"
310  "1->8\n"
311  "8[label=\"10 : 13, 14\"];\n"
312  "8->9\n"
313  "9[label=\"5 : 10, 13\"];\n"
314  "8->10\n"
315  "10[label=\"4 : 10, 13\"];\n"
316  "}");
317 }
318 
319 /* ************************************************************************* */
320 // Check that we can have a multi-frontal lookup table
324 
325  // Make a small planning-like graph: 3 states, 2 actions
327  const DiscreteKey x1{X(1), 3}, x2{X(2), 3}, x3{X(3), 3};
328  const DiscreteKey a1{A(1), 2}, a2{A(2), 2};
329 
330  // Constraint on start and goal
331  graph.add(DiscreteKeys{x1}, std::vector<double>{1, 0, 0});
332  graph.add(DiscreteKeys{x3}, std::vector<double>{0, 0, 1});
333 
334  // Should I stay or should I go?
335  // "Reward" (exp(-cost)) for an action is 10, and rewards multiply:
336  const double r = 10;
337  std::vector<double> table{
338  r, 0, 0, 0, r, 0, // x1 = 0
339  0, r, 0, 0, 0, r, // x1 = 1
340  0, 0, r, 0, 0, r // x1 = 2
341  };
344 
345  // eliminate for MPE (maximum probable explanation).
346  Ordering ordering{A(2), X(3), X(1), A(1), X(2)};
347  auto lookup = graph.eliminateMultifrontal(ordering, EliminateForMPE);
348 
349  // Check that the lookup table is correct
350  EXPECT_LONGS_EQUAL(2, lookup->size());
351  auto lookup_x1_a1_x2 = (*lookup)[X(1)]->conditional();
352  EXPECT_LONGS_EQUAL(3, lookup_x1_a1_x2->frontals().size());
353  // check that sum is 1.0 (not 100, as we now normalize)
355  EXPECT_DOUBLES_EQUAL(1.0, (*lookup_x1_a1_x2->sum(3))(empty), 1e-9);
356  // And that only non-zero reward is for x1 a1 x2 == 0 1 1
357  EXPECT_DOUBLES_EQUAL(1.0, (*lookup_x1_a1_x2)({{X(1),0},{A(1),1},{X(2),1}}), 1e-9);
358 
359  auto lookup_a2_x3 = (*lookup)[X(3)]->conditional();
360  // check that the sum depends on x2 and is non-zero only for x2 \in {1,2}
361  auto sum_x2 = lookup_a2_x3->sum(2);
362  EXPECT_DOUBLES_EQUAL(0, (*sum_x2)({{X(2),0}}), 1e-9);
363  EXPECT_DOUBLES_EQUAL(1.0, (*sum_x2)({{X(2),1}}), 1e-9);
364  EXPECT_DOUBLES_EQUAL(2.0, (*sum_x2)({{X(2),2}}), 1e-9);
365  EXPECT_LONGS_EQUAL(2, lookup_a2_x3->frontals().size());
366  // And that the non-zero rewards are for
367  // x2 a2 x3 == 1 1 2
368  EXPECT_DOUBLES_EQUAL(1.0, (*lookup_a2_x3)({{X(2),1},{A(2),1},{X(3),2}}), 1e-9);
369  // x2 a2 x3 == 2 0 2
370  EXPECT_DOUBLES_EQUAL(1.0, (*lookup_a2_x3)({{X(2),2},{A(2),0},{X(3),2}}), 1e-9);
371  // x2 a2 x3 == 2 1 2
372  EXPECT_DOUBLES_EQUAL(1.0, (*lookup_a2_x3)({{X(2),2},{A(2),1},{X(3),2}}), 1e-9);
373 }
374 
375 /* ************************************************************************* */
376 // Test creating a Bayes tree directly from cliques
377 TEST(DiscreteBayesTree, DirectFromCliques) {
378  // Create a BayesNet
380  DiscreteKey A(0, 2), B(1, 2), C(2, 2);
381  bayesNet.add(A % "1/3");
382  bayesNet.add(B | A = "1/3 3/1");
383  bayesNet.add(C | B = "3/1 3/1");
384 
385  // Create cliques directly
386  auto clique2 = std::make_shared<DiscreteBayesTree::Clique>(
387  std::make_shared<DiscreteConditional>(C | B = "3/1 3/1"));
388  auto clique1 = std::make_shared<DiscreteBayesTree::Clique>(
389  std::make_shared<DiscreteConditional>(B | A = "1/3 3/1"));
390  auto clique0 = std::make_shared<DiscreteBayesTree::Clique>(
391  std::make_shared<DiscreteConditional>(A % "1/3"));
392 
393  // Create a BayesTree
395  bayesTree.insertRoot(clique2);
396  bayesTree.addClique(clique1, clique2);
397  bayesTree.addClique(clique0, clique1);
398 
399  // Check that the BayesTree is correct
401  values[A.first] = 1;
402  values[B.first] = 1;
403  values[C.first] = 1;
404 
405  // Regression
406  double expected = .046875;
408 }
409 
410 /* ************************************************************************* */
411 int main() {
412  TestResult tr;
413  return TestRegistry::runAllTests(tr);
414 }
415 /* ************************************************************************* */
TestRegistry::runAllTests
static int runAllTests(TestResult &result)
Definition: TestRegistry.cpp:27
gtsam::EliminateDiscrete
std::pair< DiscreteConditional::shared_ptr, DiscreteFactor::shared_ptr > EliminateDiscrete(const DiscreteFactorGraph &factors, const Ordering &frontalKeys)
Main elimination function for DiscreteFactorGraph.
Definition: DiscreteFactorGraph.cpp:202
gtsam::EliminateForMPE
std::pair< DiscreteConditional::shared_ptr, DiscreteFactor::shared_ptr > EliminateForMPE(const DiscreteFactorGraph &factors, const Ordering &frontalKeys)
Alternate elimination function for that creates non-normalized lookup tables.
Definition: DiscreteFactorGraph.cpp:124
DiscreteBayesNet.h
gtsam::BayesTree::insertRoot
void insertRoot(const sharedClique &subtree)
Definition: BayesTree-inst.h:300
B
Matrix< SCALARB, Dynamic, Dynamic, opt_B > B
Definition: bench_gemm.cpp:49
asia::bayesNet
static const DiscreteBayesNet bayesNet
Definition: testDiscreteSearch.cpp:30
gtsam::DiscreteFactorGraph
Definition: DiscreteFactorGraph.h:99
main
int main()
Definition: testDiscreteBayesTree.cpp:411
Vector.h
typedef and functions to augment Eigen's VectorXd
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
gtsam::BayesNet::print
void print(const std::string &s="BayesNet", const KeyFormatter &formatter=DefaultKeyFormatter) const override
Definition: BayesNet-inst.h:31
EXPECT_LONGS_EQUAL
#define EXPECT_LONGS_EQUAL(expected, actual)
Definition: Test.h:154
EXPECT
#define EXPECT(condition)
Definition: Test.h:150
TestHarness.h
keys
const KeyVector keys
Definition: testRegularImplicitSchurFactor.cpp:40
DiscreteFactorGraph.h
TestFixture::TestFixture
TestFixture()
Definition: testDiscreteBayesTree.cpp:44
x
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition: gnuplot_common_settings.hh:12
asia::bayesTree
static const DiscreteBayesTree bayesTree
Definition: testDiscreteSearch.cpp:40
gtsam::BayesTree< DiscreteBayesTreeClique >::Nodes
ConcurrentMap< Key, sharedClique > Nodes
Definition: BayesTree.h:92
gtsam::symbol_shorthand::A
Key A(std::uint64_t j)
Definition: inference/Symbol.h:148
different_sigmas::values
HybridValues values
Definition: testHybridBayesNet.cpp:247
X
#define X
Definition: icosphere.cpp:20
gtsam::DiscreteKeys
DiscreteKeys is a set of keys that can be assembled using the & operator.
Definition: DiscreteKey.h:41
gtsam::Vector
Eigen::VectorXd Vector
Definition: Vector.h:39
gtsam::BayesTree::addClique
void addClique(const sharedClique &clique, const sharedClique &parent_clique=sharedClique())
Definition: BayesTree-inst.h:144
x3
Pose3 x3(Rot3::Ypr(M_PI/4.0, 0.0, 0.0), l2)
gtsam::EliminateableFactorGraph::eliminateMultifrontal
std::shared_ptr< BayesTreeType > eliminateMultifrontal(OptionalOrderingType orderingType={}, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
Definition: EliminateableFactorGraph-inst.h:89
A
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:48
TestFixture::bayesTree
std::shared_ptr< DiscreteBayesTree > bayesTree
Definition: testDiscreteBayesTree.cpp:38
align_3::a1
Point2 a1
Definition: testPose2.cpp:769
gtsam::symbol_shorthand::X
Key X(std::uint64_t j)
Definition: inference/Symbol.h:171
table
ArrayXXf table(10, 4)
gtsam::DiscreteBayesNet
Definition: DiscreteBayesNet.h:38
gtsam::DiscreteValues::CartesianProduct
static std::vector< DiscreteValues > CartesianProduct(const DiscreteKeys &keys)
Return a vector of DiscreteValues, one for each possible combination of values.
Definition: DiscreteValues.h:148
x1
Pose3 x1
Definition: testPose3.cpp:663
DOUBLES_EQUAL
#define DOUBLES_EQUAL(expected, actual, threshold)
Definition: Test.h:141
debug
static constexpr bool debug
Definition: testDiscreteBayesTree.cpp:31
gtsam::DiscreteBayesNet::evaluate
double evaluate(const DiscreteValues &values) const
Definition: DiscreteBayesNet.cpp:44
cholesky::expected
Matrix expected
Definition: testMatrix.cpp:971
TestFixture::bayesNet
DiscreteBayesNet bayesNet
Definition: testDiscreteBayesTree.cpp:37
Symbol.h
GTSAM_PRINT
#define GTSAM_PRINT(x)
Definition: Testable.h:43
BayesNet.h
Bayes network.
DiscreteBayesTree.h
Discrete Bayes Tree, the result of eliminating a DiscreteJunctionTree.
EXPECT_DOUBLES_EQUAL
#define EXPECT_DOUBLES_EQUAL(expected, actual, threshold)
Definition: Test.h:161
ordering
static enum @1096 ordering
TestResult
Definition: TestResult.h:26
gtsam::FactorGraph::size
size_t size() const
Definition: FactorGraph.h:297
gtsam::DiscreteBayesNet::add
void add(const DiscreteKey &key, const std::string &spec)
Definition: DiscreteBayesNet.h:85
empty
Definition: test_copy_move.cpp:19
C
Matrix< Scalar, Dynamic, Dynamic > C
Definition: bench_gemm.cpp:50
gtsam
traits
Definition: SFMdata.h:40
gtsam::TEST
TEST(SmartFactorBase, Pinhole)
Definition: testSmartFactorBase.cpp:38
gtsam::DiscreteValues
Definition: DiscreteValues.h:34
align_3::a2
Point2 a2
Definition: testPose2.cpp:770
gtsam::DiscreteKey
std::pair< Key, size_t > DiscreteKey
Definition: DiscreteKey.h:38
gtsam::DiscreteBayesNet::shared_ptr
std::shared_ptr< This > shared_ptr
Definition: DiscreteBayesNet.h:43
TestFixture::assignments
std::vector< DiscreteValues > assignments
Definition: testDiscreteBayesTree.cpp:36
gtsam::DiscreteBayesTree
A Bayes tree representing a Discrete distribution.
Definition: DiscreteBayesTree.h:73
TestFixture
Definition: testDiscreteBayesTree.cpp:34
gtsam::FactorGraph::add
IsDerived< DERIVEDFACTOR > add(std::shared_ptr< DERIVEDFACTOR > factor)
add is a synonym for push_back.
Definition: FactorGraph.h:171
graph
NonlinearFactorGraph graph
Definition: doc/Code/OdometryExample.cpp:2
marginals
Marginals marginals(graph, result)
gtsam::Ordering
Definition: inference/Ordering.h:33
x2
Pose3 x2(Rot3::Ypr(0.0, 0.0, 0.0), l2)
LONGS_EQUAL
#define LONGS_EQUAL(expected, actual)
Definition: Test.h:134
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
TestFixture::keys
DiscreteKeys keys
Definition: testDiscreteBayesTree.cpp:35
R
Rot2 R(Rot2::fromAngle(0.1))
gtsam::DiscreteBayesTree::evaluate
double evaluate(const DiscreteValues &values) const
Definition: DiscreteBayesTree.cpp:49
px
RealScalar RealScalar * px
Definition: level1_cplx_impl.h:28


gtsam
Author(s):
autogenerated on Sun Feb 16 2025 04:06:11