GTSAM  4.0.2
C++ library for smoothing and mapping (SAM)
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 JacobianFactor;
44 class HybridValues;
45 
54 GTSAM_EXPORT
55 std::pair<std::shared_ptr<HybridConditional>, std::shared_ptr<Factor>>
56 EliminateHybrid(const HybridGaussianFactorGraph& factors, const Ordering& keys);
57 
64 GTSAM_EXPORT const Ordering
65 HybridOrdering(const HybridGaussianFactorGraph& graph);
66 
67 /* ************************************************************************* */
68 template <>
70  typedef Factor FactorType;
73  typedef HybridConditional
76  typedef HybridBayesNet
78  typedef HybridEliminationTree
82  static std::pair<std::shared_ptr<ConditionalType>,
84  std::shared_ptr<FactorType>>
85  DefaultEliminate(const FactorGraphType& factors, const Ordering& keys) {
86  return EliminateHybrid(factors, keys);
87  }
90  const FactorGraphType& graph,
91  std::optional<std::reference_wrapper<const VariableIndex>>) {
92  return HybridOrdering(graph);
93  }
94 };
95 
103 class GTSAM_EXPORT HybridGaussianFactorGraph
104  : public HybridFactorGraph,
105  public EliminateableFactorGraph<HybridGaussianFactorGraph> {
106  protected:
108  template <typename FACTOR>
109  using IsGaussian = typename std::enable_if<
110  std::is_base_of<GaussianFactor, FACTOR>::value>::type;
111 
112  public:
113  using Base = HybridFactorGraph;
115  using BaseEliminateable =
117  using shared_ptr = std::shared_ptr<This>;
118 
120  using Indices = KeyVector;
121 
124 
126  HybridGaussianFactorGraph() = default;
127 
133  template <class DERIVEDFACTOR>
135  : Base(graph) {}
136 
140 
141  // TODO(dellaert): customize print and equals.
142  // void print(const std::string& s = "HybridGaussianFactorGraph",
143  // const KeyFormatter& keyFormatter = DefaultKeyFormatter) const
144  // override;
145  // bool equals(const This& fg, double tol = 1e-9) const override;
146 
150 
151  using Base::error; // Expose error(const HybridValues&) method..
152 
162  AlgebraicDecisionTree<Key> error(const VectorValues& continuousValues) const;
163 
172  AlgebraicDecisionTree<Key> probPrime(
173  const VectorValues& continuousValues) const;
174 
181  double probPrime(const HybridValues& values) const;
182 
192  GaussianFactorGraphTree assembleGraphTree() const;
193 
195 };
196 
197 } // namespace gtsam
Definition: HybridValues.h:38
A set of GaussianFactors, indexed by a set of discrete keys.
Definition: HybridJunctionTree.h:52
GTSAM_EXPORT const Ordering HybridOrdering(const HybridGaussianFactorGraph &graph)
Return a Colamd constrained ordering where the discrete keys are eliminated after the continuous keys...
Definition: HybridEliminationTree.h:31
typename std::enable_if< std::is_base_of< GaussianFactor, FACTOR >::value >::type IsGaussian
Check if FACTOR type is derived from GaussianFactor.
Definition: HybridGaussianFactorGraph.h:110
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:85
Variable elimination algorithms for factor graphs.
Definition: Factor.h:69
A factor with a quadratic error function - a Gaussian.
Definition: BayesTree.h:34
Variable ordering for the elimination algorithm.
Definition: Ordering.h:37
Definition: HybridBayesTree.h:62
HybridEliminationTree EliminationTreeType
Type of elimination tree.
Definition: HybridGaussianFactorGraph.h:79
Definition: VectorValues.h:74
Definition: HybridGaussianFactorGraph.h:103
Factor FactorType
Type of factors in factor graph.
Definition: HybridGaussianFactorGraph.h:70
HybridBayesTree BayesTreeType
Type of Bayes tree.
Definition: HybridGaussianFactorGraph.h:80
Factor Graph Values.
Definition: DecisionTree.h:49
Definition: HybridBayesNet.h:35
std::shared_ptr< This > shared_ptr
shared_ptr to This
Definition: HybridFactorGraph.h:42
HybridJunctionTree JunctionTreeType
Definition: HybridGaussianFactorGraph.h:81
Definition: Values.h:65
HybridGaussianFactorGraph FactorGraphType
Definition: HybridGaussianFactorGraph.h:72
Definition: chartTesting.h:28
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition: Key.h:86
Definition: HybridFactorGraph.h:38
Definition: BayesTreeCliqueBase.h:33
Factor Graph Base Class.
static Ordering DefaultOrderingFunc(const FactorGraphType &graph, std::optional< std::reference_wrapper< const VariableIndex >>)
The default ordering generation function.
Definition: HybridGaussianFactorGraph.h:89
Factor graph with utilities for hybrid factors.
Definition: HybridConditional.h:59
GTSAM_EXPORT std::pair< std::shared_ptr< HybridConditional >, std::shared_ptr< Factor > > EliminateHybrid(const HybridGaussianFactorGraph &factors, const Ordering &keys)
Main elimination function for HybridGaussianFactorGraph.
Definition: EliminateableFactorGraph.h:55
HybridGaussianFactorGraph(const FactorGraph< DERIVEDFACTOR > &graph)
Definition: HybridGaussianFactorGraph.h:134
HybridBayesNet BayesNetType
Type of Bayes net from sequential elimination.
Definition: HybridGaussianFactorGraph.h:77
HybridConditional ConditionalType
Type of conditionals from elimination.
Definition: HybridGaussianFactorGraph.h:75