gtsam 4.2.0
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
21#pragma once
22
28
29#include <string>
30
31namespace gtsam {
32
33// Forward declarations
34class DiscreteConditional;
35class VectorValues;
36
37/* ************************************************************************* */
39class GTSAM_EXPORT DiscreteBayesTreeClique
40 : public BayesTreeCliqueBase<DiscreteBayesTreeClique, DiscreteFactorGraph> {
41 public:
44 Base;
45 typedef boost::shared_ptr<This> shared_ptr;
46 typedef boost::weak_ptr<This> weak_ptr;
48 virtual ~DiscreteBayesTreeClique() {}
50 const boost::shared_ptr<DiscreteConditional>& conditional)
51 : Base(conditional) {}
52
55 const std::string& s = "Clique: ",
56 const KeyFormatter& formatter = DefaultKeyFormatter) const {
57 conditional_->printSignature(s, formatter);
58 }
59
60 //** evaluate conditional probability of subtree for given DiscreteValues */
61 double evaluate(const DiscreteValues& values) const;
62
63 //** (Preferred) sugar for the above for given DiscreteValues */
64 double operator()(const DiscreteValues& values) const {
65 return evaluate(values);
66 }
67};
68
69/* ************************************************************************* */
74class GTSAM_EXPORT DiscreteBayesTree
75 : public BayesTree<DiscreteBayesTreeClique> {
76 private:
78
79 public:
80 typedef DiscreteBayesTree This;
81 typedef boost::shared_ptr<This> shared_ptr;
82
85
87
89 bool equals(const This& other, double tol = 1e-9) const;
90
91 //** evaluate probability for given DiscreteValues */
92 double evaluate(const DiscreteValues& values) const;
93
94 //** (Preferred) sugar for the above for given DiscreteValues */
95 double operator()(const DiscreteValues& values) const {
96 return evaluate(values);
97 }
98
102
104 std::string markdown(const KeyFormatter& keyFormatter = DefaultKeyFormatter,
105 const DiscreteFactor::Names& names = {}) const;
106
108 std::string html(const KeyFormatter& keyFormatter = DefaultKeyFormatter,
109 const DiscreteFactor::Names& names = {}) const;
110
112};
113
114} // namespace gtsam
Base class for cliques of a BayesTree.
Base class for conditional densities.
Bayes Tree is a tree of cliques of a Bayes Chain.
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:134
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
Template to create a binary predicate.
Definition Testable.h:111
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:54
A Bayes tree representing a Discrete density.
Definition DiscreteBayesTree.h:75
DiscreteBayesTree()
Default constructor, creates an empty Bayes tree.
Definition DiscreteBayesTree.h:86
A map from keys to values.
Definition DiscreteValues.h:34
Bayes tree.
Definition BayesTree.h:67
This is the base class for BayesTree cliques.
Definition BayesTreeCliqueBase.h:50
The Factor::error simply extracts the.