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 
88  double error(const HybridValues& values) const;
89 
97  HybridValues optimize() const;
98 
106  VectorValues optimize(const DiscreteValues& assignment) const;
107 
113  void prune(const size_t maxNumberLeaves);
114 
116 
117  private:
118 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION
119 
120  friend class boost::serialization::access;
121  template <class ARCHIVE>
122  void serialize(ARCHIVE& ar, const unsigned int /*version*/) {
123  ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
124  }
125 #endif
126 };
127 
129 template <>
130 struct traits<HybridBayesTreeClique> : public Testable<HybridBayesTreeClique> {
131 };
132 
133 template <>
134 struct traits<HybridBayesTree> : public Testable<HybridBayesTree> {};
135 
146 template <>
148  public:
151 
152  std::shared_ptr<CliqueType> clique;
153 
159  BayesTreeOrphanWrapper(const std::shared_ptr<CliqueType>& clique)
160  : clique(clique) {
161  // Store parent keys in our base type factor so that eliminating those
162  // parent keys will pull this subtree into the elimination.
163  this->keys_.assign(clique->conditional()->beginParents(),
164  clique->conditional()->endParents());
165  this->discreteKeys_.assign(clique->conditional()->discreteKeys().begin(),
166  clique->conditional()->discreteKeys().end());
167  }
168 
170  void print(
171  const std::string& s = "",
172  const KeyFormatter& formatter = DefaultKeyFormatter) const override {
173  clique->print(s + " stored clique ", formatter);
174  }
175 };
176 
177 } // namespace gtsam
gtsam::BayesTreeOrphanWrapper< HybridBayesTreeClique >::clique
std::shared_ptr< CliqueType > clique
Definition: HybridBayesTree.h:152
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:170
gtsam::HybridValues
Definition: HybridValues.h:37
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:60
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:149
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.
different_sigmas::values
HybridValues values
Definition: testHybridBayesNet.cpp:245
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: SFMdata.h:40
gtsam::Testable
Definition: Testable.h:152
gtsam::BayesTree
Definition: BayesTree.h:66
gtsam::GaussianBayesTree
Definition: GaussianBayesTree.h:49
error
static double error
Definition: testRot3.cpp:37
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:150
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:159
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 Fri Nov 1 2024 03:32:43