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