Loading...
Searching...
No Matches
HybridBayesTree.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/hybrid/HybridBayesNet.h>
#include <gtsam/hybrid/HybridGaussianFactorGraph.h>
#include <gtsam/inference/BayesTree.h>
#include <gtsam/inference/BayesTreeCliqueBase.h>
#include <gtsam/inference/Conditional.h>
#include <gtsam/linear/GaussianBayesTree.h>
#include <string>
namespace gtsam {
// Forward declarations
class HybridConditional;
class VectorValues;
/* ************************************************************************* */
class GTSAM_EXPORT HybridBayesTreeClique
: public BayesTreeCliqueBase<HybridBayesTreeClique,
HybridGaussianFactorGraph> {
public:
typedef HybridBayesTreeClique This;
typedef BayesTreeCliqueBase<HybridBayesTreeClique, HybridGaussianFactorGraph>
Base;
typedef boost::shared_ptr<This> shared_ptr;
typedef boost::weak_ptr<This> weak_ptr;
HybridBayesTreeClique() {}
HybridBayesTreeClique(const boost::shared_ptr<HybridConditional>& conditional)
: Base(conditional) {}
HybridBayesTreeClique(const HybridBayesTreeClique& clique) : Base(clique) {}
virtual ~HybridBayesTreeClique() {}
};
/* ************************************************************************* */
class GTSAM_EXPORT HybridBayesTree : public BayesTree<HybridBayesTreeClique> {
private:
typedef BayesTree<HybridBayesTreeClique> Base;
public:
typedef HybridBayesTree This;
typedef boost::shared_ptr<This> shared_ptr;
HybridBayesTree() = default;
bool equals(const This& other, double tol = 1e-9) const;
GaussianBayesTree choose(const DiscreteValues& assignment) const;
HybridValues optimize() const;
VectorValues optimize(const DiscreteValues& assignment) const;
void prune(const size_t maxNumberLeaves);
private:
friend class boost::serialization::access;
template <class ARCHIVE>
void serialize(ARCHIVE& ar, const unsigned int /*version*/) {
ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
}
};
template <>
struct traits<HybridBayesTree> : public Testable<HybridBayesTree> {};
template <>
class BayesTreeOrphanWrapper<HybridBayesTreeClique> : public HybridConditional {
public:
typedef HybridBayesTreeClique CliqueType;
typedef HybridConditional Base;
boost::shared_ptr<CliqueType> clique;
BayesTreeOrphanWrapper(const boost::shared_ptr<CliqueType>& clique)
: clique(clique) {
// Store parent keys in our base type factor so that eliminating those
// parent keys will pull this subtree into the elimination.
this->keys_.assign(clique->conditional()->beginParents(),
clique->conditional()->endParents());
this->discreteKeys_.assign(clique->conditional()->discreteKeys().begin(),
clique->conditional()->discreteKeys().end());
}
void print(
const std::string& s = "",
const KeyFormatter& formatter = DefaultKeyFormatter) const override {
clique->print(s + "stored clique", formatter);
}
};
} // namespace gtsam
HybridBayesNet.h
A Bayes net of Gaussian Conditionals indexed by discrete keys.
HybridGaussianFactorGraph.h
Linearized Hybrid factor graph that uses type erasure.
BayesTreeCliqueBase.h
Base class for cliques of a BayesTree.
Conditional.h
Base class for conditional densities.
BayesTree.h
Bayes Tree is a tree of cliques of a Bayes Chain.
GaussianBayesTree.h
Gaussian Bayes Tree, the result of eliminating a GaussianJunctionTree.
gtsam
Global functions in a separate testing namespace.
Definition chartTesting.h:28
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::traits
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition concepts.h:30
gtsam::Testable
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:151
gtsam::DiscreteValues
A map from keys to values.
Definition DiscreteValues.h:34
gtsam::HybridBayesTreeClique
A clique in a HybridBayesTree which is a HybridConditional internally.
Definition HybridBayesTree.h:46
gtsam::HybridBayesTreeClique::HybridBayesTreeClique
HybridBayesTreeClique(const boost::shared_ptr< HybridConditional > &conditional)
Copy constructor.
Definition HybridBayesTree.h:54
gtsam::HybridBayesTree
A Bayes tree representing a Hybrid density.
Definition HybridBayesTree.h:64
gtsam::HybridBayesTree::prune
void prune(const size_t maxNumberLeaves)
Prune the underlying Bayes tree.
Definition HybridBayesTree.cpp:175
gtsam::HybridBayesTree::optimize
HybridValues optimize() const
Optimize the hybrid Bayes tree by computing the MPE for the current set of discrete variables and usi...
Definition HybridBayesTree.cpp:42
gtsam::HybridBayesTree::choose
GaussianBayesTree choose(const DiscreteValues &assignment) const
Get the Gaussian Bayes Tree which corresponds to a specific discrete value assignment.
Definition HybridBayesTree.cpp:141
gtsam::HybridBayesTree::HybridBayesTree
HybridBayesTree()=default
Default constructor, creates an empty Bayes tree.
gtsam::HybridBayesTree::equals
bool equals(const This &other, double tol=1e-9) const
Check equality.
Definition HybridBayesTree.cpp:37
gtsam::BayesTreeOrphanWrapper< HybridBayesTreeClique >::BayesTreeOrphanWrapper
BayesTreeOrphanWrapper(const boost::shared_ptr< CliqueType > &clique)
Construct a new Bayes Tree Orphan Wrapper object.
Definition HybridBayesTree.h:152
gtsam::BayesTreeOrphanWrapper< HybridBayesTreeClique >::print
void print(const std::string &s="", const KeyFormatter &formatter=DefaultKeyFormatter) const override
print utility
Definition HybridBayesTree.h:163
gtsam::HybridConditional
Hybrid Conditional Density.
Definition HybridConditional.h:62
gtsam::HybridConditional::HybridConditional
HybridConditional()=default
Default constructor needed for serialization.
gtsam::HybridValues
HybridValues represents a collection of DiscreteValues and VectorValues.
Definition HybridValues.h:38
gtsam::BayesTree< HybridBayesTreeClique >::BayesTree
BayesTree()
Definition BayesTree.h:109
gtsam::BayesTreeCliqueBase< HybridBayesTreeClique, HybridGaussianFactorGraph >::BayesTreeCliqueBase
BayesTreeCliqueBase()
Definition BayesTreeCliqueBase.h:74
gtsam::BayesTreeCliqueBase< HybridBayesTreeClique, HybridGaussianFactorGraph >::conditional
const sharedConditional & conditional() const
Definition BayesTreeCliqueBase.h:141
gtsam::Factor::keys_
KeyVector keys_
The keys involved in this factor.
Definition Factor.h:85
gtsam::GaussianBayesTree
A Bayes tree representing a Gaussian density.
Definition GaussianBayesTree.h:52
gtsam::VectorValues
VectorValues represents a collection of vector-valued variables associated each with a unique integer...
Definition VectorValues.h:74