DiscreteConditional.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 
19 #include <gtsam/base/Testable.h>
20 #include <gtsam/base/debug.h>
22 #include <gtsam/discrete/Ring.h>
25 
26 #include <algorithm>
27 #include <cassert>
28 #include <random>
29 #include <set>
30 #include <stdexcept>
31 #include <string>
32 #include <utility>
33 #include <vector>
34 
35 using namespace std;
36 using std::pair;
37 using std::stringstream;
38 using std::vector;
39 namespace gtsam {
40 
41 // Instantiate base class
42 template class GTSAM_EXPORT
44 
45 /* ************************************************************************** */
46 DiscreteConditional::DiscreteConditional(const size_t nrFrontals,
47  const DiscreteFactor& f)
48  : BaseFactor((f / f.sum(nrFrontals))->toDecisionTreeFactor()),
49  BaseConditional(nrFrontals) {}
50 
51 /* ************************************************************************** */
53  const DiscreteKeys& keys,
54  const ADT& potentials)
55  : BaseFactor(keys, potentials), BaseConditional(nrFrontals) {}
56 
57 /* ************************************************************************** */
59  const DecisionTreeFactor& marginal)
60  : BaseFactor(joint / marginal),
61  BaseConditional(joint.size() - marginal.size()) {}
62 
63 /* ************************************************************************** */
65  const DecisionTreeFactor& marginal,
66  const Ordering& orderedKeys)
67  : DiscreteConditional(joint, marginal) {
68  keys_.clear();
69  keys_.insert(keys_.end(), orderedKeys.begin(), orderedKeys.end());
70 }
71 
72 /* ************************************************************************** */
74  : BaseFactor(signature.discreteKeys(), signature.cpt()),
75  BaseConditional(1) {}
76 
77 /* ************************************************************************** */
79  const DiscreteConditional& other) const {
80  // Take union of frontal keys
81  std::set<Key> newFrontals;
82  for (auto&& key : this->frontals()) newFrontals.insert(key);
83  for (auto&& key : other.frontals()) newFrontals.insert(key);
84 
85  // Check if frontals overlapped
86  if (nrFrontals() + other.nrFrontals() > newFrontals.size())
87  throw std::invalid_argument(
88  "DiscreteConditional::operator* called with overlapping frontal keys.");
89 
90  // Now, add cardinalities.
92  for (auto&& key : frontals())
93  discreteKeys.emplace_back(key, cardinality(key));
94  for (auto&& key : other.frontals())
95  discreteKeys.emplace_back(key, other.cardinality(key));
96 
97  // Sort
98  std::sort(discreteKeys.begin(), discreteKeys.end());
99 
100  // Add parents to set, to make them unique
101  std::set<DiscreteKey> parents;
102  for (auto&& key : this->parents())
103  if (!newFrontals.count(key)) parents.emplace(key, cardinality(key));
104  for (auto&& key : other.parents())
105  if (!newFrontals.count(key)) parents.emplace(key, other.cardinality(key));
106 
107  // Finally, add parents to keys, in order
108  for (auto&& dk : parents) discreteKeys.push_back(dk);
109 
111  return DiscreteConditional(newFrontals.size(), discreteKeys, product);
112 }
113 
114 /* ************************************************************************** */
116  if (nrParents() > 0)
117  throw std::invalid_argument(
118  "DiscreteConditional::marginal: single argument version only valid for "
119  "fully specified joint distributions (i.e., no parents).");
120 
121  // Calculate the keys as the frontal keys without the given key.
123 
124  // Calculate sum
125  ADT adt(*this);
126  for (auto&& k : frontals())
127  if (k != key) adt = adt.sum(k, cardinality(k));
128 
129  // Return new factor
130  return DiscreteConditional(1, discreteKeys, adt);
131 }
132 
133 /* ************************************************************************** */
134 void DiscreteConditional::print(const string& s,
135  const KeyFormatter& formatter) const {
136  cout << s << " P( ";
137  for (const_iterator it = beginFrontals(); it != endFrontals(); ++it) {
138  cout << formatter(*it) << " ";
139  }
140  if (nrParents()) {
141  cout << "| ";
142  for (const_iterator it = beginParents(); it != endParents(); ++it) {
143  cout << formatter(*it) << " ";
144  }
145  }
146  cout << "):\n";
147  ADT::print("", formatter);
148  cout << endl;
149 }
150 
151 /* ************************************************************************** */
153  double tol) const {
154  if (!dynamic_cast<const BaseFactor*>(&other)) {
155  return false;
156  } else {
157  const BaseFactor& f(static_cast<const BaseFactor&>(other));
158  return BaseFactor::equals(f, tol);
159  }
160 }
161 
162 /* ************************************************************************** */
164  const DiscreteValues& given, bool forceComplete) const {
165  // Get the big decision tree with all the levels, and then go down the
166  // branches based on the value of the parent variables.
167  DiscreteConditional::ADT adt(*this);
168  size_t value;
169  for (Key j : parents()) {
170  try {
171  value = given.at(j);
172  adt = adt.choose(j, value); // ADT keeps getting smaller.
173  } catch (std::out_of_range&) {
174  if (forceComplete) {
175  given.print("parentsValues: ");
176  throw runtime_error(
177  "DiscreteConditional::choose: parent value missing");
178  }
179  }
180  }
181  return adt;
182 }
183 
184 /* ************************************************************************** */
186  const DiscreteValues& given) const {
187  ADT adt = choose(given, false); // P(F|S=given)
188 
189  // Collect all keys not in given.
190  DiscreteKeys dKeys;
191  for (Key j : frontals()) {
192  dKeys.emplace_back(j, this->cardinality(j));
193  }
194  for (size_t i = nrFrontals(); i < size(); i++) {
195  Key j = keys_[i];
196  if (given.count(j) == 0) {
197  dKeys.emplace_back(j, this->cardinality(j));
198  }
199  }
200  return std::make_shared<DiscreteConditional>(nrFrontals(), dKeys, adt);
201 }
202 
203 /* ************************************************************************** */
205  const DiscreteValues& frontalValues) const {
206  // Get the big decision tree with all the levels, and then go down the
207  // branches based on the value of the frontal variables.
208  ADT adt(*this);
209  size_t value;
210  for (Key j : frontals()) {
211  try {
212  value = frontalValues.at(j);
213  adt = adt.choose(j, value); // ADT keeps getting smaller.
214  } catch (exception&) {
215  frontalValues.print("frontalValues: ");
216  throw runtime_error("DiscreteConditional::choose: frontal value missing");
217  }
218  }
219 
220  // Convert ADT to factor.
222  for (Key j : parents()) {
223  discreteKeys.emplace_back(j, this->cardinality(j));
224  }
225  return std::make_shared<DecisionTreeFactor>(discreteKeys, adt);
226 }
227 
228 /* ****************************************************************************/
230  size_t frontal) const {
231  if (nrFrontals() != 1)
232  throw std::invalid_argument(
233  "Single value likelihood can only be invoked on single-variable "
234  "conditional");
236  values.emplace(keys_[0], frontal);
237  return likelihood(values);
238 }
239 
240 /* ************************************************************************** */
241 size_t DiscreteConditional::argmax(const DiscreteValues& parentsValues) const {
242  ADT pFS = choose(parentsValues, true); // P(F|S=parentsValues)
243 
244  // Initialize
245  size_t maxValue = 0;
246  double maxP = 0;
247  DiscreteValues values = parentsValues;
248 
249  assert(nrFrontals() == 1);
250  Key j = firstFrontalKey();
251  for (size_t value = 0; value < cardinality(j); value++) {
252  values[j] = value;
253  double pValueS = (*this)(values);
254  // Update MPE solution if better
255  if (pValueS > maxP) {
256  maxP = pValueS;
257  maxValue = value;
258  }
259  }
260  return maxValue;
261 }
262 
263 /* ************************************************************************** */
265  // throw if more than one frontal:
266  if (nrFrontals() != 1) {
267  throw std::invalid_argument(
268  "DiscreteConditional::sampleInPlace can only be called on single "
269  "variable conditionals");
270  }
271  Key j = firstFrontalKey();
272  // throw if values already contains j:
273  if (values->count(j) > 0) {
274  throw std::invalid_argument(
275  "DiscreteConditional::sampleInPlace: values already contains j");
276  }
277  size_t sampled = sample(*values); // Sample variable given parents
278  (*values)[j] = sampled; // store result in partial solution
279 }
280 
281 /* ************************************************************************** */
282 size_t DiscreteConditional::sample(const DiscreteValues& parentsValues) const {
283  static mt19937 rng(2); // random number generator
284 
285  // Get the correct conditional distribution
286  ADT pFS = choose(parentsValues, true); // P(F|S=parentsValues)
287 
288  // TODO(Duy): only works for one key now, seems horribly slow this way
289  if (nrFrontals() != 1) {
290  throw std::invalid_argument(
291  "DiscreteConditional::sample can only be called on single variable "
292  "conditionals");
293  }
294  Key key = firstFrontalKey();
295  size_t nj = cardinality(key);
296  vector<double> p(nj);
298  for (size_t value = 0; value < nj; value++) {
299  frontals[key] = value;
300  p[value] = pFS(frontals); // P(F=value|S=parentsValues)
301  if (p[value] == 1.0) {
302  return value; // shortcut exit
303  }
304  }
305  std::discrete_distribution<size_t> distribution(p.begin(), p.end());
306  return distribution(rng);
307 }
308 
309 /* ************************************************************************** */
310 size_t DiscreteConditional::sample(size_t parent_value) const {
311  if (nrParents() != 1)
312  throw std::invalid_argument(
313  "Single value sample() can only be invoked on single-parent "
314  "conditional");
316  values.emplace(keys_.back(), parent_value);
317  return sample(values);
318 }
319 
320 /* ************************************************************************** */
322  if (nrParents() != 0)
323  throw std::invalid_argument(
324  "sample() can only be invoked on no-parent prior");
326  return sample(values);
327 }
328 
329 /* ************************************************************************* */
330 vector<DiscreteValues> DiscreteConditional::frontalAssignments() const {
331  vector<pair<Key, size_t>> pairs;
332  for (Key key : frontals()) pairs.emplace_back(key, cardinalities_.at(key));
333  vector<pair<Key, size_t>> rpairs(pairs.rbegin(), pairs.rend());
334  return DiscreteValues::CartesianProduct(rpairs);
335 }
336 
337 /* ************************************************************************* */
338 vector<DiscreteValues> DiscreteConditional::allAssignments() const {
339  vector<pair<Key, size_t>> pairs;
340  for (Key key : parents()) pairs.emplace_back(key, cardinalities_.at(key));
341  for (Key key : frontals()) pairs.emplace_back(key, cardinalities_.at(key));
342  vector<pair<Key, size_t>> rpairs(pairs.rbegin(), pairs.rend());
343  return DiscreteValues::CartesianProduct(rpairs);
344 }
345 
346 /* ************************************************************************* */
347 // Print out signature.
348 static void streamSignature(const DiscreteConditional& conditional,
349  const KeyFormatter& keyFormatter,
350  stringstream* ss) {
351  *ss << "P(";
352  bool first = true;
353  for (Key key : conditional.frontals()) {
354  if (!first) *ss << ",";
355  *ss << keyFormatter(key);
356  first = false;
357  }
358  if (conditional.nrParents() > 0) {
359  *ss << "|";
360  bool first = true;
361  for (Key parent : conditional.parents()) {
362  if (!first) *ss << ",";
363  *ss << keyFormatter(parent);
364  first = false;
365  }
366  }
367  *ss << "):";
368 }
369 
370 /* ************************************************************************* */
371 std::string DiscreteConditional::markdown(const KeyFormatter& keyFormatter,
372  const Names& names) const {
373  stringstream ss;
374  ss << " *";
375  streamSignature(*this, keyFormatter, &ss);
376  ss << "*\n" << std::endl;
377  if (nrParents() == 0) {
378  // We have no parents, call factor method.
379  ss << BaseFactor::markdown(keyFormatter, names);
380  return ss.str();
381  }
382 
383  // Print out header.
384  ss << "|";
385  for (Key parent : parents()) {
386  ss << "*" << keyFormatter(parent) << "*|";
387  }
388 
389  auto frontalAssignments = this->frontalAssignments();
390  for (const auto& a : frontalAssignments) {
391  for (auto&& it = beginFrontals(); it != endFrontals(); ++it) {
392  size_t index = a.at(*it);
393  ss << DiscreteValues::Translate(names, *it, index);
394  }
395  ss << "|";
396  }
397  ss << "\n";
398 
399  // Print out separator with alignment hints.
400  ss << "|";
401  size_t n = frontalAssignments.size();
402  for (size_t j = 0; j < nrParents() + n; j++) ss << ":-:|";
403  ss << "\n";
404 
405  // Print out all rows.
406  size_t count = 0;
407  for (const auto& a : allAssignments()) {
408  if (count == 0) {
409  ss << "|";
410  for (auto&& it = beginParents(); it != endParents(); ++it) {
411  size_t index = a.at(*it);
412  ss << DiscreteValues::Translate(names, *it, index) << "|";
413  }
414  }
415  ss << operator()(a) << "|";
416  count = (count + 1) % n;
417  if (count == 0) ss << "\n";
418  }
419  return ss.str();
420 }
421 
422 /* ************************************************************************ */
423 string DiscreteConditional::html(const KeyFormatter& keyFormatter,
424  const Names& names) const {
425  stringstream ss;
426  ss << "<div>\n<p> <i>";
427  streamSignature(*this, keyFormatter, &ss);
428  ss << "</i></p>\n";
429  if (nrParents() == 0) {
430  // We have no parents, call factor method.
431  ss << BaseFactor::html(keyFormatter, names);
432  return ss.str();
433  }
434 
435  // Print out preamble.
436  ss << "<table class='DiscreteConditional'>\n <thead>\n";
437 
438  // Print out header row.
439  ss << " <tr>";
440  for (Key parent : parents()) {
441  ss << "<th><i>" << keyFormatter(parent) << "</i></th>";
442  }
443  auto frontalAssignments = this->frontalAssignments();
444  for (const auto& a : frontalAssignments) {
445  ss << "<th>";
446  for (auto&& it = beginFrontals(); it != endFrontals(); ++it) {
447  size_t index = a.at(*it);
448  ss << DiscreteValues::Translate(names, *it, index);
449  }
450  ss << "</th>";
451  }
452  ss << "</tr>\n";
453 
454  // Finish header and start body.
455  ss << " </thead>\n <tbody>\n";
456 
457  // Output all rows, one per assignment:
458  size_t count = 0, n = frontalAssignments.size();
459  for (const auto& a : allAssignments()) {
460  if (count == 0) {
461  ss << " <tr>";
462  for (auto&& it = beginParents(); it != endParents(); ++it) {
463  size_t index = a.at(*it);
464  ss << "<th>" << DiscreteValues::Translate(names, *it, index) << "</th>";
465  }
466  }
467  ss << "<td>" << operator()(a) << "</td>"; // value
468  count = (count + 1) % n;
469  if (count == 0) ss << "</tr>\n";
470  }
471 
472  // Finish up
473  ss << " </tbody>\n</table>\n</div>";
474  return ss.str();
475 }
476 
477 /* ************************************************************************* */
479  return this->operator()(x.discrete());
480 }
481 
482 /* ************************************************************************* */
483 double DiscreteConditional::negLogConstant() const { return 0.0; }
484 
485 /* ************************************************************************* */
486 
487 } // namespace gtsam
gtsam::DiscreteConditional::sample
size_t sample() const
Zero parent version.
Definition: DiscreteConditional.cpp:321
gtsam::DiscreteValues::print
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
print required by Testable.
Definition: DiscreteValues.cpp:30
gtsam::DecisionTreeFactor
Definition: DecisionTreeFactor.h:45
gtsam::HybridValues
Definition: HybridValues.h:37
rng
static std::mt19937 rng
Definition: timeFactorOverhead.cpp:31
s
RealScalar s
Definition: level1_cplx_impl.h:126
Testable.h
Concept check for values that can be used in unit tests.
keys
const KeyVector keys
Definition: testRegularImplicitSchurFactor.cpp:40
gtsam::DiscreteFactor::cardinalities_
std::map< Key, size_t > cardinalities_
Map of Keys and their cardinalities.
Definition: DiscreteFactor.h:57
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::DiscreteConditional::operator*
DiscreteConditional operator*(const DiscreteConditional &other) const
Combine two conditionals, yielding a new conditional with the union of the frontal keys,...
Definition: DiscreteConditional.cpp:78
gtsam::DiscreteConditional::equals
bool equals(const DiscreteFactor &other, double tol=1e-9) const override
GTSAM-style equals.
Definition: DiscreteConditional.cpp:152
formatter
const KeyFormatter & formatter
Definition: treeTraversal-inst.h:204
different_sigmas::values
HybridValues values
Definition: testHybridBayesNet.cpp:245
gtsam::DiscreteKeys
DiscreteKeys is a set of keys that can be assembled using the & operator.
Definition: DiscreteKey.h:41
DiscreteConditional.h
gtsam::DiscreteConditional::markdown
std::string markdown(const KeyFormatter &keyFormatter=DefaultKeyFormatter, const Names &names={}) const override
Render as markdown table.
Definition: DiscreteConditional.cpp:371
gtsam::DecisionTree::choose
DecisionTree choose(const L &label, size_t index) const
Definition: DecisionTree.h:391
gtsam::DecisionTreeFactor::shared_ptr
std::shared_ptr< DecisionTreeFactor > shared_ptr
Definition: DecisionTreeFactor.h:51
gtsam::DiscreteConditional::html
std::string html(const KeyFormatter &keyFormatter=DefaultKeyFormatter, const Names &names={}) const override
Render as html table.
Definition: DiscreteConditional.cpp:423
Ring::mul
static double mul(const double &a, const double &b)
Definition: Ring.h:31
gtsam::Conditional< DecisionTreeFactor, DiscreteConditional >::operator()
double operator()(const HybridValues &x) const
Evaluate probability density, sugar.
Definition: Conditional.h:163
gtsam::AlgebraicDecisionTree< Key >
size
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
ss
static std::stringstream ss
Definition: testBTree.cpp:31
n
int n
Definition: BiCGSTAB_simple.cpp:1
gtsam::Conditional< DecisionTreeFactor, DiscreteConditional >::endParents
DecisionTreeFactor ::const_iterator endParents() const
Definition: Conditional.h:189
gtsam::DiscreteConditional::marginal
DiscreteConditional marginal(Key key) const
Definition: DiscreteConditional.cpp:115
gtsam::DiscreteConditional::allAssignments
std::vector< DiscreteValues > allAssignments() const
Return all assignments for frontal and parent variables.
Definition: DiscreteConditional.cpp:338
gtsam::DiscreteConditional::print
void print(const std::string &s="Discrete Conditional: ", const KeyFormatter &formatter=DefaultKeyFormatter) const override
GTSAM-style print.
Definition: DiscreteConditional.cpp:134
j
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2
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:85
gtsam::Conditional< DecisionTreeFactor, DiscreteConditional >::endFrontals
DecisionTreeFactor ::const_iterator endFrontals() const
Definition: Conditional.h:183
gtsam::KeyFormatter
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:35
Signature.h
signatures for conditional densities
gtsam::DiscreteConditional::frontalAssignments
std::vector< DiscreteValues > frontalAssignments() const
Return all assignments for frontal variables.
Definition: DiscreteConditional.cpp:330
gtsam::streamSignature
static void streamSignature(const DiscreteConditional &conditional, const KeyFormatter &keyFormatter, stringstream *ss)
Definition: DiscreteConditional.cpp:348
gtsam::DecisionTreeFactor::equals
bool equals(const DiscreteFactor &other, double tol=1e-9) const override
equality
Definition: DecisionTreeFactor.cpp:46
gtsam::DiscreteConditional::negLogConstant
double negLogConstant() const override
Definition: DiscreteConditional.cpp:483
gtsam::DiscreteConditional::evaluate
double evaluate(const HybridValues &x) const override
Definition: DiscreteConditional.cpp:478
gtsam::Conditional< DecisionTreeFactor, DiscreteConditional >::beginFrontals
DecisionTreeFactor ::const_iterator beginFrontals() const
Definition: Conditional.h:180
gtsam::DiscreteConditional::argmax
size_t argmax(const DiscreteValues &parentsValues=DiscreteValues()) const
Return assignment for single frontal variable that maximizes value.
Definition: DiscreteConditional.cpp:241
gtsam::Conditional< DecisionTreeFactor, DiscreteConditional >
gtsam::DecisionTree< Key, double >::apply
DecisionTree apply(const Unary &op) const
Definition: DecisionTree-inl.h:1000
gtsam::Conditional< DecisionTreeFactor, DiscreteConditional >::parents
Parents parents() const
Definition: Conditional.h:148
gtsam::DiscreteConditional::likelihood
DecisionTreeFactor::shared_ptr likelihood(const DiscreteValues &frontalValues) const
Definition: DiscreteConditional.cpp:204
gtsam::Conditional< DecisionTreeFactor, DiscreteConditional >::nrFrontals
size_t nrFrontals() const
Definition: Conditional.h:131
gtsam::AlgebraicDecisionTree::sum
double sum() const
Compute sum of all values.
Definition: AlgebraicDecisionTree.h:208
key
const gtsam::Symbol key('X', 0)
gtsam::DiscreteConditional::shared_ptr
std::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition: DiscreteConditional.h:43
tree::f
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Definition: testExpression.cpp:218
gtsam::Conditional< DecisionTreeFactor, DiscreteConditional >::beginParents
DecisionTreeFactor ::const_iterator beginParents() const
Definition: Conditional.h:186
gtsam::DiscreteFactor::cardinality
size_t cardinality(Key j) const
Definition: DiscreteFactor.h:99
process_shonan_timing_results.names
dictionary names
Definition: process_shonan_timing_results.py:175
gtsam::Conditional< DecisionTreeFactor, DiscreteConditional >::firstFrontalKey
Key firstFrontalKey() const
Definition: Conditional.h:137
gtsam::DiscreteConditional
Definition: DiscreteConditional.h:37
a
ArrayXXi a
Definition: Array_initializer_list_23_cxx11.cpp:1
gtsam::Factor::const_iterator
KeyVector::const_iterator const_iterator
Const iterator over keys.
Definition: Factor.h:83
gtsam::DiscreteConditional::sampleInPlace
void sampleInPlace(DiscreteValues *parentsValues) const
sample in place, stores result in partial solution
Definition: DiscreteConditional.cpp:264
gtsam
traits
Definition: SFMdata.h:40
gtsam::Factor::keys_
KeyVector keys_
The keys involved in this factor.
Definition: Factor.h:88
gtsam::DiscreteFactor::Names
DiscreteValues::Names Names
Translation table from values to strings.
Definition: DiscreteFactor.h:172
gtsam::DiscreteValues
Definition: DiscreteValues.h:34
gtsam::AlgebraicDecisionTree< Key >::print
void print(const std::string &s="", const typename Base::LabelFormatter &labelFormatter=&DefaultFormatter) const
print method customized to value type double.
Definition: AlgebraicDecisionTree.h:251
std
Definition: BFloat16.h:88
gtsam::HybridValues::discrete
const DiscreteValues & discrete() const
Return the discrete values.
Definition: HybridValues.cpp:57
p
float * p
Definition: Tutorial_Map_using.cpp:9
Ring.h
Real Ring definition.
gtsam::DecisionTreeFactor::html
std::string html(const KeyFormatter &keyFormatter=DefaultKeyFormatter, const Names &names={}) const override
Render as html table.
Definition: DecisionTreeFactor.cpp:351
product
void product(const MatrixType &m)
Definition: product.h:20
gtsam::DiscreteConditional::DiscreteConditional
DiscreteConditional()
Default constructor needed for serialization.
Definition: DiscreteConditional.h:54
gtsam::tol
const G double tol
Definition: Group.h:79
gtsam::DiscreteConditional::choose
shared_ptr choose(const DiscreteValues &given) const
< DiscreteValues version
Definition: DiscreteConditional.cpp:185
gtsam::DiscreteFactor::discreteKeys
DiscreteKeys discreteKeys() const
Return all the discrete keys associated with this factor.
Definition: DiscreteFactor.cpp:37
gtsam::DiscreteFactor
Definition: DiscreteFactor.h:40
gtsam::DiscreteValues::Translate
static std::string Translate(const Names &names, Key key, size_t index)
Translate an integer index value for given key to a string.
Definition: DiscreteValues.cpp:78
gtsam::Factor::size
size_t size() const
Definition: Factor.h:160
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:97
HybridValues.h
gtsam::Ordering
Definition: inference/Ordering.h:33
gtsam::Conditional< DecisionTreeFactor, DiscreteConditional >::frontals
Frontals frontals() const
Definition: Conditional.h:145
gtsam::DecisionTreeFactor::markdown
std::string markdown(const KeyFormatter &keyFormatter=DefaultKeyFormatter, const Names &names={}) const override
Render as markdown table.
Definition: DecisionTreeFactor.cpp:320
gtsam::Conditional< DecisionTreeFactor, DiscreteConditional >::nrParents
size_t nrParents() const
Definition: Conditional.h:134
test_callbacks.value
value
Definition: test_callbacks.py:160
gtsam::Signature
Definition: Signature.h:54
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
pybind_wrapper_test_script.other
other
Definition: pybind_wrapper_test_script.py:42
debug.h
Global debugging flags.


gtsam
Author(s):
autogenerated on Tue Jan 7 2025 04:02:11