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 
31 namespace gtsam {
32 
33 // Forward declarations
34 class HybridConditional;
35 class VectorValues;
36 
37 /* ************************************************************************* */
44 class GTSAM_EXPORT HybridBayesTreeClique
45  : public BayesTreeCliqueBase<HybridBayesTreeClique,
46  HybridGaussianFactorGraph> {
47  public:
51  typedef std::shared_ptr<This> shared_ptr;
52  typedef std::weak_ptr<This> weak_ptr;
54  HybridBayesTreeClique(const std::shared_ptr<HybridConditional>& conditional)
55  : Base(conditional) {}
57  HybridBayesTreeClique(const HybridBayesTreeClique& clique) : Base(clique) {}
58 };
59 
60 /* ************************************************************************* */
62 class GTSAM_EXPORT HybridBayesTree : public BayesTree<HybridBayesTreeClique> {
63  private:
65 
66  public:
68  typedef std::shared_ptr<This> shared_ptr;
69 
72 
73  HybridBayesTree() = default;
74 
76  bool equals(const This& other, double tol = 1e-9) const;
77 
85  GaussianBayesTree choose(const DiscreteValues& assignment) const;
86 
94  HybridValues optimize() const;
95 
103  VectorValues optimize(const DiscreteValues& assignment) const;
104 
110  void prune(const size_t maxNumberLeaves);
111 
113 
114  private:
115 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION
116 
117  friend class boost::serialization::access;
118  template <class ARCHIVE>
119  void serialize(ARCHIVE& ar, const unsigned int /*version*/) {
120  ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
121  }
122 #endif
123 };
124 
126 template <>
127 struct traits<HybridBayesTree> : public Testable<HybridBayesTree> {};
128 
139 template <>
141  public:
144 
145  std::shared_ptr<CliqueType> clique;
146 
152  BayesTreeOrphanWrapper(const std::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
A clique in a HybridBayesTree which is a HybridConditional internally.
Base class for conditional densities.
BayesTreeOrphanWrapper(const std::shared_ptr< CliqueType > &clique)
Construct a new Bayes Tree Orphan Wrapper object.
std::string serialize(const T &input)
serializes to a string
std::shared_ptr< This > shared_ptr
static const T & choose(int layout, const T &col, const T &row)
HybridBayesTreeClique(const std::shared_ptr< HybridConditional > &conditional)
Copy constructor.
static const KeyFormatter DefaultKeyFormatter
Definition: Key.h:43
std::weak_ptr< This > weak_ptr
const KeyFormatter & formatter
A Bayes net of Gaussian Conditionals indexed by discrete keys.
HybridBayesTreeClique This
Point3 optimize(const NonlinearFactorGraph &graph, const Values &values, Key landmarkKey)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
RealScalar s
void print(const std::string &s="", const KeyFormatter &formatter=DefaultKeyFormatter) const override
print utility
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
Linearized Hybrid factor graph that uses type erasure.
Bayes Tree is a tree of cliques of a Bayes Chain.
HybridBayesTree This
traits
Definition: chartTesting.h:28
HybridBayesTreeClique(const HybridBayesTreeClique &clique)
std::shared_ptr< This > shared_ptr
BayesTree< HybridBayesTreeClique > Base
const G double tol
Definition: Group.h:86
BayesTreeCliqueBase< HybridBayesTreeClique, HybridGaussianFactorGraph > Base
Gaussian Bayes Tree, the result of eliminating a GaussianJunctionTree.
Base class for cliques of a BayesTree.


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:20