gtsam
Loading...
Searching...
No Matches
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
20
21#pragma once
22
28
29#include <string>
30
31namespace gtsam {
32
33// Forward declarations
35class VectorValues;
36
37/* ************************************************************************* */
39class GTSAM_EXPORT DiscreteBayesTreeClique
40 : public BayesTreeCliqueBase<DiscreteBayesTreeClique, DiscreteFactorGraph> {
41 public:
42 typedef DiscreteBayesTreeClique This;
44 Base;
45 typedef std::shared_ptr<This> shared_ptr;
46 typedef std::weak_ptr<This> weak_ptr;
47 DiscreteBayesTreeClique() {}
48 DiscreteBayesTreeClique(
49 const std::shared_ptr<DiscreteConditional>& conditional)
50 : Base(conditional) {}
51
54 const std::string& s = "Clique: ",
55 const KeyFormatter& formatter = DefaultKeyFormatter) const {
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/* ************************************************************************* */
73class GTSAM_EXPORT DiscreteBayesTree
74 : public BayesTree<DiscreteBayesTreeClique> {
75 private:
77
78 public:
79 typedef DiscreteBayesTree This;
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
114template <>
116 : public Testable<DiscreteBayesTreeClique> {};
117
118template <>
119struct traits<DiscreteBayesTree> : public Testable<DiscreteBayesTree> {};
120
121} // namespace gtsam
122
123#if GTSAM_ENABLE_BOOST_SERIALIZATION
124BOOST_CLASS_VERSION(gtsam::DiscreteBayesTree, 1)
125#endif
Base class for cliques of a BayesTree.
Bayes Tree is a tree of cliques of a Bayes Chain.
Base class for conditional densities.
Global functions in a separate testing namespace.
Definition chartTesting.h:28
string html(const DiscreteValues &values, const KeyFormatter &keyFormatter, const DiscreteValues::Names &names)
Free version of html.
Definition DiscreteValues.cpp:160
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition Key.cpp:30
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
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition Group.h:37
Template to create a binary predicate.
Definition Testable.h:112
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:152
A clique in a DiscreteBayesTree.
Definition DiscreteBayesTree.h:40
void printSignature(const std::string &s="Clique: ", const KeyFormatter &formatter=DefaultKeyFormatter) const
print index signature only
Definition DiscreteBayesTree.h:53
A Bayes tree representing a Discrete distribution.
Definition DiscreteBayesTree.h:74
DiscreteBayesTree()
Default constructor, creates an empty Bayes tree.
Definition DiscreteBayesTree.h:85
Discrete Conditional Density Derives from DecisionTreeFactor.
Definition DiscreteConditional.h:40
A map from keys to values.
Definition DiscreteValues.h:34
BayesTree()
Definition BayesTree.h:119
const sharedConditional & conditional() const
Definition BayesTreeCliqueBase.h:140
VectorValues represents a collection of vector-valued variables associated each with a unique integer...
Definition VectorValues.h:73