HybridGaussianConditional.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 
21 #pragma once
22 
31 
32 namespace gtsam {
33 
34 class HybridValues;
35 
54 class GTSAM_EXPORT HybridGaussianConditional
55  : public HybridGaussianFactor,
56  public Conditional<HybridGaussianFactor, HybridGaussianConditional> {
57  public:
59  using shared_ptr = std::shared_ptr<This>;
62 
65 
66  private:
70 
71  public:
74 
76  HybridGaussianConditional() = default;
77 
86  const DiscreteKey &discreteParent,
87  const std::vector<GaussianConditional::shared_ptr> &conditionals);
88 
98  const DiscreteKey &discreteParent, Key key,
99  const std::vector<std::pair<Vector, double>> &parameters);
100 
112  const DiscreteKey &discreteParent, Key key, const Matrix &A, Key parent,
113  const std::vector<std::pair<Vector, double>> &parameters);
114 
128  const DiscreteKey &discreteParent, Key key, //
129  const Matrix &A1, Key parent1, const Matrix &A2, Key parent2,
130  const std::vector<std::pair<Vector, double>> &parameters);
131 
141  HybridGaussianConditional(const DiscreteKeys &discreteParents,
142  const Conditionals &conditionals);
143 
154  HybridGaussianConditional(const DiscreteKeys &discreteParents,
155  const FactorValuePairs &pairs);
156 
160 
162  bool equals(const HybridFactor &lf, double tol = 1e-9) const override;
163 
165  void print(
166  const std::string &s = "HybridGaussianConditional\n",
167  const KeyFormatter &formatter = DefaultKeyFormatter) const override;
168 
172 
175  const DiscreteValues &discreteValues) const;
176 
179  const DiscreteValues &discreteValues) const {
180  return choose(discreteValues);
181  }
182 
184  size_t nrComponents() const;
185 
187  KeyVector continuousParents() const;
188 
197  inline double negLogConstant() const override { return negLogConstant_; }
198 
203  std::shared_ptr<HybridGaussianFactor> likelihood(
204  const VectorValues &given) const;
205 
208  const Conditionals conditionals() const;
209 
216  double logProbability(const HybridValues &values) const override;
217 
219  double evaluate(const HybridValues &values) const override;
220 
222  double operator()(const HybridValues &values) const {
223  return evaluate(values);
224  }
225 
234  const DecisionTreeFactor &discreteProbs) const;
235 
237 
238  private:
240  struct Helper;
241 
243  HybridGaussianConditional(const DiscreteKeys &discreteParents,
244  Helper &&helper);
245 
247  bool allFrontalsGiven(const VectorValues &given) const;
248 
249 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION
250 
251  friend class boost::serialization::access;
252  template <class Archive>
253  void serialize(Archive &ar, const unsigned int /*version*/) {
254  ar &BOOST_SERIALIZATION_BASE_OBJECT_NVP(BaseFactor);
255  ar &BOOST_SERIALIZATION_BASE_OBJECT_NVP(BaseConditional);
256  }
257 #endif
258 };
259 
261 std::set<DiscreteKey> DiscreteKeysAsSet(const DiscreteKeys &discreteKeys);
262 
263 // traits
264 template <>
266  : public Testable<HybridGaussianConditional> {};
267 
268 } // namespace gtsam
gtsam::DecisionTreeFactor
Definition: DecisionTreeFactor.h:44
gtsam::HybridValues
Definition: HybridValues.h:37
GaussianConditional.h
Conditional Gaussian Base class.
gtsam::HybridGaussianConditional::shared_ptr
std::shared_ptr< This > shared_ptr
Definition: HybridGaussianConditional.h:59
s
RealScalar s
Definition: level1_cplx_impl.h:126
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
gtsam::HybridFactor
Definition: HybridFactor.h:51
gtsam::HybridFactor::shared_ptr
std::shared_ptr< HybridFactor > shared_ptr
shared_ptr to this class
Definition: HybridFactor.h:70
formatter
const KeyFormatter & formatter
Definition: treeTraversal-inst.h:204
gtsam::Matrix
Eigen::MatrixXd Matrix
Definition: base/Matrix.h:39
different_sigmas::values
HybridValues values
Definition: testHybridBayesNet.cpp:245
gtsam::DiscreteKeys
DiscreteKeys is a set of keys that can be assembled using the & operator.
Definition: DiscreteKey.h:41
HybridValues
gtsam::KeyVector
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition: Key.h:92
HybridGaussianFactor.h
A set of GaussianFactors, indexed by a set of discrete keys.
equal_constants::conditionals
const std::vector< GaussianConditional::shared_ptr > conditionals
Definition: testHybridGaussianConditional.cpp:53
gtsam::DefaultKeyFormatter
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition: Key.cpp:30
gtsam::print
void print(const Matrix &A, const string &s, ostream &stream)
Definition: Matrix.cpp:155
HybridFactor.h
A
Definition: test_numpy_dtypes.cpp:298
gtsam::VectorValues
Definition: VectorValues.h:74
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
parameters
static ConjugateGradientParameters parameters
Definition: testIterative.cpp:33
DecisionTree.h
Decision Tree for use in DiscreteFactors.
A2
static const double A2[]
Definition: expn.h:7
gtsam::HybridGaussianConditional
A conditional of gaussian conditionals indexed by discrete variables, as part of a Bayes Network....
Definition: HybridGaussianConditional.h:54
gtsam::HybridGaussianConditional::operator()
double operator()(const HybridValues &values) const
Evaluate probability density, sugar.
Definition: HybridGaussianConditional.h:222
gtsam::Conditional
Definition: Conditional.h:63
gtsam::equals
Definition: Testable.h:112
DiscreteKey.h
specialized key for discrete variables
key
const gtsam::Symbol key('X', 0)
gtsam::DecisionTree
a decision tree is a function from assignments to values.
Definition: DecisionTree.h:62
gtsam::DiscreteKeysAsSet
std::set< DiscreteKey > DiscreteKeysAsSet(const DiscreteKeys &discreteKeys)
Return the DiscreteKey vector as a set.
Definition: HybridGaussianConditional.cpp:298
gtsam
traits
Definition: SFMdata.h:40
gtsam::Testable
Definition: Testable.h:152
DecisionTree-inl.h
gtsam::traits
Definition: Group.h:36
gtsam::DiscreteValues
Definition: DiscreteValues.h:34
gtsam::HybridGaussianConditional::operator()
GaussianConditional::shared_ptr operator()(const DiscreteValues &discreteValues) const
Syntactic sugar for choose.
Definition: HybridGaussianConditional.h:178
gtsam::DiscreteKey
std::pair< Key, size_t > DiscreteKey
Definition: DiscreteKey.h:38
gtsam::HybridGaussianFactor
Implementation of a discrete-conditioned hybrid factor. Implements a joint discrete-continuous factor...
Definition: HybridGaussianFactor.h:60
A1
static const double A1[]
Definition: expn.h:6
gtsam::GaussianConditional::shared_ptr
std::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition: GaussianConditional.h:46
gtsam::HybridGaussianConditional::negLogConstant_
double negLogConstant_
Definition: HybridGaussianConditional.h:69
gtsam::HybridGaussianConditional::negLogConstant
double negLogConstant() const override
Return log normalization constant in negative log space.
Definition: HybridGaussianConditional.h:197
gtsam::tol
const G double tol
Definition: Group.h:79
Conditional.h
Base class for conditional densities.
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:97
DecisionTreeFactor.h
choose
static const T & choose(int layout, const T &col, const T &row)
Definition: cxx11_tensor_block_access.cpp:27


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:26