HybridGaussianFactorGraph.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 
19 #pragma once
20 
29 
30 #include <functional>
31 #include <optional>
32 
33 namespace gtsam {
34 
35 // Forward declarations
36 class HybridGaussianFactorGraph;
37 class HybridConditional;
38 class HybridBayesNet;
39 class HybridEliminationTree;
40 class HybridBayesTree;
41 class HybridJunctionTree;
42 class DecisionTreeFactor;
43 class TableFactor;
44 class JacobianFactor;
45 class HybridValues;
46 
55 GTSAM_EXPORT
56 std::pair<std::shared_ptr<HybridConditional>, std::shared_ptr<Factor>>
57 EliminateHybrid(const HybridGaussianFactorGraph& factors, const Ordering& keys);
58 
65 GTSAM_EXPORT const Ordering
66 HybridOrdering(const HybridGaussianFactorGraph& graph);
67 
68 /* ************************************************************************* */
69 template <>
71  typedef Factor FactorType;
74  typedef HybridConditional
77  typedef HybridBayesNet
79  typedef HybridEliminationTree
83  static std::pair<std::shared_ptr<ConditionalType>,
85  std::shared_ptr<FactorType>>
87  return EliminateHybrid(factors, keys);
88  }
91  const FactorGraphType& graph,
92  std::optional<std::reference_wrapper<const VariableIndex>>) {
93  return HybridOrdering(graph);
94  }
95 };
96 
104 class GTSAM_EXPORT HybridGaussianFactorGraph
105  : public HybridFactorGraph,
106  public EliminateableFactorGraph<HybridGaussianFactorGraph> {
107  protected:
109  template <typename FACTOR>
110  using IsGaussian = typename std::enable_if<
112 
113  public:
118  using shared_ptr = std::shared_ptr<This>;
119 
121  using Indices = KeyVector;
122 
125 
127  HybridGaussianFactorGraph() = default;
128 
134  template <class DERIVEDFACTOR>
136  : Base(graph) {}
137 
141 
142  // TODO(dellaert): customize print and equals.
143  // void print(
144  // const std::string& s = "HybridGaussianFactorGraph",
145  // const KeyFormatter& keyFormatter = DefaultKeyFormatter) const override;
146 
147  void printErrors(
148  const HybridValues& values,
149  const std::string& str = "HybridGaussianFactorGraph: ",
150  const KeyFormatter& keyFormatter = DefaultKeyFormatter,
151  const std::function<bool(const Factor* /*factor*/,
152  double /*whitenedError*/, size_t /*index*/)>&
153  printCondition =
154  [](const Factor*, double, size_t) { return true; }) const;
155 
156  // bool equals(const This& fg, double tol = 1e-9) const override;
157 
161 
163  using Base::error;
164 
174  AlgebraicDecisionTree<Key> errorTree(
175  const VectorValues& continuousValues) const;
176 
185  AlgebraicDecisionTree<Key> probPrime(
186  const VectorValues& continuousValues) const;
187 
194  double probPrime(const HybridValues& values) const;
195 
205  GaussianFactorGraphTree assembleGraphTree() const;
206 
208 };
209 
210 } // namespace gtsam
VectorValues
gtsam::HybridFactorGraph
Definition: HybridFactorGraph.h:38
gtsam::HybridValues
Definition: HybridValues.h:38
gtsam::EliminationTraits< HybridGaussianFactorGraph >::BayesTreeType
HybridBayesTree BayesTreeType
Type of Bayes tree.
Definition: HybridGaussianFactorGraph.h:81
gtsam.examples.DogLegOptimizerExample.type
type
Definition: DogLegOptimizerExample.py:111
gtsam::HybridConditional
Definition: HybridConditional.h:59
gtsam::HybridBayesNet
Definition: HybridBayesNet.h:35
keys
const KeyVector keys
Definition: testRegularImplicitSchurFactor.cpp:40
simple_graph::factors
const GaussianFactorGraph factors
Definition: testJacobianFactor.cpp:213
gtsam::HybridBayesTree
Definition: HybridBayesTree.h:62
gtsam::EliminationTraits< HybridGaussianFactorGraph >::EliminationTreeType
HybridEliminationTree EliminationTreeType
Type of elimination tree.
Definition: HybridGaussianFactorGraph.h:80
Ordering.h
Variable ordering for the elimination algorithm.
gtsam::Factor
Definition: Factor.h:69
HybridValues
gtsam::KeyVector
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition: Key.h:92
gtsam::EliminationTraits< HybridGaussianFactorGraph >::DefaultEliminate
static std::pair< std::shared_ptr< ConditionalType >, std::shared_ptr< FactorType > > DefaultEliminate(const FactorGraphType &factors, const Ordering &keys)
The default dense elimination function.
Definition: HybridGaussianFactorGraph.h:86
gtsam::HybridGaussianFactorGraph::HybridGaussianFactorGraph
HybridGaussianFactorGraph(const FactorGraph< DERIVEDFACTOR > &graph)
Definition: HybridGaussianFactorGraph.h:135
gtsam::DefaultKeyFormatter
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition: Key.cpp:30
gtsam::FactorGraph< Factor >
gtsam::EliminationTraits< HybridGaussianFactorGraph >::FactorType
Factor FactorType
Type of factors in factor graph.
Definition: HybridGaussianFactorGraph.h:71
HybridFactor.h
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::EliminationTraits< HybridGaussianFactorGraph >::JunctionTreeType
HybridJunctionTree JunctionTreeType
Definition: HybridGaussianFactorGraph.h:82
gtsam::HybridGaussianFactorGraph
Definition: HybridGaussianFactorGraph.h:104
gtsam::HybridGaussianFactorGraph::IsGaussian
typename std::enable_if< std::is_base_of< GaussianFactor, FACTOR >::value >::type IsGaussian
Check if FACTOR type is derived from GaussianFactor.
Definition: HybridGaussianFactorGraph.h:111
VectorValues.h
Factor Graph Values.
gtsam::EliminateHybrid
std::pair< HybridConditional::shared_ptr, std::shared_ptr< Factor > > EliminateHybrid(const HybridGaussianFactorGraph &factors, const Ordering &frontalKeys)
Main elimination function for HybridGaussianFactorGraph.
Definition: HybridGaussianFactorGraph.cpp:390
EliminateableFactorGraph.h
Variable elimination algorithms for factor graphs.
gtsam::EliminationTraits
Definition: BayesTreeCliqueBase.h:33
gtsam::HybridEliminationTree
Definition: HybridEliminationTree.h:31
str
Definition: pytypes.h:1524
HybridFactorGraph.h
Factor graph with utilities for hybrid factors.
gtsam::EliminationTraits< HybridGaussianFactorGraph >::ConditionalType
HybridConditional ConditionalType
Type of conditionals from elimination.
Definition: HybridGaussianFactorGraph.h:76
Values
std::vector< float > Values
Definition: sparse_setter.cpp:45
gtsam
traits
Definition: chartTesting.h:28
error
static double error
Definition: testRot3.cpp:37
FactorGraph.h
Factor Graph Base Class.
leaf::values
leaf::MyValues values
gtsam::Values
Definition: Values.h:65
gtsam::HybridFactorGraph::shared_ptr
std::shared_ptr< This > shared_ptr
shared_ptr to This
Definition: HybridFactorGraph.h:42
JacobianFactor
gtsam::HybridOrdering
const Ordering HybridOrdering(const HybridGaussianFactorGraph &graph)
Return a Colamd constrained ordering where the discrete keys are eliminated after the continuous keys...
Definition: HybridGaussianFactorGraph.cpp:70
gtsam::EliminationTraits< HybridGaussianFactorGraph >::FactorGraphType
HybridGaussianFactorGraph FactorGraphType
Definition: HybridGaussianFactorGraph.h:73
gtsam::EliminationTraits< HybridGaussianFactorGraph >::DefaultOrderingFunc
static Ordering DefaultOrderingFunc(const FactorGraphType &graph, std::optional< std::reference_wrapper< const VariableIndex >>)
The default ordering generation function.
Definition: HybridGaussianFactorGraph.h:90
GaussianFactor.h
A factor with a quadratic error function - a Gaussian.
gtsam::EliminateableFactorGraph
Definition: EliminateableFactorGraph.h:55
graph
NonlinearFactorGraph graph
Definition: doc/Code/OdometryExample.cpp:2
gtsam::HybridJunctionTree
Definition: HybridJunctionTree.h:52
gtsam::EliminationTraits< HybridGaussianFactorGraph >::BayesNetType
HybridBayesNet BayesNetType
Type of Bayes net from sequential elimination.
Definition: HybridGaussianFactorGraph.h:78
gtsam::Ordering
Definition: inference/Ordering.h:33
gtsam::GaussianFactorGraphTree
DecisionTree< Key, GaussianFactorGraph > GaussianFactorGraphTree
Alias for DecisionTree of GaussianFactorGraphs.
Definition: HybridFactor.h:35
gtsam::HybridFactorGraph::Indices
KeyVector Indices
Definition: HybridFactorGraph.h:45
test_callbacks.value
value
Definition: test_callbacks.py:158
GaussianMixtureFactor.h
A set of GaussianFactors, indexed by a set of discrete keys.


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