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  //** (Preferred) sugar for the above for given DiscreteValues */
63  double operator()(const DiscreteValues& values) const {
64  return evaluate(values);
65  }
66 };
67 
68 /* ************************************************************************* */
73 class GTSAM_EXPORT DiscreteBayesTree
74  : public BayesTree<DiscreteBayesTreeClique> {
75  private:
77 
78  public:
80  typedef std::shared_ptr<This> shared_ptr;
81 
84 
86 
88  bool equals(const This& other, double tol = 1e-9) const;
89 
90  //** evaluate probability for given DiscreteValues */
91  double evaluate(const DiscreteValues& values) const;
92 
93  //** (Preferred) sugar for the above for given DiscreteValues */
94  double operator()(const DiscreteValues& values) const {
95  return evaluate(values);
96  }
97 
101 
103  std::string markdown(const KeyFormatter& keyFormatter = DefaultKeyFormatter,
104  const DiscreteFactor::Names& names = {}) const;
105 
107  std::string html(const KeyFormatter& keyFormatter = DefaultKeyFormatter,
108  const DiscreteFactor::Names& names = {}) const;
109 
111 };
112 
114 template <>
116  : public Testable<DiscreteBayesTreeClique> {};
117 
118 template <>
119 struct traits<DiscreteBayesTree> : public Testable<DiscreteBayesTree> {};
120 
121 } // namespace gtsam
VectorValues
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::DiscreteBayesTreeClique::Base
BayesTreeCliqueBase< DiscreteBayesTreeClique, DiscreteFactorGraph > Base
Definition: DiscreteBayesTree.h:44
s
RealScalar s
Definition: level1_cplx_impl.h:126
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
gtsam::DiscreteBayesTree::shared_ptr
std::shared_ptr< This > shared_ptr
Definition: DiscreteBayesTree.h:80
DiscreteFactorGraph.h
gtsam::DiscreteBayesTreeClique::DiscreteBayesTreeClique
DiscreteBayesTreeClique()
Definition: DiscreteBayesTree.h:47
BayesTree.h
Bayes Tree is a tree of cliques of a Bayes Chain.
formatter
const KeyFormatter & formatter
Definition: treeTraversal-inst.h:204
BayesTreeCliqueBase.h
Base class for cliques of a BayesTree.
gtsam::DiscreteBayesTreeClique::operator()
double operator()(const DiscreteValues &values) const
Definition: DiscreteBayesTree.h:63
gtsam::DefaultKeyFormatter
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition: Key.cpp:30
gtsam::DiscreteBayesTree::Base
BayesTree< DiscreteBayesTreeClique > Base
Definition: DiscreteBayesTree.h:76
gtsam::BayesTreeCliqueBase
Definition: BayesTreeCliqueBase.h:49
gtsam::DiscreteBayesTreeClique::DiscreteBayesTreeClique
DiscreteBayesTreeClique(const std::shared_ptr< DiscreteConditional > &conditional)
Definition: DiscreteBayesTree.h:48
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::DiscreteBayesTree::DiscreteBayesTree
DiscreteBayesTree()
Definition: DiscreteBayesTree.h:85
gtsam::DiscreteBayesTreeClique::printSignature
void printSignature(const std::string &s="Clique: ", const KeyFormatter &formatter=DefaultKeyFormatter) const
print index signature only
Definition: DiscreteBayesTree.h:53
gtsam::DiscreteBayesTreeClique::weak_ptr
std::weak_ptr< This > weak_ptr
Definition: DiscreteBayesTree.h:46
gtsam::equals
Definition: Testable.h:112
process_shonan_timing_results.names
dictionary names
Definition: process_shonan_timing_results.py:175
gtsam
traits
Definition: chartTesting.h:28
gtsam::Testable
Definition: Testable.h:152
gtsam::BayesTree
Definition: BayesTree.h:66
gtsam::traits
Definition: Group.h:36
gtsam::DiscreteFactor::Names
DiscreteValues::Names Names
Translation table from values to strings.
Definition: DiscreteFactor.h:121
gtsam::DiscreteValues
Definition: DiscreteValues.h:34
leaf::values
leaf::MyValues values
This
#define This
Definition: ActiveSetSolver-inl.h:27
gtsam::DiscreteBayesTree
A Bayes tree representing a Discrete distribution.
Definition: DiscreteBayesTree.h:73
gtsam::tol
const G double tol
Definition: Group.h:79
gtsam::html
string html(const DiscreteValues &values, const KeyFormatter &keyFormatter, const DiscreteValues::Names &names)
Free version of html.
Definition: DiscreteValues.cpp:135
gtsam::DiscreteBayesTreeClique
Definition: DiscreteBayesTree.h:39
gtsam::DiscreteBayesTreeClique::This
DiscreteBayesTreeClique This
Definition: DiscreteBayesTree.h:42
Conditional.h
Base class for conditional densities.
gtsam::DiscreteBayesTree::This
DiscreteBayesTree This
Definition: DiscreteBayesTree.h:79
gtsam::DiscreteBayesTree::operator()
double operator()(const DiscreteValues &values) const
Definition: DiscreteBayesTree.h:94
pybind_wrapper_test_script.other
other
Definition: pybind_wrapper_test_script.py:42
gtsam::DiscreteBayesTreeClique::shared_ptr
std::shared_ptr< This > shared_ptr
Definition: DiscreteBayesTree.h:45


gtsam
Author(s):
autogenerated on Tue Jun 25 2024 03:00:48