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