gtsam 4.2.0
gtsam
Loading...
Searching...
No Matches
HybridBayesTree.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#pragma once
21
28
29#include <string>
30
31namespace gtsam {
32
33// Forward declarations
34class HybridConditional;
35class VectorValues;
36
37/* ************************************************************************* */
44class GTSAM_EXPORT HybridBayesTreeClique
45 : public BayesTreeCliqueBase<HybridBayesTreeClique,
46 HybridGaussianFactorGraph> {
47 public:
50 Base;
51 typedef boost::shared_ptr<This> shared_ptr;
52 typedef boost::weak_ptr<This> weak_ptr;
54 HybridBayesTreeClique(const boost::shared_ptr<HybridConditional>& conditional)
55 : Base(conditional) {}
57 HybridBayesTreeClique(const HybridBayesTreeClique& clique) : Base(clique) {}
58
59 virtual ~HybridBayesTreeClique() {}
60};
61
62/* ************************************************************************* */
64class GTSAM_EXPORT HybridBayesTree : public BayesTree<HybridBayesTreeClique> {
65 private:
67
68 public:
69 typedef HybridBayesTree This;
70 typedef boost::shared_ptr<This> shared_ptr;
71
74
75 HybridBayesTree() = default;
76
78 bool equals(const This& other, double tol = 1e-9) const;
79
87 GaussianBayesTree choose(const DiscreteValues& assignment) const;
88
96 HybridValues optimize() const;
97
105 VectorValues optimize(const DiscreteValues& assignment) const;
106
112 void prune(const size_t maxNumberLeaves);
113
115
116 private:
118 friend class boost::serialization::access;
119 template <class ARCHIVE>
120 void serialize(ARCHIVE& ar, const unsigned int /*version*/) {
121 ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
122 }
123};
124
126template <>
127struct traits<HybridBayesTree> : public Testable<HybridBayesTree> {};
128
139template <>
141 public:
143 typedef HybridConditional Base;
144
145 boost::shared_ptr<CliqueType> clique;
146
152 BayesTreeOrphanWrapper(const boost::shared_ptr<CliqueType>& clique)
153 : clique(clique) {
154 // Store parent keys in our base type factor so that eliminating those
155 // parent keys will pull this subtree into the elimination.
156 this->keys_.assign(clique->conditional()->beginParents(),
157 clique->conditional()->endParents());
158 this->discreteKeys_.assign(clique->conditional()->discreteKeys().begin(),
159 clique->conditional()->discreteKeys().end());
160 }
161
163 void print(
164 const std::string& s = "",
165 const KeyFormatter& formatter = DefaultKeyFormatter) const override {
166 clique->print(s + "stored clique", formatter);
167 }
168};
169
170} // namespace gtsam
Linearized Hybrid factor graph that uses type erasure.
A Bayes net of Gaussian Conditionals indexed by discrete keys.
Base class for conditional densities.
Base class for cliques of a BayesTree.
Bayes Tree is a tree of cliques of a Bayes Chain.
Gaussian Bayes Tree, the result of eliminating a GaussianJunctionTree.
Global functions in a separate testing namespace.
Definition chartTesting.h:28
Point3 optimize(const NonlinearFactorGraph &graph, const Values &values, Key landmarkKey)
Optimize for triangulation.
Definition triangulation.cpp:155
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 concepts.h:30
Template to create a binary predicate.
Definition Testable.h:111
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:151
A map from keys to values.
Definition DiscreteValues.h:34
A clique in a HybridBayesTree which is a HybridConditional internally.
Definition HybridBayesTree.h:46
HybridBayesTreeClique(const boost::shared_ptr< HybridConditional > &conditional)
Copy constructor.
Definition HybridBayesTree.h:54
A Bayes tree representing a Hybrid density.
Definition HybridBayesTree.h:64
HybridBayesTree()=default
Default constructor, creates an empty Bayes tree.
BayesTreeOrphanWrapper(const boost::shared_ptr< CliqueType > &clique)
Construct a new Bayes Tree Orphan Wrapper object.
Definition HybridBayesTree.h:152
void print(const std::string &s="", const KeyFormatter &formatter=DefaultKeyFormatter) const override
print utility
Definition HybridBayesTree.h:163
Hybrid Conditional Density.
Definition HybridConditional.h:62
HybridValues represents a collection of DiscreteValues and VectorValues.
Definition HybridValues.h:38
Bayes tree.
Definition BayesTree.h:67
Definition BayesTree.h:276
This is the base class for BayesTree cliques.
Definition BayesTreeCliqueBase.h:50
A Bayes tree representing a Gaussian density.
Definition GaussianBayesTree.h:52
VectorValues represents a collection of vector-valued variables associated each with a unique integer...
Definition VectorValues.h:74
The Factor::error simply extracts the.