27 template<
class FACTORGRAPH>
28 std::shared_ptr<typename EliminateableFactorGraph<FACTORGRAPH>::BayesNetType>
38 return eliminateSequential(orderingType,
function, std::cref(computedVariableIndex));
45 return eliminateSequential(computedOrdering,
function, variableIndex);
48 return eliminateSequential(computedOrdering,
function, variableIndex);
51 return eliminateSequential(computedOrdering,
function, variableIndex);
53 Ordering computedOrdering = EliminationTraitsType::DefaultOrderingFunc(
54 asDerived(), *variableIndex);
55 return eliminateSequential(computedOrdering,
function, variableIndex);
61 template<
class FACTORGRAPH>
62 std::shared_ptr<typename EliminateableFactorGraph<FACTORGRAPH>::BayesNetType>
70 return eliminateSequential(ordering,
function, std::cref(computedVariableIndex));
72 gttic(eliminateSequential);
75 const auto [bayesNet, factorGraph] = etree.eliminate(
function);
77 if(!factorGraph->empty())
85 template <
class FACTORGRAPH>
98 return eliminateMultifrontal(orderingType,
function,
99 std::cref(computedVariableIndex));
106 return eliminateMultifrontal(computedOrdering,
function, variableIndex);
109 return eliminateMultifrontal(computedOrdering,
function, variableIndex);
112 return eliminateMultifrontal(computedOrdering,
function, variableIndex);
114 Ordering computedOrdering = EliminationTraitsType::DefaultOrderingFunc(
115 asDerived(), *variableIndex);
116 return eliminateMultifrontal(computedOrdering,
function, variableIndex);
122 template<
class FACTORGRAPH>
123 std::shared_ptr<typename EliminateableFactorGraph<FACTORGRAPH>::BayesTreeType>
131 return eliminateMultifrontal(ordering,
function, std::cref(computedVariableIndex));
133 gttic(eliminateMultifrontal);
137 const auto [bayesTree, factorGraph] = junctionTree.eliminate(
function);
139 if(!factorGraph->empty())
147 template<
class FACTORGRAPH>
148 std::pair<std::shared_ptr<typename EliminateableFactorGraph<FACTORGRAPH>::BayesNetType>, std::shared_ptr<FACTORGRAPH> >
153 gttic(eliminatePartialSequential);
156 return etree.eliminate(
function);
160 return eliminatePartialSequential(ordering,
function, std::cref(computedVariableIndex));
165 template<
class FACTORGRAPH>
166 std::pair<std::shared_ptr<typename EliminateableFactorGraph<FACTORGRAPH>::BayesNetType>, std::shared_ptr<FACTORGRAPH> >
171 gttic(eliminatePartialSequential);
176 Ordering ordering(fullOrdering.begin(), fullOrdering.begin() + variables.size());
177 return eliminatePartialSequential(
ordering,
function, variableIndex);
181 return eliminatePartialSequential(variables,
function, std::cref(computedVariableIndex));
186 template<
class FACTORGRAPH>
187 std::pair<std::shared_ptr<typename EliminateableFactorGraph<FACTORGRAPH>::BayesTreeType>, std::shared_ptr<FACTORGRAPH> >
192 gttic(eliminatePartialMultifrontal);
196 return junctionTree.eliminate(
function);
200 return eliminatePartialMultifrontal(ordering,
function, std::cref(computedVariableIndex));
205 template<
class FACTORGRAPH>
206 std::pair<std::shared_ptr<typename EliminateableFactorGraph<FACTORGRAPH>::BayesTreeType>, std::shared_ptr<FACTORGRAPH> >
211 gttic(eliminatePartialMultifrontal);
216 Ordering ordering(fullOrdering.begin(), fullOrdering.begin() + variables.size());
217 return eliminatePartialMultifrontal(
ordering,
function, variableIndex);
221 return eliminatePartialMultifrontal(variables,
function, std::cref(computedVariableIndex));
226 template<
class FACTORGRAPH>
227 std::shared_ptr<typename EliminateableFactorGraph<FACTORGRAPH>::BayesNetType>
235 return marginalMultifrontalBayesNet(variables,
function, std::cref(index));
239 constexpr
bool forceOrder =
true;
244 const size_t nVars = variables.size();
245 Ordering marginalizationOrdering(totalOrdering.begin(), totalOrdering.end() - nVars);
246 Ordering marginalVarsOrdering(totalOrdering.end() - nVars, totalOrdering.end());
249 return marginalMultifrontalBayesNet(marginalVarsOrdering, marginalizationOrdering,
function, variableIndex);
254 template<
class FACTORGRAPH>
255 std::shared_ptr<typename EliminateableFactorGraph<FACTORGRAPH>::BayesNetType>
263 return marginalMultifrontalBayesNet(variables,
function, std::cref(index));
267 const constexpr
bool forceOrder =
false;
272 const size_t nVars = variables.size();
273 Ordering marginalizationOrdering(totalOrdering.begin(), totalOrdering.end() - nVars);
274 Ordering marginalVarsOrdering(totalOrdering.end() - nVars, totalOrdering.end());
277 return marginalMultifrontalBayesNet(marginalVarsOrdering, marginalizationOrdering,
function, variableIndex);
282 template<
class FACTORGRAPH>
283 std::shared_ptr<typename EliminateableFactorGraph<FACTORGRAPH>::BayesNetType>
286 const Ordering& marginalizedVariableOrdering,
292 return marginalMultifrontalBayesNet(variables, marginalizedVariableOrdering,
function, index);
294 gttic(marginalMultifrontalBayesNet);
297 const auto [bayesTree, factorGraph] =
298 eliminatePartialMultifrontal(marginalizedVariableOrdering,
function, variableIndex);
302 return factorGraph->eliminateSequential(variables,
function);
307 template<
class FACTORGRAPH>
308 std::shared_ptr<typename EliminateableFactorGraph<FACTORGRAPH>::BayesNetType>
311 const Ordering& marginalizedVariableOrdering,
317 return marginalMultifrontalBayesNet(variables, marginalizedVariableOrdering,
function, index);
319 gttic(marginalMultifrontalBayesNet);
322 const auto [bayesTree, factorGraph] =
323 eliminatePartialMultifrontal(marginalizedVariableOrdering,
function, variableIndex);
331 template<
class FACTORGRAPH>
332 std::shared_ptr<typename EliminateableFactorGraph<FACTORGRAPH>::BayesTreeType>
340 return marginalMultifrontalBayesTree(variables,
function, std::cref(computedVariableIndex));
344 constexpr
bool forceOrder =
true;
349 const size_t nVars = variables.size();
350 Ordering marginalizationOrdering(totalOrdering.begin(), totalOrdering.end() - nVars);
351 Ordering marginalVarsOrdering(totalOrdering.end() - nVars, totalOrdering.end());
354 return marginalMultifrontalBayesTree(marginalVarsOrdering, marginalizationOrdering,
function, variableIndex);
359 template<
class FACTORGRAPH>
360 std::shared_ptr<typename EliminateableFactorGraph<FACTORGRAPH>::BayesTreeType>
368 return marginalMultifrontalBayesTree(variables,
function, std::cref(computedVariableIndex));
372 constexpr
bool forceOrder =
false;
377 const size_t nVars = variables.size();
378 Ordering marginalizationOrdering(totalOrdering.begin(), totalOrdering.end() - nVars);
379 Ordering marginalVarsOrdering(totalOrdering.end() - nVars, totalOrdering.end());
382 return marginalMultifrontalBayesTree(marginalVarsOrdering, marginalizationOrdering,
function, variableIndex);
387 template<
class FACTORGRAPH>
388 std::shared_ptr<typename EliminateableFactorGraph<FACTORGRAPH>::BayesTreeType>
391 const Ordering& marginalizedVariableOrdering,
397 return marginalMultifrontalBayesTree(variables, marginalizedVariableOrdering,
function, std::cref(computedVariableIndex));
399 gttic(marginalMultifrontalBayesTree);
402 const auto [bayesTree, factorGraph] =
403 eliminatePartialMultifrontal(marginalizedVariableOrdering,
function, variableIndex);
407 return factorGraph->eliminateMultifrontal(variables,
function);
412 template<
class FACTORGRAPH>
413 std::shared_ptr<typename EliminateableFactorGraph<FACTORGRAPH>::BayesTreeType>
416 const Ordering& marginalizedVariableOrdering,
422 return marginalMultifrontalBayesTree(variables, marginalizedVariableOrdering,
function, std::cref(computedVariableIndex));
424 gttic(marginalMultifrontalBayesTree);
427 const auto [bayesTree, factorGraph] =
428 eliminatePartialMultifrontal(marginalizedVariableOrdering,
function, variableIndex);
436 template<
class FACTORGRAPH>
437 std::shared_ptr<FACTORGRAPH>
448 Ordering marginalizationOrdering(totalOrdering.begin(), totalOrdering.end() - variables.size());
451 return eliminatePartialMultifrontal(marginalizationOrdering,
function, variableIndex).second;
457 return marginal(variables,
function, std::cref(computedVariableIndex));
static GTSAM_EXPORT Ordering Metis(const MetisIndex &met)
Compute an ordering determined by METIS from a VariableIndex.
std::pair< std::shared_ptr< BayesTreeType >, std::shared_ptr< FactorGraphType > > eliminatePartialMultifrontal(const Ordering &ordering, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
std::optional< std::reference_wrapper< const VariableIndex > > OptionalVariableIndex
std::shared_ptr< BayesNetType > marginalMultifrontalBayesNet(const Ordering &variables, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
Variable elimination algorithms for factor graphs.
std::shared_ptr< BayesTreeType > marginalMultifrontalBayesTree(const Ordering &variables, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
std::pair< std::shared_ptr< BayesNetType >, std::shared_ptr< FactorGraphType > > eliminatePartialSequential(const Ordering &ordering, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
Exceptions that may be thrown by inference algorithms.
static enum @1107 ordering
static Ordering Colamd(const FACTOR_GRAPH &graph)
std::shared_ptr< FactorGraphType > marginal(const KeyVector &variables, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
EliminationTraitsType::JunctionTreeType JunctionTreeType
Junction tree type that can do multifrontal elimination of this graph.
std::function< EliminationResult(const FactorGraphType &, const Ordering &)> Eliminate
The function type that does a single dense elimination step on a subgraph.
std::shared_ptr< BayesNetType > eliminateSequential(OptionalOrderingType orderingType={}, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
static Ordering ColamdConstrainedFirst(const FACTOR_GRAPH &graph, const KeyVector &constrainFirst, bool forceOrder=false)
EliminationTraitsType::EliminationTreeType EliminationTreeType
Elimination tree type that can do sequential elimination of this graph.
std::shared_ptr< BayesTreeType > eliminateMultifrontal(OptionalOrderingType orderingType={}, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
EliminationTraitsType::BayesTreeType BayesTreeType
Bayes tree type produced by multifrontal elimination.
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
std::optional< Ordering::OrderingType > OptionalOrderingType
Typedef for an optional ordering type.
static Ordering ColamdConstrainedLast(const FACTOR_GRAPH &graph, const KeyVector &constrainLast, bool forceOrder=false)
static Ordering Natural(const FACTOR_GRAPH &fg)
Return a natural Ordering. Typically used by iterative solvers.