HybridBayesNet.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
3  * Atlanta, Georgia 30332-0415
4  * All Rights Reserved
5  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
6  * See LICENSE for the license information
7  * -------------------------------------------------------------------------- */
8 
18 #pragma once
19 
21 #include <gtsam/global_includes.h>
26 
27 namespace gtsam {
28 
35 class GTSAM_EXPORT HybridBayesNet : public BayesNet<HybridConditional> {
36  public:
40  using shared_ptr = std::shared_ptr<HybridBayesNet>;
41  using sharedConditional = std::shared_ptr<ConditionalType>;
42 
45 
47  HybridBayesNet() = default;
48 
52 
54  void print(const std::string &s = "", const KeyFormatter &formatter =
55  DefaultKeyFormatter) const override;
56 
58  bool equals(const This &fg, double tol = 1e-9) const;
59 
63 
69  void push_back(std::shared_ptr<HybridConditional> conditional) {
70  factors_.push_back(conditional);
71  }
72 
81  template <class Conditional>
82  void emplace_back(Conditional *conditional) {
83  factors_.push_back(std::make_shared<HybridConditional>(
84  std::shared_ptr<Conditional>(conditional)));
85  }
86 
99  void push_back(HybridConditional &&conditional) {
100  factors_.push_back(
101  std::make_shared<HybridConditional>(std::move(conditional)));
102  }
103 
111  GaussianBayesNet choose(const DiscreteValues &assignment) const;
112 
114  double evaluate(const HybridValues &values) const;
115 
117  double operator()(const HybridValues &values) const {
118  return evaluate(values);
119  }
120 
128  HybridValues optimize() const;
129 
137  VectorValues optimize(const DiscreteValues &assignment) const;
138 
144  DecisionTreeFactor::shared_ptr discreteConditionals() const;
145 
158  HybridValues sample(const HybridValues &given, std::mt19937_64 *rng) const;
159 
170  HybridValues sample(std::mt19937_64 *rng) const;
171 
178  HybridValues sample(const HybridValues &given) const;
179 
185  HybridValues sample() const;
186 
188  HybridBayesNet prune(size_t maxNrLeaves);
189 
197  AlgebraicDecisionTree<Key> logProbability(
198  const VectorValues &continuousValues) const;
199 
200  using BayesNet::logProbability; // expose HybridValues version
201 
213  const VectorValues &continuousValues) const;
214 
219  HybridGaussianFactorGraph toFactorGraph(
220  const VectorValues &measurements) const;
222 
223  private:
229  void updateDiscreteConditionals(const DecisionTreeFactor &prunedDecisionTree);
230 
231 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION
232 
233  friend class boost::serialization::access;
234  template <class ARCHIVE>
235  void serialize(ARCHIVE &ar, const unsigned int /*version*/) {
236  ar &BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
237  }
238 #endif
239 };
240 
242 template <>
243 struct traits<HybridBayesNet> : public Testable<HybridBayesNet> {};
244 
245 } // namespace gtsam
void print(const Matrix &A, const string &s, ostream &stream)
Definition: Matrix.cpp:155
std::string serialize(const T &input)
serializes to a string
std::shared_ptr< ConditionalType > sharedConditional
static std::mt19937 rng
static const T & choose(int layout, const T &col, const T &row)
leaf::MyValues values
Bayes network.
static const KeyFormatter DefaultKeyFormatter
Definition: Key.h:43
const KeyFormatter & formatter
Included from all GTSAM files.
Point3 optimize(const NonlinearFactorGraph &graph, const Values &values, Key landmarkKey)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
RealScalar s
double operator()(const HybridValues &values) const
Evaluate hybrid probability density for given HybridValues, sugar.
void push_back(std::shared_ptr< HybridConditional > conditional)
Add a hybrid conditional using a shared_ptr.
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
void push_back(HybridConditional &&conditional)
void emplace_back(Conditional *conditional)
traits
Definition: chartTesting.h:28
std::shared_ptr< DecisionTreeFactor > shared_ptr
double logProbability(const HybridValues &x) const
Definition: BayesNet-inst.h:94
Chordal Bayes Net, the result of eliminating a factor graph.
const G double tol
Definition: Group.h:86
std::shared_ptr< HybridBayesNet > shared_ptr


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