testDiscreteConditional.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 
12 /*
13  * @file testDiscreteConditional.cpp
14  * @brief unit tests for DiscreteConditional
15  * @author Duy-Nguyen Ta
16  * @author Frank dellaert
17  * @date Feb 14, 2011
18  */
19 
24 #include <gtsam/inference/Symbol.h>
27 
28 
29 using namespace std;
30 using namespace gtsam;
31 
32 /* ************************************************************************* */
33 TEST(DiscreteConditional, constructors) {
34  DiscreteKey X(0, 2), Y(2, 3), Z(1, 2); // watch ordering !
35 
36  DiscreteConditional actual(X | Y = "1/1 2/3 1/4");
37  EXPECT_LONGS_EQUAL(0, *(actual.beginFrontals()));
38  EXPECT_LONGS_EQUAL(2, *(actual.beginParents()));
39  EXPECT(actual.endParents() == actual.end());
40  EXPECT(actual.endFrontals() == actual.beginParents());
41 
42  DecisionTreeFactor f1(X & Y, "0.5 0.4 0.2 0.5 0.6 0.8");
43  DiscreteConditional expected1(1, f1);
44  EXPECT(assert_equal(expected1, actual, 1e-9));
45 
47  X & Y & Z, "0.2 0.5 0.3 0.6 0.4 0.7 0.25 0.55 0.35 0.65 0.45 0.75");
48  DiscreteConditional actual2(1, f2);
49  DecisionTreeFactor expected2 = f2 / *f2.sum(1);
50  EXPECT(assert_equal(expected2, static_cast<DecisionTreeFactor>(actual2)));
51 
52  std::vector<double> probs{0.2, 0.5, 0.3, 0.6, 0.4, 0.7, 0.25, 0.55, 0.35, 0.65, 0.45, 0.75};
53  DiscreteConditional actual3(X, {Y, Z}, probs);
54  DecisionTreeFactor expected3 = f2;
55  EXPECT(assert_equal(expected3, static_cast<DecisionTreeFactor>(actual3)));
56 }
57 
58 /* ************************************************************************* */
59 TEST(DiscreteConditional, constructors_alt_interface) {
60  DiscreteKey X(0, 2), Y(2, 3), Z(1, 2); // watch ordering !
61 
62  const Signature::Row r1{1, 1}, r2{2, 3}, r3{1, 4};
63  const Signature::Table table{r1, r2, r3};
64  DiscreteConditional actual1(X, {Y}, table);
65 
66  DecisionTreeFactor f1(X & Y, "0.5 0.4 0.2 0.5 0.6 0.8");
67  DiscreteConditional expected1(1, f1);
68  EXPECT(assert_equal(expected1, actual1, 1e-9));
69 
71  X & Y & Z, "0.2 0.5 0.3 0.6 0.4 0.7 0.25 0.55 0.35 0.65 0.45 0.75");
72  DiscreteConditional actual2(1, f2);
73  DecisionTreeFactor expected2 = f2 / *f2.sum(1);
74  EXPECT(assert_equal(expected2, static_cast<DecisionTreeFactor>(actual2)));
75 }
76 
77 /* ************************************************************************* */
78 TEST(DiscreteConditional, constructors2) {
79  DiscreteKey C(0, 2), B(1, 2);
80  Signature signature((C | B) = "4/1 3/1");
81  DiscreteConditional actual(signature);
82 
83  DecisionTreeFactor expected(C & B, "0.8 0.75 0.2 0.25");
84  EXPECT(assert_equal(expected, static_cast<DecisionTreeFactor>(actual)));
85 }
86 
87 /* ************************************************************************* */
88 TEST(DiscreteConditional, constructors3) {
89  DiscreteKey C(0, 2), B(1, 2), A(2, 2);
90  Signature signature((C | B, A) = "4/1 1/1 1/1 1/4");
91  DiscreteConditional actual(signature);
92 
93  DecisionTreeFactor expected(C & B & A, "0.8 0.5 0.5 0.2 0.2 0.5 0.5 0.8");
94  EXPECT(assert_equal(expected, static_cast<DecisionTreeFactor>(actual)));
95 }
96 
97 /* ****************************************************************************/
98 // Test evaluate for a discrete Prior P(Asia).
99 TEST(DiscreteConditional, PriorProbability) {
100  constexpr Key asiaKey = 0;
101  const DiscreteKey Asia(asiaKey, 2);
102  DiscreteConditional dc(Asia, "4/6");
104  EXPECT_DOUBLES_EQUAL(0.4, dc.evaluate(values), 1e-9);
105  EXPECT(DiscreteConditional::CheckInvariants(dc, values));
106 }
107 
108 /* ************************************************************************* */
109 // Check that error, logProbability, evaluate all work as expected.
110 TEST(DiscreteConditional, probability) {
111  DiscreteKey C(2, 2), D(4, 2), E(3, 2);
112  DiscreteConditional C_given_DE((C | D, E) = "4/1 1/1 1/1 1/4");
113 
114  DiscreteValues given {{C.first, 1}, {D.first, 0}, {E.first, 0}};
115  EXPECT_DOUBLES_EQUAL(0.2, C_given_DE.evaluate(given), 1e-9);
116  EXPECT_DOUBLES_EQUAL(0.2, C_given_DE(given), 1e-9);
117  EXPECT_DOUBLES_EQUAL(log(0.2), C_given_DE.logProbability(given), 1e-9);
118  EXPECT_DOUBLES_EQUAL(-log(0.2), C_given_DE.error(given), 1e-9);
119  EXPECT(DiscreteConditional::CheckInvariants(C_given_DE, given));
120 }
121 
122 /* ************************************************************************* */
123 // Check calculation of joint P(A,B)
125  DiscreteKey A(1, 2), B(0, 2);
126  DiscreteConditional conditional(A | B = "1/2 2/1");
127  DiscreteConditional prior(B % "1/2");
128 
129  // The expected factor
130  DecisionTreeFactor f(A & B, "1 4 2 2");
132 
133  // P(A,B) = P(A|B) * P(B) = P(B) * P(A|B)
134  for (auto&& actual : {prior * conditional, conditional * prior}) {
135  EXPECT_LONGS_EQUAL(2, actual.nrFrontals());
136  KeyVector frontals(actual.beginFrontals(), actual.endFrontals());
137  EXPECT((frontals == KeyVector{0, 1}));
138  for (auto&& it : actual.enumerate()) {
139  const DiscreteValues& v = it.first;
140  EXPECT_DOUBLES_EQUAL(actual(v), conditional(v) * prior(v), 1e-9);
141  }
142  // And for good measure:
143  EXPECT(assert_equal(expected, actual));
144  }
145 }
146 
147 /* ************************************************************************* */
148 // Check calculation of conditional joint P(A,B|C)
150  DiscreteKey A(0, 2), B(1, 2), C(2, 2);
151  DiscreteConditional A_given_B(A | B = "1/3 3/1");
152  DiscreteConditional B_given_C(B | C = "1/3 3/1");
153 
154  // P(A,B|C) = P(A|B)P(B|C) = P(B|C)P(A|B)
155  for (auto&& actual : {A_given_B * B_given_C, B_given_C * A_given_B}) {
156  EXPECT_LONGS_EQUAL(2, actual.nrFrontals());
157  EXPECT_LONGS_EQUAL(1, actual.nrParents());
158  KeyVector frontals(actual.beginFrontals(), actual.endFrontals());
159  EXPECT((frontals == KeyVector{0, 1}));
160  for (auto&& it : actual.enumerate()) {
161  const DiscreteValues& v = it.first;
162  EXPECT_DOUBLES_EQUAL(actual(v), A_given_B(v) * B_given_C(v), 1e-9);
163  }
164  }
165 }
166 
167 /* ************************************************************************* */
168 // Check calculation of conditional joint P(A,B|C), double check keys
170  DiscreteKey A(1, 2), B(2, 2), C(0, 2); // different keys!!!
171  DiscreteConditional A_given_B(A | B = "1/3 3/1");
172  DiscreteConditional B_given_C(B | C = "1/3 3/1");
173 
174  // P(A,B|C) = P(A|B)P(B|C) = P(B|C)P(A|B)
175  for (auto&& actual : {A_given_B * B_given_C, B_given_C * A_given_B}) {
176  EXPECT_LONGS_EQUAL(2, actual.nrFrontals());
177  EXPECT_LONGS_EQUAL(1, actual.nrParents());
178  KeyVector frontals(actual.beginFrontals(), actual.endFrontals());
179  EXPECT((frontals == KeyVector{1, 2}));
180  for (auto&& it : actual.enumerate()) {
181  const DiscreteValues& v = it.first;
182  EXPECT_DOUBLES_EQUAL(actual(v), A_given_B(v) * B_given_C(v), 1e-9);
183  }
184  }
185 }
186 
187 /* ************************************************************************* */
188 // Check calculation of conditional joint P(A,B,C|D,E) = P(A,B|D) P(C|D,E)
190  DiscreteKey A(0, 2), B(1, 2), C(2, 2), D(4, 2), E(3, 2);
191  DiscreteConditional A_given_B(A | B = "1/3 3/1");
192  DiscreteConditional B_given_D(B | D = "1/3 3/1");
193  DiscreteConditional AB_given_D = A_given_B * B_given_D;
194  DiscreteConditional C_given_DE((C | D, E) = "4/1 1/1 1/1 1/4");
195 
196  // P(A,B,C|D,E) = P(A,B|D) P(C|D,E) = P(C|D,E) P(A,B|D)
197  for (auto&& actual : {AB_given_D * C_given_DE, C_given_DE * AB_given_D}) {
198  EXPECT_LONGS_EQUAL(3, actual.nrFrontals());
199  EXPECT_LONGS_EQUAL(2, actual.nrParents());
200  KeyVector frontals(actual.beginFrontals(), actual.endFrontals());
201  EXPECT((frontals == KeyVector{0, 1, 2}));
202  KeyVector parents(actual.beginParents(), actual.endParents());
203  EXPECT((parents == KeyVector{3, 4}));
204  for (auto&& it : actual.enumerate()) {
205  const DiscreteValues& v = it.first;
206  EXPECT_DOUBLES_EQUAL(actual(v), AB_given_D(v) * C_given_DE(v), 1e-9);
207  }
208  }
209 }
210 
211 /* ************************************************************************* */
212 // Check calculation of marginals for joint P(A,B)
214  DiscreteKey A(1, 2), B(0, 2);
215  DiscreteConditional conditional(A | B = "1/2 2/1");
216  DiscreteConditional prior(B % "1/2");
217  DiscreteConditional pAB = prior * conditional;
218 
219  // P(A=0) = P(A=0|B=0)P(B=0) + P(A=0|B=1)P(B=1) = 1*1 + 2*2 = 5
220  // P(A=1) = P(A=1|B=0)P(B=0) + P(A=1|B=1)P(B=1) = 2*1 + 1*2 = 4
221  DiscreteConditional actualA = pAB.marginal(A.first);
222  DiscreteConditional pA(A % "5/4");
223  EXPECT(assert_equal(pA, actualA));
224  EXPECT(actualA.frontals() == KeyVector{1});
225  EXPECT_LONGS_EQUAL(0, actualA.nrParents());
226 
227  DiscreteConditional actualB = pAB.marginal(B.first);
228  EXPECT(assert_equal(prior, actualB));
229  EXPECT(actualB.frontals() == KeyVector{0});
230  EXPECT_LONGS_EQUAL(0, actualB.nrParents());
231 }
232 
233 /* ************************************************************************* */
234 // Check calculation of marginals in case branches are pruned
235 TEST(DiscreteConditional, marginals2) {
236  DiscreteKey A(0, 2), B(1, 2); // changing keys need to make pruning happen!
237  DiscreteConditional conditional(A | B = "2/2 3/1");
238  DiscreteConditional prior(B % "1/2");
239  DiscreteConditional pAB = prior * conditional;
240  // P(A=0) = P(A=0|B=0)P(B=0) + P(A=0|B=1)P(B=1) = 2*1 + 3*2 = 8
241  // P(A=1) = P(A=1|B=0)P(B=0) + P(A=1|B=1)P(B=1) = 2*1 + 1*2 = 4
242  DiscreteConditional actualA = pAB.marginal(A.first);
243  DiscreteConditional pA(A % "8/4");
244  EXPECT(assert_equal(pA, actualA));
245 
246  DiscreteConditional actualB = pAB.marginal(B.first);
247  EXPECT(assert_equal(prior, actualB));
248 }
249 
250 /* ************************************************************************* */
251 TEST(DiscreteConditional, likelihood) {
252  DiscreteKey X(0, 2), Y(1, 3);
253  DiscreteConditional conditional(X | Y = "2/8 4/6 5/5");
254 
255  auto actual0 = conditional.likelihood(0);
256  DecisionTreeFactor expected0(Y, "0.2 0.4 0.5");
257  EXPECT(assert_equal(expected0, *actual0, 1e-9));
258 
259  auto actual1 = conditional.likelihood(1);
260  DecisionTreeFactor expected1(Y, "0.8 0.6 0.5");
261  EXPECT(assert_equal(expected1, *actual1, 1e-9));
262 }
263 
264 /* ************************************************************************* */
265 // Check choose on P(C|D,E)
267  DiscreteKey C(2, 2), D(4, 2), E(3, 2);
268  DiscreteConditional C_given_DE((C | D, E) = "4/1 1/1 1/1 1/4");
269 
270  // Case 1: no given values: no-op
271  DiscreteValues given;
272  auto actual1 = C_given_DE.choose(given);
273  EXPECT(assert_equal(C_given_DE, *actual1, 1e-9));
274 
275  // Case 2: 1 given value
276  given[D.first] = 1;
277  auto actual2 = C_given_DE.choose(given);
278  EXPECT_LONGS_EQUAL(1, actual2->nrFrontals());
279  EXPECT_LONGS_EQUAL(1, actual2->nrParents());
280  DiscreteConditional expected2(C | E = "1/1 1/4");
281  EXPECT(assert_equal(expected2, *actual2, 1e-9));
282 
283  // Case 2: 2 given values
284  given[E.first] = 0;
285  auto actual3 = C_given_DE.choose(given);
286  EXPECT_LONGS_EQUAL(1, actual3->nrFrontals());
287  EXPECT_LONGS_EQUAL(0, actual3->nrParents());
288  DiscreteConditional expected3(C % "1/1");
289  EXPECT(assert_equal(expected3, *actual3, 1e-9));
290 }
291 
292 /* ************************************************************************* */
293 // Check markdown representation looks as expected, no parents.
294 TEST(DiscreteConditional, markdown_prior) {
295  DiscreteKey A(Symbol('x', 1), 3);
296  DiscreteConditional conditional(A % "1/2/2");
297  string expected =
298  " *P(x1):*\n\n"
299  "|x1|value|\n"
300  "|:-:|:-:|\n"
301  "|0|0.2|\n"
302  "|1|0.4|\n"
303  "|2|0.4|\n";
304  string actual = conditional.markdown();
305  EXPECT(actual == expected);
306 }
307 
308 /* ************************************************************************* */
309 // Check markdown representation looks as expected, no parents + names.
310 TEST(DiscreteConditional, markdown_prior_names) {
311  Symbol x1('x', 1);
312  DiscreteKey A(x1, 3);
313  DiscreteConditional conditional(A % "1/2/2");
314  string expected =
315  " *P(x1):*\n\n"
316  "|x1|value|\n"
317  "|:-:|:-:|\n"
318  "|A0|0.2|\n"
319  "|A1|0.4|\n"
320  "|A2|0.4|\n";
321  DecisionTreeFactor::Names names{{x1, {"A0", "A1", "A2"}}};
322  string actual = conditional.markdown(DefaultKeyFormatter, names);
323  EXPECT(actual == expected);
324 }
325 
326 /* ************************************************************************* */
327 // Check markdown representation looks as expected, multivalued.
328 TEST(DiscreteConditional, markdown_multivalued) {
329  DiscreteKey A(Symbol('a', 1), 3), B(Symbol('b', 1), 5);
330  DiscreteConditional conditional(
331  A | B = "2/88/10 2/20/78 33/33/34 33/33/34 95/2/3");
332  string expected =
333  " *P(a1|b1):*\n\n"
334  "|*b1*|0|1|2|\n"
335  "|:-:|:-:|:-:|:-:|\n"
336  "|0|0.02|0.88|0.1|\n"
337  "|1|0.02|0.2|0.78|\n"
338  "|2|0.33|0.33|0.34|\n"
339  "|3|0.33|0.33|0.34|\n"
340  "|4|0.95|0.02|0.03|\n";
341  string actual = conditional.markdown();
342  EXPECT(actual == expected);
343 }
344 
345 /* ************************************************************************* */
346 // Check markdown representation looks as expected, two parents + names.
348  DiscreteKey A(2, 2), B(1, 2), C(0, 3);
349  DiscreteConditional conditional(A, {B, C}, "0/1 1/3 1/1 3/1 0/1 1/0");
350  string expected =
351  " *P(A|B,C):*\n\n"
352  "|*B*|*C*|T|F|\n"
353  "|:-:|:-:|:-:|:-:|\n"
354  "|-|Zero|0|1|\n"
355  "|-|One|0.25|0.75|\n"
356  "|-|Two|0.5|0.5|\n"
357  "|+|Zero|0.75|0.25|\n"
358  "|+|One|0|1|\n"
359  "|+|Two|1|0|\n";
360  vector<string> keyNames{"C", "B", "A"};
361  auto formatter = [keyNames](Key key) { return keyNames[key]; };
362  DecisionTreeFactor::Names names{
363  {0, {"Zero", "One", "Two"}}, {1, {"-", "+"}}, {2, {"T", "F"}}};
364  string actual = conditional.markdown(formatter, names);
365  EXPECT(actual == expected);
366 }
367 
368 /* ************************************************************************* */
369 // Check html representation looks as expected, two parents + names.
371  DiscreteKey A(2, 2), B(1, 2), C(0, 3);
372  DiscreteConditional conditional(A, {B, C}, "0/1 1/3 1/1 3/1 0/1 1/0");
373  string expected =
374  "<div>\n"
375  "<p> <i>P(A|B,C):</i></p>\n"
376  "<table class='DiscreteConditional'>\n"
377  " <thead>\n"
378  " <tr><th><i>B</i></th><th><i>C</i></th><th>T</th><th>F</th></tr>\n"
379  " </thead>\n"
380  " <tbody>\n"
381  " <tr><th>-</th><th>Zero</th><td>0</td><td>1</td></tr>\n"
382  " <tr><th>-</th><th>One</th><td>0.25</td><td>0.75</td></tr>\n"
383  " <tr><th>-</th><th>Two</th><td>0.5</td><td>0.5</td></tr>\n"
384  " <tr><th>+</th><th>Zero</th><td>0.75</td><td>0.25</td></tr>\n"
385  " <tr><th>+</th><th>One</th><td>0</td><td>1</td></tr>\n"
386  " <tr><th>+</th><th>Two</th><td>1</td><td>0</td></tr>\n"
387  " </tbody>\n"
388  "</table>\n"
389  "</div>";
390  vector<string> keyNames{"C", "B", "A"};
391  auto formatter = [keyNames](Key key) { return keyNames[key]; };
392  DecisionTreeFactor::Names names{
393  {0, {"Zero", "One", "Two"}}, {1, {"-", "+"}}, {2, {"T", "F"}}};
394  string actual = conditional.html(formatter, names);
395  EXPECT(actual == expected);
396 }
397 
398 /* ************************************************************************* */
399 int main() {
400  TestResult tr;
401  return TestRegistry::runAllTests(tr);
402 }
403 /* ************************************************************************* */
TestRegistry::runAllTests
static int runAllTests(TestResult &result)
Definition: TestRegistry.cpp:27
gtsam::DiscreteConditional::logProbability
double logProbability(const DiscreteValues &x) const
Log-probability is just -error(x).
Definition: DiscreteConditional.h:162
gtsam::Signature::Table
std::vector< Row > Table
Definition: Signature.h:60
DiscreteBayesNet.h
gtsam::markdown
string markdown(const DiscreteValues &values, const KeyFormatter &keyFormatter, const DiscreteValues::Names &names)
Free version of markdown.
Definition: DiscreteValues.cpp:130
gtsam::DecisionTreeFactor
Definition: DecisionTreeFactor.h:44
B
Matrix< SCALARB, Dynamic, Dynamic, opt_B > B
Definition: bench_gemm.cpp:49
Y
const char Y
Definition: test/EulerAngles.cpp:31
D
MatrixXcd D
Definition: EigenSolver_EigenSolver_MatrixType.cpp:14
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
EXPECT_LONGS_EQUAL
#define EXPECT_LONGS_EQUAL(expected, actual)
Definition: Test.h:154
main
int main()
Definition: testDiscreteConditional.cpp:399
EXPECT
#define EXPECT(condition)
Definition: Test.h:150
TestHarness.h
DiscreteFactorGraph.h
r2
static const double r2
Definition: testSmartRangeFactor.cpp:32
example1::pA
Point2 pA(size_t i)
Definition: testEssentialMatrixFactor.cpp:49
formatter
const KeyFormatter & formatter
Definition: treeTraversal-inst.h:204
f2
double f2(const Vector2 &x)
Definition: testNumericalDerivative.cpp:56
log
const EIGEN_DEVICE_FUNC LogReturnType log() const
Definition: ArrayCwiseUnaryOps.h:128
gtsam::Signature::Row
std::vector< double > Row
Definition: Signature.h:59
X
#define X
Definition: icosphere.cpp:20
DiscreteConditional.h
gtsam::DiscreteConditional::markdown
std::string markdown(const KeyFormatter &keyFormatter=DefaultKeyFormatter, const Names &names={}) const override
Render as markdown table.
Definition: DiscreteConditional.cpp:355
r1
static const double r1
Definition: testSmartRangeFactor.cpp:32
gtsam::KeyVector
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition: Key.h:92
gtsam::DefaultKeyFormatter
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition: Key.cpp:30
A
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:48
gtsam::Conditional::endParents
FACTOR::const_iterator endParents() const
Definition: Conditional.h:188
gtsam::DiscreteConditional::marginal
DiscreteConditional marginal(Key key) const
Definition: DiscreteConditional.cpp:112
table
ArrayXXf table(10, 4)
x1
Pose3 x1
Definition: testPose3.cpp:663
gtsam::Conditional::endFrontals
FACTOR::const_iterator endFrontals() const
Definition: Conditional.h:182
cholesky::expected
Matrix expected
Definition: testMatrix.cpp:971
r3
static const double r3
Definition: testSmartRangeFactor.cpp:32
test_DiscreteBayesNet.Asia
tuple Asia
Definition: test_DiscreteBayesNet.py:25
Symbol.h
gtsam::Conditional::beginFrontals
FACTOR::const_iterator beginFrontals() const
Definition: Conditional.h:179
gtsam::Factor::end
const_iterator end() const
Definition: Factor.h:148
EXPECT_DOUBLES_EQUAL
#define EXPECT_DOUBLES_EQUAL(expected, actual, threshold)
Definition: Test.h:161
gtsam::DiscreteConditional::likelihood
DecisionTreeFactor::shared_ptr likelihood(const DiscreteValues &frontalValues) const
Definition: DiscreteConditional.cpp:201
serializationTestHelpers.h
TestResult
Definition: TestResult.h:26
key
const gtsam::Symbol key('X', 0)
E
DiscreteKey E(5, 2)
tree::f
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Definition: testExpression.cpp:218
gtsam::Conditional::beginParents
FACTOR::const_iterator beginParents() const
Definition: Conditional.h:185
process_shonan_timing_results.names
dictionary names
Definition: process_shonan_timing_results.py:175
simulated2D::prior
Point2 prior(const Point2 &x)
Prior on a single pose.
Definition: simulated2D.h:88
gtsam::DiscreteConditional
Definition: DiscreteConditional.h:37
gtsam::DiscreteConditional::evaluate
double evaluate(const DiscreteValues &values) const
Evaluate, just look up in AlgebraicDecisonTree.
Definition: DiscreteConditional.h:174
C
Matrix< Scalar, Dynamic, Dynamic > C
Definition: bench_gemm.cpp:50
gtsam
traits
Definition: chartTesting.h:28
gtsam::DiscreteValues
Definition: DiscreteValues.h:34
leaf::values
leaf::MyValues values
gtsam::DiscreteKey
std::pair< Key, size_t > DiscreteKey
Definition: DiscreteKey.h:38
std
Definition: BFloat16.h:88
v
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
gtsam::assert_equal
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
Definition: Matrix.cpp:40
gtsam::DiscreteConditional::choose
shared_ptr choose(const DiscreteValues &given) const
< DiscreteValues version
Definition: DiscreteConditional.cpp:182
TEST
TEST(DiscreteConditional, constructors)
Definition: testDiscreteConditional.cpp:33
unary::f1
Point2 f1(const Point3 &p, OptionalJacobian< 2, 3 > H)
Definition: testExpression.cpp:79
gtsam::html
string html(const DiscreteValues &values, const KeyFormatter &keyFormatter, const DiscreteValues::Names &names)
Free version of html.
Definition: DiscreteValues.cpp:135
marginals
Marginals marginals(graph, result)
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:97
Z
#define Z
Definition: icosphere.cpp:21
gtsam::Conditional::frontals
Frontals frontals() const
Definition: Conditional.h:143
DecisionTreeFactor.h
choose
static const T & choose(int layout, const T &col, const T &row)
Definition: cxx11_tensor_block_access.cpp:27
gtsam::Conditional::nrParents
size_t nrParents() const
Definition: Conditional.h:132
gtsam::Signature
Definition: Signature.h:54
asiaKey
static const Key asiaKey
Definition: testHybridBayesNet.cpp:39
gtsam::Symbol
Definition: inference/Symbol.h:37
gtsam::DiscreteConditional::error
double error(const DiscreteValues &values) const
Calculate error for DiscreteValues x, is -log(probability).
Definition: DecisionTreeFactor.cpp:56


gtsam
Author(s):
autogenerated on Tue Jun 25 2024 03:05:42