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<HybridBayesTreeClique> : public Testable<HybridBayesTreeClique> {
128 };
129 
130 template <>
131 struct traits<HybridBayesTree> : public Testable<HybridBayesTree> {};
132 
143 template <>
145  public:
148 
149  std::shared_ptr<CliqueType> clique;
150 
156  BayesTreeOrphanWrapper(const std::shared_ptr<CliqueType>& clique)
157  : clique(clique) {
158  // Store parent keys in our base type factor so that eliminating those
159  // parent keys will pull this subtree into the elimination.
160  this->keys_.assign(clique->conditional()->beginParents(),
161  clique->conditional()->endParents());
162  this->discreteKeys_.assign(clique->conditional()->discreteKeys().begin(),
163  clique->conditional()->discreteKeys().end());
164  }
165 
167  void print(
168  const std::string& s = "",
169  const KeyFormatter& formatter = DefaultKeyFormatter) const override {
170  clique->print(s + "stored clique", formatter);
171  }
172 };
173 
174 } // namespace gtsam
gtsam::BayesTreeOrphanWrapper< HybridBayesTreeClique >::clique
std::shared_ptr< CliqueType > clique
Definition: HybridBayesTree.h:149
gtsam::BayesTreeOrphanWrapper
Definition: BayesTree.h:281
VectorValues
gtsam::BayesTreeOrphanWrapper< HybridBayesTreeClique >::print
void print(const std::string &s="", const KeyFormatter &formatter=DefaultKeyFormatter) const override
print utility
Definition: HybridBayesTree.h:167
gtsam::HybridValues
Definition: HybridValues.h:38
gtsam::HybridBayesTreeClique::weak_ptr
std::weak_ptr< This > weak_ptr
Definition: HybridBayesTree.h:52
gtsam::HybridBayesTreeClique::shared_ptr
std::shared_ptr< This > shared_ptr
Definition: HybridBayesTree.h:51
gtsam::HybridConditional
Definition: HybridConditional.h:59
s
RealScalar s
Definition: level1_cplx_impl.h:126
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
gtsam::HybridBayesTreeClique::HybridBayesTreeClique
HybridBayesTreeClique(const HybridBayesTreeClique &clique)
Definition: HybridBayesTree.h:57
BayesTree.h
Bayes Tree is a tree of cliques of a Bayes Chain.
gtsam::BayesTreeOrphanWrapper::clique
std::shared_ptr< CliqueType > clique
Definition: BayesTree.h:286
gtsam::optimize
Point3 optimize(const NonlinearFactorGraph &graph, const Values &values, Key landmarkKey)
Definition: triangulation.cpp:177
gtsam::HybridBayesTree
Definition: HybridBayesTree.h:62
gtsam::BayesTreeOrphanWrapper< HybridBayesTreeClique >::CliqueType
HybridBayesTreeClique CliqueType
Definition: HybridBayesTree.h:146
formatter
const KeyFormatter & formatter
Definition: treeTraversal-inst.h:204
HybridBayesNet.h
A Bayes net of Gaussian Conditionals indexed by discrete keys.
BayesTreeCliqueBase.h
Base class for cliques of a BayesTree.
gtsam::DefaultKeyFormatter
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition: Key.cpp:30
gtsam::HybridBayesTree::Base
BayesTree< HybridBayesTreeClique > Base
Definition: HybridBayesTree.h:64
gtsam::HybridBayesTreeClique
A clique in a HybridBayesTree which is a HybridConditional internally.
Definition: HybridBayesTree.h:44
gtsam::VectorValues
Definition: VectorValues.h:74
gtsam::BayesTreeCliqueBase
Definition: BayesTreeCliqueBase.h:49
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::HybridBayesTreeClique::Base
BayesTreeCliqueBase< HybridBayesTreeClique, HybridGaussianFactorGraph > Base
Definition: HybridBayesTree.h:50
gtsam::equals
Definition: Testable.h:112
HybridGaussianFactorGraph.h
Linearized Hybrid factor graph that uses type erasure.
gtsam
traits
Definition: chartTesting.h:28
gtsam::Testable
Definition: Testable.h:152
gtsam::BayesTree
Definition: BayesTree.h:66
gtsam::GaussianBayesTree
Definition: GaussianBayesTree.h:49
gtsam::traits
Definition: Group.h:36
gtsam::DiscreteValues
Definition: DiscreteValues.h:34
gtsam::HybridBayesTreeClique::HybridBayesTreeClique
HybridBayesTreeClique()
Definition: HybridBayesTree.h:53
GaussianBayesTree.h
Gaussian Bayes Tree, the result of eliminating a GaussianJunctionTree.
gtsam::tol
const G double tol
Definition: Group.h:79
gtsam::BayesTreeOrphanWrapper< HybridBayesTreeClique >::Base
HybridConditional Base
Definition: HybridBayesTree.h:147
gtsam::HybridBayesTreeClique::This
HybridBayesTreeClique This
Definition: HybridBayesTree.h:48
gtsam::BayesTreeOrphanWrapper< HybridBayesTreeClique >::BayesTreeOrphanWrapper
BayesTreeOrphanWrapper(const std::shared_ptr< CliqueType > &clique)
Construct a new Bayes Tree Orphan Wrapper object.
Definition: HybridBayesTree.h:156
Base
Definition: test_virtual_functions.cpp:156
Conditional.h
Base class for conditional densities.
choose
static const T & choose(int layout, const T &col, const T &row)
Definition: cxx11_tensor_block_access.cpp:27
pybind_wrapper_test_script.other
other
Definition: pybind_wrapper_test_script.py:42
gtsam::HybridBayesTree::shared_ptr
std::shared_ptr< This > shared_ptr
Definition: HybridBayesTree.h:68
gtsam::HybridBayesTree::This
HybridBayesTree This
Definition: HybridBayesTree.h:67


gtsam
Author(s):
autogenerated on Tue Jun 25 2024 03:01:00