testHybridBayesTree.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 
24 
25 #include <numeric>
26 
27 #include "Switching.h"
28 
29 // Include for test suite
31 
32 using namespace std;
33 using namespace gtsam;
38 
39 static const DiscreteKey m0(M(0), 2), m1(M(1), 2), m2(M(2), 2), m3(M(3), 2);
40 
41 /* ************************************************************************* */
42 TEST(HybridGaussianFactorGraph, EliminateMultifrontal) {
43  // Test multifrontal elimination
45 
46  // Add priors on x0 and c1
47  hfg.add(JacobianFactor(X(0), I_3x3, Z_3x1));
48  hfg.add(DecisionTreeFactor(m1, {2, 8}));
49 
51  ordering.push_back(X(0));
53 
54  EXPECT_LONGS_EQUAL(result.first->size(), 1);
55  EXPECT_LONGS_EQUAL(result.second->size(), 1);
56 }
57 
58 /* ************************************************************************* */
59 namespace two {
60 std::vector<GaussianFactor::shared_ptr> components(Key key) {
61  return {std::make_shared<JacobianFactor>(key, I_3x3, Z_3x1),
62  std::make_shared<JacobianFactor>(key, I_3x3, Vector3::Ones())};
63 }
64 } // namespace two
65 
66 /* ************************************************************************* */
68  HybridGaussianFactorGraphEliminateFullMultifrontalSimple) {
70 
71  hfg.add(JacobianFactor(X(0), I_3x3, Z_3x1));
72  hfg.add(JacobianFactor(X(0), I_3x3, X(1), -I_3x3, Z_3x1));
73 
75 
76  hfg.add(DecisionTreeFactor(m1, {2, 8}));
77  hfg.add(DecisionTreeFactor({m1, m2}, "1 2 3 4"));
78 
80 
81  // The bayes tree should have 3 cliques
83 }
84 
85 /* ************************************************************************* */
86 TEST(HybridGaussianFactorGraph, eliminateFullMultifrontalCLG) {
88 
89  // Prior on x0
90  hfg.add(JacobianFactor(X(0), I_3x3, Z_3x1));
91  // Factor between x0-x1
92  hfg.add(JacobianFactor(X(0), I_3x3, X(1), -I_3x3, Z_3x1));
93 
94  // Hybrid factor P(x1|c1)
96  // Prior factor on c1
97  hfg.add(DecisionTreeFactor(m1, {2, 8}));
98 
99  // Get a constrained ordering keeping c1 last
100  auto ordering_full = HybridOrdering(hfg);
101 
102  // Returns a Hybrid Bayes Tree with distribution P(x0|x1)P(x1|c1)P(c1)
103  HybridBayesTree::shared_ptr hbt = hfg.eliminateMultifrontal(ordering_full);
104 
105  EXPECT_LONGS_EQUAL(3, hbt->size());
106 }
107 
108 /* ************************************************************************* */
109 // Check assembling the Bayes Tree roots after we do partial elimination
110 TEST(HybridGaussianFactorGraph, eliminateFullMultifrontalTwoClique) {
112 
113  hfg.add(JacobianFactor(X(0), I_3x3, X(1), -I_3x3, Z_3x1));
114  hfg.add(JacobianFactor(X(1), I_3x3, X(2), -I_3x3, Z_3x1));
115 
118 
119  hfg.add(DecisionTreeFactor({m1, m2}, "1 2 3 4"));
120 
121  hfg.add(JacobianFactor(X(3), I_3x3, X(4), -I_3x3, Z_3x1));
122  hfg.add(JacobianFactor(X(4), I_3x3, X(5), -I_3x3, Z_3x1));
123 
126 
127  auto ordering_full =
128  Ordering::ColamdConstrainedLast(hfg, {M(0), M(1), M(2), M(3)});
129 
130  const auto [hbt, remaining] = hfg.eliminatePartialMultifrontal(ordering_full);
131 
132  // 9 cliques in the bayes tree and 0 remaining variables to eliminate.
133  EXPECT_LONGS_EQUAL(9, hbt->size());
134  EXPECT_LONGS_EQUAL(0, remaining->size());
135 
136  /*
137  (Fan) Explanation: the Junction tree will need to re-eliminate to get to the
138  marginal on X(1), which is not possible because it involves eliminating
139  discrete before continuous. The solution to this, however, is in Murphy02.
140  TLDR is that this is 1. expensive and 2. inexact. nevertheless it is doable.
141  And I believe that we should do this.
142  */
143 }
144 
145 /* ************************************************************************* */
147  const HybridBayesTree::shared_ptr& hbt,
148  const Ordering& ordering) {
149  DotWriter dw;
150  dw.positionHints['c'] = 2;
151  dw.positionHints['x'] = 1;
152  std::cout << hfg->dot(DefaultKeyFormatter, dw);
153  std::cout << "\n";
154  hbt->dot(std::cout);
155 
156  std::cout << "\n";
157  std::cout << hfg->eliminateSequential(ordering)->dot(DefaultKeyFormatter, dw);
158 }
159 
160 /* ************************************************************************* */
161 // TODO(fan): make a graph like Varun's paper one
163  auto N = 12;
164  auto hfg = makeSwitchingChain(N);
165 
166  // X(5) will be the center, X(1-4), X(6-9)
167  // X(3), X(7)
168  // X(2), X(8)
169  // X(1), X(4), X(6), X(9)
170  // M(5) will be the center, M(1-4), M(6-8)
171  // M(3), M(7)
172  // M(1), M(4), M(2), M(6), M(8)
173  // auto ordering_full =
174  // Ordering(KeyVector{X(1), X(4), X(2), X(6), X(9), X(8), X(3), X(7),
175  // X(5),
176  // M(1), M(4), M(2), M(6), M(8), M(3), M(7), M(5)});
178 
179  {
180  std::vector<int> naturalX(N);
181  std::iota(naturalX.begin(), naturalX.end(), 1);
182  std::vector<Key> ordX;
183  std::transform(naturalX.begin(), naturalX.end(), std::back_inserter(ordX),
184  [](int x) { return X(x); });
185 
186  auto [ndX, lvls] = makeBinaryOrdering(ordX);
187  std::copy(ndX.begin(), ndX.end(), std::back_inserter(ordering));
188  }
189  {
190  std::vector<int> naturalC(N - 1);
191  std::iota(naturalC.begin(), naturalC.end(), 1);
192  std::vector<Key> ordC;
193  std::transform(naturalC.begin(), naturalC.end(), std::back_inserter(ordC),
194  [](int x) { return M(x); });
195 
196  const auto [ndC, lvls] = makeBinaryOrdering(ordC);
197  std::copy(ndC.begin(), ndC.end(), std::back_inserter(ordering));
198  }
199 
200  const auto [hbt, remaining] = hfg->eliminatePartialMultifrontal(ordering);
201 
202  // 12 cliques in the bayes tree and 0 remaining variables to eliminate.
203  EXPECT_LONGS_EQUAL(12, hbt->size());
204  EXPECT_LONGS_EQUAL(0, remaining->size());
205 }
206 
207 /* ************************************************************************* */
208 // TODO(fan): make a graph like Varun's paper one
210  auto N = 11;
211  auto hfg = makeSwitchingChain(N);
212 
213  // X(5) will be the center, X(1-4), X(6-9)
214  // X(3), X(7)
215  // X(2), X(8)
216  // X(1), X(4), X(6), X(9)
217  // M(5) will be the center, M(1-4), M(6-8)
218  // M(3), M(7)
219  // M(1), M(4), M(2), M(6), M(8)
220  // auto ordering_full =
221  // Ordering(KeyVector{X(1), X(4), X(2), X(6), X(9), X(8), X(3), X(7),
222  // X(5),
223  // M(1), M(4), M(2), M(6), M(8), M(3), M(7), M(5)});
225 
226  {
227  std::vector<int> naturalX(N);
228  std::iota(naturalX.begin(), naturalX.end(), 1);
229  std::vector<Key> ordX;
230  std::transform(naturalX.begin(), naturalX.end(), std::back_inserter(ordX),
231  [](int x) { return X(x); });
232 
233  auto [ndX, lvls] = makeBinaryOrdering(ordX);
234  std::copy(ndX.begin(), ndX.end(), std::back_inserter(ordering));
235  }
236  {
237  std::vector<int> naturalC(N - 1);
238  std::iota(naturalC.begin(), naturalC.end(), 1);
239  std::vector<Key> ordC;
240  std::transform(naturalC.begin(), naturalC.end(), std::back_inserter(ordC),
241  [](int x) { return M(x); });
242 
243  // std::copy(ordC.begin(), ordC.end(), std::back_inserter(ordering));
244  const auto [ndC, lvls] = makeBinaryOrdering(ordC);
245  std::copy(ndC.begin(), ndC.end(), std::back_inserter(ordering));
246  }
247 
248  const auto [hbt, remaining] = hfg->eliminatePartialMultifrontal(ordering);
249 
250  auto new_fg = makeSwitchingChain(12);
251  auto isam = HybridGaussianISAM(*hbt);
252 
253  // Run an ISAM update.
254  HybridGaussianFactorGraph factorGraph;
255  factorGraph.push_back(new_fg->at(new_fg->size() - 2));
256  factorGraph.push_back(new_fg->at(new_fg->size() - 1));
257  isam.update(factorGraph);
258 
259  // ISAM should have 12 factors after the last update
260  EXPECT_LONGS_EQUAL(12, isam.size());
261 }
262 
263 /* ************************************************************************* */
264 TEST(HybridGaussianFactorGraph, SwitchingTwoVar) {
265  const int N = 7;
266  auto hfg = makeSwitchingChain(N, X);
267  hfg->push_back(*makeSwitchingChain(N, Y, D));
268 
269  for (int t = 1; t <= N; t++) {
270  hfg->add(JacobianFactor(X(t), I_3x3, Y(t), -I_3x3, Vector3(1.0, 0.0, 0.0)));
271  }
272 
274 
275  KeyVector naturalX(N);
276  std::iota(naturalX.begin(), naturalX.end(), 1);
277  KeyVector ordX;
278  for (size_t i = 1; i <= N; i++) {
279  ordX.emplace_back(X(i));
280  ordX.emplace_back(Y(i));
281  }
282 
283  for (size_t i = 1; i <= N - 1; i++) {
284  ordX.emplace_back(M(i));
285  }
286  for (size_t i = 1; i <= N - 1; i++) {
287  ordX.emplace_back(D(i));
288  }
289 
290  {
291  DotWriter dw;
292  dw.positionHints['x'] = 1;
293  dw.positionHints['c'] = 0;
294  dw.positionHints['d'] = 3;
295  dw.positionHints['y'] = 2;
296  // std::cout << hfg->dot(DefaultKeyFormatter, dw);
297  // std::cout << "\n";
298  }
299 
300  {
301  DotWriter dw;
302  dw.positionHints['y'] = 9;
303  // dw.positionHints['c'] = 0;
304  // dw.positionHints['d'] = 3;
305  dw.positionHints['x'] = 1;
306  // std::cout << "\n";
307  // std::cout << hfg->eliminateSequential(Ordering(ordX))
308  // ->dot(DefaultKeyFormatter, dw);
309  // hfg->eliminateMultifrontal(Ordering(ordX))->dot(std::cout);
310  }
311 
312  Ordering ordering_partial;
313  for (size_t i = 1; i <= N; i++) {
314  ordering_partial.emplace_back(X(i));
315  ordering_partial.emplace_back(Y(i));
316  }
317  const auto [hbn, remaining] =
318  hfg->eliminatePartialSequential(ordering_partial);
319 
320  EXPECT_LONGS_EQUAL(14, hbn->size());
321  EXPECT_LONGS_EQUAL(11, remaining->size());
322 
323  {
324  DotWriter dw;
325  dw.positionHints['x'] = 1;
326  dw.positionHints['c'] = 0;
327  dw.positionHints['d'] = 3;
328  dw.positionHints['y'] = 2;
329  // std::cout << remaining->dot(DefaultKeyFormatter, dw);
330  // std::cout << "\n";
331  }
332 }
333 
334 /* ****************************************************************************/
335 // Test multifrontal optimize
336 TEST(HybridBayesTree, OptimizeMultifrontal) {
337  Switching s(4);
338 
339  HybridBayesTree::shared_ptr hybridBayesTree =
340  s.linearizedFactorGraph().eliminateMultifrontal();
341  HybridValues delta = hybridBayesTree->optimize();
342 
343  VectorValues expectedValues;
344  expectedValues.insert(X(0), -0.999904 * Vector1::Ones());
345  expectedValues.insert(X(1), -0.99029 * Vector1::Ones());
346  expectedValues.insert(X(2), -1.00971 * Vector1::Ones());
347  expectedValues.insert(X(3), -1.0001 * Vector1::Ones());
348 
349  EXPECT(assert_equal(expectedValues, delta.continuous(), 1e-5));
350 }
351 
352 namespace optimize_fixture {
354  Switching s(N);
356 
357  for (size_t i = 0; i < N - 1; i++) {
358  graph.push_back(s.linearBinaryFactors.at(i));
359  }
360  for (size_t i = 0; i < N; i++) {
361  graph.push_back(s.linearUnaryFactors.at(i));
362  }
363  for (size_t i = 0; i < N - 1; i++) {
364  graph.push_back(s.modeChain.at(i));
365  }
366 
367  return graph;
368 }
369 } // namespace optimize_fixture
370 
371 /* ****************************************************************************/
372 // Test for optimizing a HybridBayesTree with a given assignment.
373 TEST(HybridBayesTree, OptimizeAssignment) {
374  using namespace optimize_fixture;
375 
376  size_t N = 4;
377 
379 
380  // Add the 3 hybrid factors, x0-x1, x1-x2, x2-x3
381  // Then add the Gaussian factors, 1 prior on X(0),
382  // 3 measurements on X(1), X(2), X(3)
383  // Finally add the discrete factors
384  // m0, m1-m0, m2-m1
386 
387  isam.update(graph1);
388 
389  DiscreteValues assignment;
390  assignment[M(0)] = 1;
391  assignment[M(1)] = 1;
392  assignment[M(2)] = 1;
393 
394  VectorValues delta = isam.optimize(assignment);
395 
396  // The linearization point has the same value as the key index,
397  // e.g. X(1) = 1, X(2) = 2,
398  // but the factors specify X(k) = k-1, so delta should be -1.
399  VectorValues expected_delta;
400  expected_delta.insert(make_pair(X(0), -Vector1::Ones()));
401  expected_delta.insert(make_pair(X(1), -Vector1::Ones()));
402  expected_delta.insert(make_pair(X(2), -Vector1::Ones()));
403  expected_delta.insert(make_pair(X(3), -Vector1::Ones()));
404 
405  EXPECT(assert_equal(expected_delta, delta));
406 
407  Switching s(N);
408  // Create ordering.
410  for (size_t k = 0; k < s.K; k++) ordering.push_back(X(k));
411 
412  const auto [hybridBayesNet, remainingFactorGraph] =
413  s.linearizedFactorGraph().eliminatePartialSequential(ordering);
414 
415  GaussianBayesNet gbn = hybridBayesNet->choose(assignment);
417 
419 }
420 
421 /* ****************************************************************************/
422 // Test for optimizing a HybridBayesTree.
423 TEST(HybridBayesTree, Optimize) {
424  using namespace optimize_fixture;
425 
426  size_t N = 4;
427 
429  // Add the 3 hybrid factors, x0-x1, x1-x2, x2-x3
430  // Then add the Gaussian factors, 1 prior on X(0),
431  // 3 measurements on X(1), X(2), X(3)
432  // Finally add the discrete factors
433  // m0, m1-m0, m2-m1
435 
436  isam.update(graph1);
437 
438  HybridValues delta = isam.optimize();
439 
440  Switching s(N);
441  // Create ordering.
443  for (size_t k = 0; k < s.K; k++) ordering.push_back(X(k));
444 
445  const auto [hybridBayesNet, remainingFactorGraph] =
446  s.linearizedFactorGraph().eliminatePartialSequential(ordering);
447 
448  DiscreteFactorGraph dfg = remainingFactorGraph->discreteFactors();
449 
450  // Add the probabilities for each branch
451  DiscreteKeys discrete_keys = {{M(0), 2}, {M(1), 2}, {M(2), 2}};
452  vector<double> probs = {0.012519475, 0.041280228, 0.075018647, 0.081663656,
453  0.037152205, 0.12248971, 0.07349729, 0.08};
454  dfg.emplace_shared<DecisionTreeFactor>(discrete_keys, probs);
455 
456  DiscreteValues expectedMPE = dfg.optimize();
457  VectorValues expectedValues = hybridBayesNet->optimize(expectedMPE);
458 
459  EXPECT(assert_equal(expectedMPE, delta.discrete()));
460  EXPECT(assert_equal(expectedValues, delta.continuous()));
461 }
462 
463 /* ****************************************************************************/
464 // Test for choosing a GaussianBayesTree from a HybridBayesTree.
466  using namespace optimize_fixture;
467 
468  size_t N = 4;
469 
471 
472  // Add the 3 hybrid factors, x0-x1, x1-x2, x2-x3
473  // Then add the Gaussian factors, 1 prior on X(0),
474  // 3 measurements on X(1), X(2), X(3)
475  // Finally add the discrete factors
476  // m0, m1-m0, m2-m1
478 
479  isam.update(graph1);
480 
481  DiscreteValues assignment;
482  assignment[M(0)] = 1;
483  assignment[M(1)] = 1;
484  assignment[M(2)] = 1;
485 
486  GaussianBayesTree gbt = isam.choose(assignment);
487 
488  // Specify ordering so it matches that of HybridGaussianISAM.
489  Switching s(N);
490  Ordering ordering(KeyVector{X(0), X(1), X(2), X(3), M(0), M(1), M(2)});
491  auto bayesTree = s.linearizedFactorGraph().eliminateMultifrontal(ordering);
492 
493  auto expected_gbt = bayesTree->choose(assignment);
494 
495  EXPECT(assert_equal(expected_gbt, gbt));
496 }
497 
498 /* ************************************************************************* */
499 int main() {
500  TestResult tr;
501  return TestRegistry::runAllTests(tr);
502 }
503 /* ************************************************************************* */
gtsam::EliminateableFactorGraph::eliminatePartialMultifrontal
std::pair< std::shared_ptr< BayesTreeType >, std::shared_ptr< FactorGraphType > > eliminatePartialMultifrontal(const Ordering &ordering, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
Definition: EliminateableFactorGraph-inst.h:190
TestRegistry::runAllTests
static int runAllTests(TestResult &result)
Definition: TestRegistry.cpp:27
dotPrint
void dotPrint(const HybridGaussianFactorGraph::shared_ptr &hfg, const HybridBayesTree::shared_ptr &hbt, const Ordering &ordering)
Definition: testHybridBayesTree.cpp:146
gtsam::HybridGaussianFactorGraph::shared_ptr
std::shared_ptr< This > shared_ptr
shared_ptr to This
Definition: HybridGaussianFactorGraph.h:120
DotWriter.h
Graphviz formatter.
gtsam::HybridGaussianISAM
Incremental Smoothing and Mapping (ISAM) algorithm for hybrid factor graphs.
Definition: HybridGaussianISAM.h:37
gtsam::DotWriter::positionHints
std::map< char, double > positionHints
Definition: DotWriter.h:55
gtsam::DecisionTreeFactor
Definition: DecisionTreeFactor.h:44
gtsam::HybridValues
Definition: HybridValues.h:37
D
MatrixXcd D
Definition: EigenSolver_EigenSolver_MatrixType.cpp:14
gtsam::DiscreteFactorGraph
Definition: DiscreteFactorGraph.h:98
gtsam::Values::size
size_t size() const
Definition: Values.h:178
s
RealScalar s
Definition: level1_cplx_impl.h:126
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
EXPECT_LONGS_EQUAL
#define EXPECT_LONGS_EQUAL(expected, actual)
Definition: Test.h:154
EXPECT
#define EXPECT(condition)
Definition: Test.h:150
gtsam::Z_3x1
static const Eigen::MatrixBase< Vector3 >::ConstantReturnType Z_3x1
Definition: Vector.h:46
TestHarness.h
DiscreteFactorGraph.h
gtsam::VectorValues::insert
iterator insert(const std::pair< Key, Vector > &key_value)
Definition: VectorValues.cpp:90
gtsam::Y
GaussianFactorGraphValuePair Y
Definition: HybridGaussianProductFactor.cpp:29
m1
static const DiscreteKey m1(M(1), 2)
Switching.h
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
gtsam::JacobianFactor
Definition: JacobianFactor.h:91
gtsam::HybridBayesTree
Definition: HybridBayesTree.h:62
gtsam::makeBinaryOrdering
std::pair< KeyVector, std::vector< int > > makeBinaryOrdering(std::vector< Key > &input)
Return the ordering as a binary tree such that all parent nodes are above their children.
Definition: Switching.h:89
m2
static const DiscreteKey m2(M(2), 2)
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
m0
static const DiscreteKey m0(M(0), 2)
gtsam::Vector3
Eigen::Vector3d Vector3
Definition: Vector.h:43
gtsam::KeyVector
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition: Key.h:92
result
Values result
Definition: OdometryOptimize.cpp:8
TEST
TEST(HybridGaussianFactorGraph, EliminateMultifrontal)
Definition: testHybridBayesTree.cpp:42
gtsam::NonlinearISAM::update
void update(const NonlinearFactorGraph &newFactors, const Values &initialValues)
Definition: NonlinearISAM.cpp:35
gtsam::EliminateableFactorGraph::eliminateMultifrontal
std::shared_ptr< BayesTreeType > eliminateMultifrontal(OptionalOrderingType orderingType={}, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
Definition: EliminateableFactorGraph-inst.h:89
gtsam::DefaultKeyFormatter
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition: Key.cpp:30
gtsam::Switching
ϕ(X(0)) .. ϕ(X(k),X(k+1)) .. ϕ(X(k);z_k) .. ϕ(M(0)) .. ϕ(M(K-3),M(K-2))
Definition: Switching.h:124
gtsam.examples.PlanarManipulatorExample.delta
def delta(g0, g1)
Definition: PlanarManipulatorExample.py:45
gtsam::VectorValues
Definition: VectorValues.h:74
two::components
std::vector< GaussianFactor::shared_ptr > components(Key key)
Definition: testHybridBayesTree.cpp:60
optimize_fixture::GetGaussianFactorGraph
HybridGaussianFactorGraph GetGaussianFactorGraph(size_t N)
Definition: testHybridBayesTree.cpp:353
isam
NonlinearISAM isam(relinearizeInterval)
cholesky::expected
Matrix expected
Definition: testMatrix.cpp:971
HybridGaussianISAM.h
gtsam::GaussianBayesNet::optimize
VectorValues optimize() const
Definition: GaussianBayesNet.cpp:44
gtsam::HybridGaussianFactorGraph
Definition: HybridGaussianFactorGraph.h:106
HybridBayesTree.h
Hybrid Bayes Tree, the result of eliminating a HybridJunctionTree.
transform
EIGEN_DONT_INLINE void transform(const Transformation &t, Data &data)
Definition: geometry.cpp:25
gtsam::makeSwitchingChain
HybridGaussianFactorGraph::shared_ptr makeSwitchingChain(size_t K, std::function< Key(int)> x=X, std::function< Key(int)> m=M, const std::string &transitionProbabilityTable="0 1 1 3")
Create a switching system chain. A switching system is a continuous system which depends on a discret...
Definition: Switching.h:54
sampling::gbn
static const GaussianBayesNet gbn
Definition: testGaussianBayesNet.cpp:171
ordering
static enum @1096 ordering
serializationTestHelpers.h
optimize_fixture
Definition: testHybridBayesTree.cpp:352
TestResult
Definition: TestResult.h:26
key
const gtsam::Symbol key('X', 0)
m3
static const DiscreteKey m3(M(3), 2)
gtsam
traits
Definition: SFMdata.h:40
gtsam::GaussianBayesTree
Definition: GaussianBayesTree.h:49
gtsam::DiscreteValues
Definition: DiscreteValues.h:34
gtsam::FactorGraph::push_back
IsDerived< DERIVEDFACTOR > push_back(std::shared_ptr< DERIVEDFACTOR > factor)
Add a factor directly using a shared_ptr.
Definition: FactorGraph.h:147
gtsam::DiscreteKey
std::pair< Key, size_t > DiscreteKey
Definition: DiscreteKey.h:38
std
Definition: BFloat16.h:88
gtsam::HybridGaussianFactor
Implementation of a discrete-conditioned hybrid factor. Implements a joint discrete-continuous factor...
Definition: HybridGaussianFactor.h:60
switching3::graph1
const HybridGaussianFactorGraph graph1
Definition: testHybridGaussianISAM.cpp:50
gtsam::assert_equal
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
Definition: Matrix.cpp:40
gtsam::HybridOrdering
const Ordering HybridOrdering(const HybridGaussianFactorGraph &graph)
Return a Colamd constrained ordering where the discrete keys are eliminated after the continuous keys...
Definition: HybridGaussianFactorGraph.cpp:87
N
#define N
Definition: igam.h:9
gtsam::DiscreteFactorGraph::optimize
DiscreteValues optimize(OptionalOrderingType orderingType={}) const
Find the maximum probable explanation (MPE) by doing max-product.
Definition: DiscreteFactorGraph.cpp:189
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
align_3::t
Point2 t(10, 10)
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:97
two
Definition: testHybridBayesTree.cpp:59
gtsam::Ordering
Definition: inference/Ordering.h:33
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
gtsam::DotWriter
DotWriter is a helper class for writing graphviz .dot files.
Definition: DotWriter.h:36
main
int main()
Definition: testHybridBayesTree.cpp:499
gtsam::HybridBayesTree::shared_ptr
std::shared_ptr< This > shared_ptr
Definition: HybridBayesTree.h:68
gtsam::GaussianBayesNet
Definition: GaussianBayesNet.h:35
gtsam::FactorGraph::emplace_shared
IsDerived< DERIVEDFACTOR > emplace_shared(Args &&... args)
Emplace a shared pointer to factor of given type.
Definition: FactorGraph.h:153
M
Matrix< RealScalar, Dynamic, Dynamic > M
Definition: bench_gemm.cpp:51


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:07:38