EliminateableFactorGraph.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 
21 #include <memory>
22 #include <cstddef>
23 #include <functional>
24 #include <optional>
25 
28 
29 namespace gtsam {
33  template<class GRAPH>
34  struct EliminationTraits
35  {
36  // Template for deriving:
37  // typedef MyFactor FactorType; ///< Type of factors in factor graph (e.g. GaussianFactor)
38  // typedef MyFactorGraphType FactorGraphType; ///< Type of the factor graph (e.g. GaussianFactorGraph)
39  // typedef MyConditional ConditionalType; ///< Type of conditionals from elimination (e.g. GaussianConditional)
40  // typedef MyBayesNet BayesNetType; ///< Type of Bayes net from sequential elimination (e.g. GaussianBayesNet)
41  // typedef MyEliminationTree EliminationTreeType; ///< Type of elimination tree (e.g. GaussianEliminationTree)
42  // typedef MyBayesTree BayesTreeType; ///< Type of Bayes tree (e.g. GaussianBayesTree)
43  // typedef MyJunctionTree JunctionTreeType; ///< Type of Junction tree (e.g. GaussianJunctionTree)
44  // static pair<shared_ptr<ConditionalType>, shared_ptr<FactorType>
45  // DefaultEliminate(
46  // const MyFactorGraph& factors, const Ordering& keys); ///< The default dense elimination function
47  };
48 
49 
54  template<class FACTOR_GRAPH>
56  {
57  private:
59  typedef FACTOR_GRAPH FactorGraphType;
60  // Base factor type stored in this graph (private because derived classes will get this from
61  // their FactorGraph base class)
63 
64  public:
67 
69  typedef typename EliminationTraitsType::ConditionalType ConditionalType;
70 
72  typedef typename EliminationTraitsType::BayesNetType BayesNetType;
73 
75  typedef typename EliminationTraitsType::EliminationTreeType EliminationTreeType;
76 
78  typedef typename EliminationTraitsType::BayesTreeType BayesTreeType;
79 
81  typedef typename EliminationTraitsType::JunctionTreeType JunctionTreeType;
82 
85  typedef std::pair<std::shared_ptr<ConditionalType>, std::shared_ptr<_FactorType> > EliminationResult;
86 
88  typedef std::function<EliminationResult(const FactorGraphType&, const Ordering&)> Eliminate;
89 
92  typedef std::optional<std::reference_wrapper<const VariableIndex>> OptionalVariableIndex;
93 
95  typedef std::optional<Ordering::OrderingType> OptionalOrderingType;
96 
117  std::shared_ptr<BayesNetType> eliminateSequential(
118  OptionalOrderingType orderingType = {},
119  const Eliminate& function = EliminationTraitsType::DefaultEliminate,
120  OptionalVariableIndex variableIndex = {}) const;
121 
136  std::shared_ptr<BayesNetType> eliminateSequential(
137  const Ordering& ordering,
138  const Eliminate& function = EliminationTraitsType::DefaultEliminate,
139  OptionalVariableIndex variableIndex = {}) const;
140 
157  std::shared_ptr<BayesTreeType> eliminateMultifrontal(
158  OptionalOrderingType orderingType = {},
159  const Eliminate& function = EliminationTraitsType::DefaultEliminate,
160  OptionalVariableIndex variableIndex = {}) const;
161 
171  std::shared_ptr<BayesTreeType> eliminateMultifrontal(
172  const Ordering& ordering,
173  const Eliminate& function = EliminationTraitsType::DefaultEliminate,
174  OptionalVariableIndex variableIndex = {}) const;
175 
180  std::pair<std::shared_ptr<BayesNetType>, std::shared_ptr<FactorGraphType> >
182  const Ordering& ordering,
183  const Eliminate& function = EliminationTraitsType::DefaultEliminate,
184  OptionalVariableIndex variableIndex = {}) const;
185 
190  std::pair<std::shared_ptr<BayesNetType>, std::shared_ptr<FactorGraphType> >
192  const KeyVector& variables,
193  const Eliminate& function = EliminationTraitsType::DefaultEliminate,
194  OptionalVariableIndex variableIndex = {}) const;
195 
200  std::pair<std::shared_ptr<BayesTreeType>, std::shared_ptr<FactorGraphType> >
202  const Ordering& ordering,
203  const Eliminate& function = EliminationTraitsType::DefaultEliminate,
204  OptionalVariableIndex variableIndex = {}) const;
205 
210  std::pair<std::shared_ptr<BayesTreeType>, std::shared_ptr<FactorGraphType> >
212  const KeyVector& variables,
213  const Eliminate& function = EliminationTraitsType::DefaultEliminate,
214  OptionalVariableIndex variableIndex = {}) const;
215 
224  std::shared_ptr<BayesNetType> marginalMultifrontalBayesNet(
225  const Ordering& variables,
226  const Eliminate& function = EliminationTraitsType::DefaultEliminate,
227  OptionalVariableIndex variableIndex = {}) const;
228 
237  std::shared_ptr<BayesNetType> marginalMultifrontalBayesNet(
238  const KeyVector& variables,
239  const Eliminate& function = EliminationTraitsType::DefaultEliminate,
240  OptionalVariableIndex variableIndex = {}) const;
241 
251  std::shared_ptr<BayesNetType> marginalMultifrontalBayesNet(
252  const Ordering& variables,
253  const Ordering& marginalizedVariableOrdering,
254  const Eliminate& function = EliminationTraitsType::DefaultEliminate,
255  OptionalVariableIndex variableIndex = {}) const;
256 
266  std::shared_ptr<BayesNetType> marginalMultifrontalBayesNet(
267  const KeyVector& variables,
268  const Ordering& marginalizedVariableOrdering,
269  const Eliminate& function = EliminationTraitsType::DefaultEliminate,
270  OptionalVariableIndex variableIndex = {}) const;
271 
279  std::shared_ptr<BayesTreeType> marginalMultifrontalBayesTree(
280  const Ordering& variables,
281  const Eliminate& function = EliminationTraitsType::DefaultEliminate,
282  OptionalVariableIndex variableIndex = {}) const;
283 
291  std::shared_ptr<BayesTreeType> marginalMultifrontalBayesTree(
292  const KeyVector& variables,
293  const Eliminate& function = EliminationTraitsType::DefaultEliminate,
294  OptionalVariableIndex variableIndex = {}) const;
295 
304  std::shared_ptr<BayesTreeType> marginalMultifrontalBayesTree(
305  const Ordering& variables,
306  const Ordering& marginalizedVariableOrdering,
307  const Eliminate& function = EliminationTraitsType::DefaultEliminate,
308  OptionalVariableIndex variableIndex = {}) const;
309 
318  std::shared_ptr<BayesTreeType> marginalMultifrontalBayesTree(
319  const KeyVector& variables,
320  const Ordering& marginalizedVariableOrdering,
321  const Eliminate& function = EliminationTraitsType::DefaultEliminate,
322  OptionalVariableIndex variableIndex = {}) const;
323 
325  std::shared_ptr<FactorGraphType> marginal(
326  const KeyVector& variables,
327  const Eliminate& function = EliminationTraitsType::DefaultEliminate,
328  OptionalVariableIndex variableIndex = {}) const;
329 
330  private:
331 
332  // Access the derived factor graph class
333  const FactorGraphType& asDerived() const { return static_cast<const FactorGraphType&>(*this); }
334 
335  // Access the derived factor graph class
336  FactorGraphType& asDerived() { return static_cast<FactorGraphType&>(*this); }
337  };
338 
339 }
gtsam::EliminateableFactorGraph::eliminatePartialMultifrontal
std::pair< std::shared_ptr< BayesTreeType >, std::shared_ptr< FactorGraphType > > eliminatePartialMultifrontal(const Ordering &ordering, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
Definition: EliminateableFactorGraph-inst.h:190
gtsam::EliminateableFactorGraph::FactorGraphType
FACTOR_GRAPH FactorGraphType
Typedef to factor graph type.
Definition: EliminateableFactorGraph.h:59
gtsam::EliminateableFactorGraph::eliminateSequential
std::shared_ptr< BayesNetType > eliminateSequential(OptionalOrderingType orderingType={}, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
Definition: EliminateableFactorGraph-inst.h:29
gtsam::EliminateableFactorGraph::marginalMultifrontalBayesNet
std::shared_ptr< BayesNetType > marginalMultifrontalBayesNet(const Ordering &variables, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
Definition: EliminateableFactorGraph-inst.h:230
gtsam::EliminateableFactorGraph::marginal
std::shared_ptr< FactorGraphType > marginal(const KeyVector &variables, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
Definition: EliminateableFactorGraph-inst.h:440
Ordering.h
Variable ordering for the elimination algorithm.
gtsam::KeyVector
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition: Key.h:92
gtsam::EliminateableFactorGraph::eliminateMultifrontal
std::shared_ptr< BayesTreeType > eliminateMultifrontal(OptionalOrderingType orderingType={}, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
Definition: EliminateableFactorGraph-inst.h:89
gtsam::EliminateableFactorGraph::OptionalVariableIndex
std::optional< std::reference_wrapper< const VariableIndex > > OptionalVariableIndex
Definition: EliminateableFactorGraph.h:92
gtsam::GaussianFactorGraph
Definition: GaussianFactorGraph.h:73
gtsam::EliminateableFactorGraph::EliminationResult
std::pair< std::shared_ptr< ConditionalType >, std::shared_ptr< _FactorType > > EliminationResult
Definition: EliminateableFactorGraph.h:85
gtsam::EliminateableFactorGraph::EliminationTreeType
EliminationTraitsType::EliminationTreeType EliminationTreeType
Elimination tree type that can do sequential elimination of this graph.
Definition: EliminateableFactorGraph.h:75
gtsam::EliminateableFactorGraph::JunctionTreeType
EliminationTraitsType::JunctionTreeType JunctionTreeType
Junction tree type that can do multifrontal elimination of this graph.
Definition: EliminateableFactorGraph.h:81
gtsam::EliminateableFactorGraph::asDerived
FactorGraphType & asDerived()
Definition: EliminateableFactorGraph.h:336
gtsam::EliminateableFactorGraph::eliminatePartialSequential
std::pair< std::shared_ptr< BayesNetType >, std::shared_ptr< FactorGraphType > > eliminatePartialSequential(const Ordering &ordering, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
Definition: EliminateableFactorGraph-inst.h:151
gtsam::EliminateableFactorGraph::BayesTreeType
EliminationTraitsType::BayesTreeType BayesTreeType
Bayes tree type produced by multifrontal elimination.
Definition: EliminateableFactorGraph.h:78
gtsam::EliminateableFactorGraph::asDerived
const FactorGraphType & asDerived() const
Definition: EliminateableFactorGraph.h:333
gtsam::EliminateableFactorGraph::EliminationTraitsType
EliminationTraits< FactorGraphType > EliminationTraitsType
Typedef to the specific EliminationTraits for this graph.
Definition: EliminateableFactorGraph.h:66
gtsam::EliminationTraits
Definition: BayesTreeCliqueBase.h:33
ordering
static enum @1096 ordering
gtsam
traits
Definition: SFMdata.h:40
gtsam::EliminateableFactorGraph::BayesNetType
EliminationTraitsType::BayesNetType BayesNetType
Bayes net type produced by sequential elimination.
Definition: EliminateableFactorGraph.h:72
gtsam::EliminateableFactorGraph::_FactorType
EliminationTraits< FactorGraphType >::FactorType _FactorType
Definition: EliminateableFactorGraph.h:62
gtsam::EliminateableFactorGraph::ConditionalType
EliminationTraitsType::ConditionalType ConditionalType
Conditional type stored in the Bayes net produced by elimination.
Definition: EliminateableFactorGraph.h:69
VariableIndex.h
gtsam::EliminateableFactorGraph::OptionalOrderingType
std::optional< Ordering::OrderingType > OptionalOrderingType
Typedef for an optional ordering type.
Definition: EliminateableFactorGraph.h:95
gtsam::EliminateableFactorGraph::Eliminate
std::function< EliminationResult(const FactorGraphType &, const Ordering &)> Eliminate
The function type that does a single dense elimination step on a subgraph.
Definition: EliminateableFactorGraph.h:88
gtsam::EliminateableFactorGraph::This
EliminateableFactorGraph< FACTOR_GRAPH > This
Typedef to this class.
Definition: EliminateableFactorGraph.h:58
gtsam::EliminateableFactorGraph
Definition: EliminateableFactorGraph.h:55
gtsam::Ordering
Definition: inference/Ordering.h:33
gtsam::EliminateableFactorGraph::marginalMultifrontalBayesTree
std::shared_ptr< BayesTreeType > marginalMultifrontalBayesTree(const Ordering &variables, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
Definition: EliminateableFactorGraph-inst.h:335


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