DiscreteBayesTree.h
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 
21 #pragma once
22 
28 
29 #include <string>
30 
31 namespace gtsam {
32 
33 // Forward declarations
34 class DiscreteConditional;
35 class VectorValues;
36 
37 /* ************************************************************************* */
39 class GTSAM_EXPORT DiscreteBayesTreeClique
40  : public BayesTreeCliqueBase<DiscreteBayesTreeClique, DiscreteFactorGraph> {
41  public:
45  typedef std::shared_ptr<This> shared_ptr;
46  typedef std::weak_ptr<This> weak_ptr;
49  const std::shared_ptr<DiscreteConditional>& conditional)
50  : Base(conditional) {}
51 
54  const std::string& s = "Clique: ",
56  conditional_->printSignature(s, formatter);
57  }
58 
59  //** evaluate conditional probability of subtree for given DiscreteValues */
60  double evaluate(const DiscreteValues& values) const;
61 };
62 
63 /* ************************************************************************* */
68 class GTSAM_EXPORT DiscreteBayesTree
69  : public BayesTree<DiscreteBayesTreeClique> {
70  private:
72 
73  public:
75  typedef std::shared_ptr<This> shared_ptr;
76 
79 
81 
83  bool equals(const This& other, double tol = 1e-9) const;
84 
85  //** evaluate probability for given DiscreteValues */
86  double evaluate(const DiscreteValues& values) const;
87 
88  //** (Preferred) sugar for the above for given DiscreteValues */
89  double operator()(const DiscreteValues& values) const {
90  return evaluate(values);
91  }
92 
96 
98  std::string markdown(const KeyFormatter& keyFormatter = DefaultKeyFormatter,
99  const DiscreteFactor::Names& names = {}) const;
100 
102  std::string html(const KeyFormatter& keyFormatter = DefaultKeyFormatter,
103  const DiscreteFactor::Names& names = {}) const;
104 
106 };
107 
108 } // namespace gtsam
Base class for conditional densities.
std::shared_ptr< This > shared_ptr
A Bayes tree representing a Discrete distribution.
string markdown(const DiscreteValues &values, const KeyFormatter &keyFormatter, const DiscreteValues::Names &names)
Free version of markdown.
leaf::MyValues values
DiscreteBayesTreeClique This
static const KeyFormatter DefaultKeyFormatter
Definition: Key.h:43
std::weak_ptr< This > weak_ptr
const KeyFormatter & formatter
void printSignature(const std::string &s="Clique: ", const KeyFormatter &formatter=DefaultKeyFormatter) const
print index signature only
BayesTree< DiscreteBayesTreeClique > Base
string html(const DiscreteValues &values, const KeyFormatter &keyFormatter, const DiscreteValues::Names &names)
Free version of html.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
RealScalar s
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
BayesTreeCliqueBase< DiscreteBayesTreeClique, DiscreteFactorGraph > Base
Bayes Tree is a tree of cliques of a Bayes Chain.
DiscreteValues::Names Names
Translation table from values to strings.
traits
Definition: chartTesting.h:28
DiscreteBayesTreeClique(const std::shared_ptr< DiscreteConditional > &conditional)
double operator()(const DiscreteValues &values) const
const G double tol
Definition: Group.h:86
std::shared_ptr< This > shared_ptr
Base class for cliques of a BayesTree.


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:10