Loading...
Searching...
No Matches
DiscreteBayesTree.h
Go to the documentation of this file.
/* ----------------------------------------------------------------------------
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
* Atlanta, Georgia 30332-0415
* All Rights Reserved
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
* See LICENSE for the license information
* -------------------------------------------------------------------------- */
#pragma once
#include <gtsam/discrete/DiscreteBayesNet.h>
#include <gtsam/discrete/DiscreteFactorGraph.h>
#include <gtsam/inference/BayesTree.h>
#include <gtsam/inference/Conditional.h>
#include <gtsam/inference/BayesTreeCliqueBase.h>
#include <string>
namespace gtsam {
// Forward declarations
class DiscreteConditional;
class VectorValues;
/* ************************************************************************* */
class GTSAM_EXPORT DiscreteBayesTreeClique
: public BayesTreeCliqueBase<DiscreteBayesTreeClique, DiscreteFactorGraph> {
public:
typedef DiscreteBayesTreeClique This;
typedef BayesTreeCliqueBase<DiscreteBayesTreeClique, DiscreteFactorGraph>
Base;
typedef boost::shared_ptr<This> shared_ptr;
typedef boost::weak_ptr<This> weak_ptr;
DiscreteBayesTreeClique() {}
virtual ~DiscreteBayesTreeClique() {}
DiscreteBayesTreeClique(
const boost::shared_ptr<DiscreteConditional>& conditional)
: Base(conditional) {}
void printSignature(
const std::string& s = "Clique: ",
const KeyFormatter& formatter = DefaultKeyFormatter) const {
conditional_->printSignature(s, formatter);
}
//** evaluate conditional probability of subtree for given DiscreteValues */
double evaluate(const DiscreteValues& values) const;
//** (Preferred) sugar for the above for given DiscreteValues */
double operator()(const DiscreteValues& values) const {
return evaluate(values);
}
};
/* ************************************************************************* */
class GTSAM_EXPORT DiscreteBayesTree
: public BayesTree<DiscreteBayesTreeClique> {
private:
typedef BayesTree<DiscreteBayesTreeClique> Base;
public:
typedef DiscreteBayesTree This;
typedef boost::shared_ptr<This> shared_ptr;
DiscreteBayesTree() {}
bool equals(const This& other, double tol = 1e-9) const;
//** evaluate probability for given DiscreteValues */
double evaluate(const DiscreteValues& values) const;
//** (Preferred) sugar for the above for given DiscreteValues */
double operator()(const DiscreteValues& values) const {
return evaluate(values);
}
std::string markdown(const KeyFormatter& keyFormatter = DefaultKeyFormatter,
const DiscreteFactor::Names& names = {}) const;
std::string html(const KeyFormatter& keyFormatter = DefaultKeyFormatter,
const DiscreteFactor::Names& names = {}) const;
};
} // namespace gtsam
DiscreteBayesNet.h
DiscreteFactorGraph.h
BayesTreeCliqueBase.h
Base class for cliques of a BayesTree.
BayesTree.h
Bayes Tree is a tree of cliques of a Bayes Chain.
Conditional.h
Base class for conditional densities.
gtsam
Global functions in a separate testing namespace.
Definition chartTesting.h:28
gtsam::html
string html(const DiscreteValues &values, const KeyFormatter &keyFormatter, const DiscreteValues::Names &names)
Free version of html.
Definition DiscreteValues.cpp:134
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::equals
Template to create a binary predicate.
Definition Testable.h:111
gtsam::DiscreteBayesTreeClique::printSignature
void printSignature(const std::string &s="Clique: ", const KeyFormatter &formatter=DefaultKeyFormatter) const
print index signature only
Definition DiscreteBayesTree.h:54
gtsam::DiscreteBayesTree::DiscreteBayesTree
DiscreteBayesTree()
Default constructor, creates an empty Bayes tree.
Definition DiscreteBayesTree.h:86
gtsam::DiscreteConditional
Discrete Conditional Density Derives from DecisionTreeFactor.
Definition DiscreteConditional.h:40
gtsam::DiscreteValues
A map from keys to values.
Definition DiscreteValues.h:34
gtsam::BayesTree< DiscreteBayesTreeClique >::BayesTree
BayesTree()
Definition BayesTree.h:109
gtsam::BayesTreeCliqueBase< DiscreteBayesTreeClique, DiscreteFactorGraph >::BayesTreeCliqueBase
BayesTreeCliqueBase()
Definition BayesTreeCliqueBase.h:74
gtsam::BayesTreeCliqueBase< DiscreteBayesTreeClique, DiscreteFactorGraph >::conditional
const sharedConditional & conditional() const
Definition BayesTreeCliqueBase.h:141
gtsam::VectorValues
VectorValues represents a collection of vector-valued variables associated each with a unique integer...
Definition VectorValues.h:74