gtsam  4.0.0
gtsam
gtsam::EliminateableFactorGraph< FACTORGRAPH > Class Template Reference

Detailed Description

template<class FACTORGRAPH>
class gtsam::EliminateableFactorGraph< FACTORGRAPH >

EliminateableFactorGraph is a base class for factor graphs that contains elimination algorithms.

Any factor graph holding eliminateable factors can derive from this class to expose functions for computing marginals, conditional marginals, doing multifrontal and sequential elimination, etc.

Public Member Functions

boost::shared_ptr< BayesNetTypeeliminateSequential (OptionalOrdering ordering=boost::none, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex=boost::none, OptionalOrderingType orderingType=boost::none) const
 Do sequential elimination of all variables to produce a Bayes net. More...
 
boost::shared_ptr< BayesTreeTypeeliminateMultifrontal (OptionalOrdering ordering=boost::none, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex=boost::none, OptionalOrderingType orderingType=boost::none) const
 Do multifrontal elimination of all variables to produce a Bayes tree. More...
 
std::pair< boost::shared_ptr< BayesNetType >, boost::shared_ptr< FactorGraphType > > eliminatePartialSequential (const Ordering &ordering, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex=boost::none) const
 Do sequential elimination of some variables, in ordering provided, to produce a Bayes net and a remaining factor graph. More...
 
std::pair< boost::shared_ptr< BayesNetType >, boost::shared_ptr< FactorGraphType > > eliminatePartialSequential (const KeyVector &variables, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex=boost::none) const
 Do sequential elimination of the given variables in an ordering computed by COLAMD to produce a Bayes net and a remaining factor graph. More...
 
std::pair< boost::shared_ptr< BayesTreeType >, boost::shared_ptr< FactorGraphType > > eliminatePartialMultifrontal (const Ordering &ordering, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex=boost::none) const
 Do multifrontal elimination of some variables, in ordering provided, to produce a Bayes tree and a remaining factor graph. More...
 
std::pair< boost::shared_ptr< BayesTreeType >, boost::shared_ptr< FactorGraphType > > eliminatePartialMultifrontal (const KeyVector &variables, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex=boost::none) const
 Do multifrontal elimination of the given variables in an ordering computed by COLAMD to produce a Bayes net and a remaining factor graph. More...
 
boost::shared_ptr< BayesNetTypemarginalMultifrontalBayesNet (boost::variant< const Ordering &, const KeyVector & > variables, OptionalOrdering marginalizedVariableOrdering=boost::none, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex=boost::none) const
 Compute the marginal of the requested variables and return the result as a Bayes net. More...
 
boost::shared_ptr< BayesTreeTypemarginalMultifrontalBayesTree (boost::variant< const Ordering &, const KeyVector & > variables, OptionalOrdering marginalizedVariableOrdering=boost::none, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex=boost::none) const
 Compute the marginal of the requested variables and return the result as a Bayes tree. More...
 
boost::shared_ptr< FactorGraphType > marginal (const KeyVector &variables, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex=boost::none) const
 Compute the marginal factor graph of the requested variables. More...
 

Public Types

typedef EliminationTraits< FactorGraphType > EliminationTraitsType
 Typedef to the specific EliminationTraits for this graph.
 
typedef EliminationTraitsType::ConditionalType ConditionalType
 Conditional type stored in the Bayes net produced by elimination.
 
typedef EliminationTraitsType::BayesNetType BayesNetType
 Bayes net type produced by sequential elimination.
 
typedef EliminationTraitsType::EliminationTreeType EliminationTreeType
 Elimination tree type that can do sequential elimination of this graph.
 
typedef EliminationTraitsType::BayesTreeType BayesTreeType
 Bayes tree type produced by multifrontal elimination.
 
typedef EliminationTraitsType::JunctionTreeType JunctionTreeType
 Junction tree type that can do multifrontal elimination of this graph.
 
typedef std::pair< boost::shared_ptr< ConditionalType >, boost::shared_ptr< _FactorType > > EliminationResult
 The pair of conditional and remaining factor produced by a single dense elimination step on a subgraph. More...
 
typedef boost::function< EliminationResult(const FactorGraphType &, const Ordering &)> Eliminate
 The function type that does a single dense elimination step on a subgraph.
 
typedef boost::optional< const Ordering & > OptionalOrdering
 Typedef for an optional ordering as an argument to elimination functions.
 
typedef boost::optional< const VariableIndex & > OptionalVariableIndex
 Typedef for an optional variable index as an argument to elimination functions.
 
typedef boost::optional< Ordering::OrderingTypeOptionalOrderingType
 Typedef for an optional ordering type.
 

Member Typedef Documentation

◆ EliminationResult

template<class FACTORGRAPH>
typedef std::pair<boost::shared_ptr<ConditionalType>, boost::shared_ptr<_FactorType> > gtsam::EliminateableFactorGraph< FACTORGRAPH >::EliminationResult

The pair of conditional and remaining factor produced by a single dense elimination step on a subgraph.

Member Function Documentation

◆ eliminateMultifrontal()

template<class FACTORGRAPH >
boost::shared_ptr< typename EliminateableFactorGraph< FACTORGRAPH >::BayesTreeType > gtsam::EliminateableFactorGraph< FACTORGRAPH >::eliminateMultifrontal ( OptionalOrdering  ordering = boost::none,
const Eliminate function = EliminationTraitsType::DefaultEliminate,
OptionalVariableIndex  variableIndex = boost::none,
OptionalOrderingType  orderingType = boost::none 
) const

Do multifrontal elimination of all variables to produce a Bayes tree.

If an ordering is not provided, the ordering will be computed using either COLAMD or METIS, dependeing on the parameter orderingType (Ordering::COLAMD or Ordering::METIS)

Example - Full Cholesky elimination in COLAMD order:

boost::shared_ptr<GaussianBayesTree> result = graph.eliminateMultifrontal(EliminateCholesky);

Example - Full QR elimination in specified order:

boost::shared_ptr<GaussianBayesTree> result = graph.eliminateMultifrontal(EliminateQR, myOrdering);

Example - Reusing an existing VariableIndex to improve performance, and using COLAMD ordering:

VariableIndex varIndex(graph); // Build variable index
Data data = otherFunctionUsingVariableIndex(graph, varIndex); // Other code that uses variable index
boost::shared_ptr<GaussianBayesTree> result = graph.eliminateMultifrontal(EliminateQR, boost::none, varIndex);

◆ eliminatePartialMultifrontal() [1/2]

template<class FACTORGRAPH >
std::pair< boost::shared_ptr< typename EliminateableFactorGraph< FACTORGRAPH >::BayesTreeType >, boost::shared_ptr< FACTORGRAPH > > gtsam::EliminateableFactorGraph< FACTORGRAPH >::eliminatePartialMultifrontal ( const Ordering ordering,
const Eliminate function = EliminationTraitsType::DefaultEliminate,
OptionalVariableIndex  variableIndex = boost::none 
) const

Do multifrontal elimination of some variables, in ordering provided, to produce a Bayes tree and a remaining factor graph.

This computes the factorization \( p(X) = p(A|B) p(B) \), where \( A = \) variables, \( X \) is all the variables in the factor graph, and \( B = X\backslash A \).

◆ eliminatePartialMultifrontal() [2/2]

template<class FACTORGRAPH >
std::pair< boost::shared_ptr< typename EliminateableFactorGraph< FACTORGRAPH >::BayesTreeType >, boost::shared_ptr< FACTORGRAPH > > gtsam::EliminateableFactorGraph< FACTORGRAPH >::eliminatePartialMultifrontal ( const KeyVector variables,
const Eliminate function = EliminationTraitsType::DefaultEliminate,
OptionalVariableIndex  variableIndex = boost::none 
) const

Do multifrontal elimination of the given variables in an ordering computed by COLAMD to produce a Bayes net and a remaining factor graph.

This computes the factorization \( p(X) = p(A|B) p(B) \), where \( A = \) variables, \( X \) is all the variables in the factor graph, and \( B = X\backslash A \).

◆ eliminatePartialSequential() [1/2]

template<class FACTORGRAPH >
std::pair< boost::shared_ptr< typename EliminateableFactorGraph< FACTORGRAPH >::BayesNetType >, boost::shared_ptr< FACTORGRAPH > > gtsam::EliminateableFactorGraph< FACTORGRAPH >::eliminatePartialSequential ( const Ordering ordering,
const Eliminate function = EliminationTraitsType::DefaultEliminate,
OptionalVariableIndex  variableIndex = boost::none 
) const

Do sequential elimination of some variables, in ordering provided, to produce a Bayes net and a remaining factor graph.

This computes the factorization \( p(X) = p(A|B) p(B) \), where \( A = \) variables, \( X \) is all the variables in the factor graph, and \( B = X\backslash A \).

◆ eliminatePartialSequential() [2/2]

template<class FACTORGRAPH >
std::pair< boost::shared_ptr< typename EliminateableFactorGraph< FACTORGRAPH >::BayesNetType >, boost::shared_ptr< FACTORGRAPH > > gtsam::EliminateableFactorGraph< FACTORGRAPH >::eliminatePartialSequential ( const KeyVector variables,
const Eliminate function = EliminationTraitsType::DefaultEliminate,
OptionalVariableIndex  variableIndex = boost::none 
) const

Do sequential elimination of the given variables in an ordering computed by COLAMD to produce a Bayes net and a remaining factor graph.

This computes the factorization \( p(X) = p(A|B) p(B) \), where \( A = \) variables, \( X \) is all the variables in the factor graph, and \( B = X\backslash A \).

◆ eliminateSequential()

template<class FACTORGRAPH >
boost::shared_ptr< typename EliminateableFactorGraph< FACTORGRAPH >::BayesNetType > gtsam::EliminateableFactorGraph< FACTORGRAPH >::eliminateSequential ( OptionalOrdering  ordering = boost::none,
const Eliminate function = EliminationTraitsType::DefaultEliminate,
OptionalVariableIndex  variableIndex = boost::none,
OptionalOrderingType  orderingType = boost::none 
) const

Do sequential elimination of all variables to produce a Bayes net.

If an ordering is not provided, the ordering provided by COLAMD will be used.

Example - Full Cholesky elimination in COLAMD order:

boost::shared_ptr<GaussianBayesNet> result = graph.eliminateSequential(EliminateCholesky);

Example - METIS ordering for elimination

boost::shared_ptr<GaussianBayesNet> result = graph.eliminateSequential(OrderingType::METIS);
<b> Example - Full QR elimination in specified order:
\code
boost::shared_ptr<GaussianBayesNet> result = graph.eliminateSequential(EliminateQR, myOrdering);

Example - Reusing an existing VariableIndex to improve performance, and using COLAMD ordering:

VariableIndex varIndex(graph); // Build variable index
Data data = otherFunctionUsingVariableIndex(graph, varIndex); // Other code that uses variable index
boost::shared_ptr<GaussianBayesNet> result = graph.eliminateSequential(EliminateQR, boost::none, varIndex);

◆ marginal()

template<class FACTORGRAPH >
boost::shared_ptr< FACTORGRAPH > gtsam::EliminateableFactorGraph< FACTORGRAPH >::marginal ( const KeyVector variables,
const Eliminate function = EliminationTraitsType::DefaultEliminate,
OptionalVariableIndex  variableIndex = boost::none 
) const

Compute the marginal factor graph of the requested variables.

◆ marginalMultifrontalBayesNet()

template<class FACTORGRAPH >
boost::shared_ptr< typename EliminateableFactorGraph< FACTORGRAPH >::BayesNetType > gtsam::EliminateableFactorGraph< FACTORGRAPH >::marginalMultifrontalBayesNet ( boost::variant< const Ordering &, const KeyVector & >  variables,
OptionalOrdering  marginalizedVariableOrdering = boost::none,
const Eliminate function = EliminationTraitsType::DefaultEliminate,
OptionalVariableIndex  variableIndex = boost::none 
) const

Compute the marginal of the requested variables and return the result as a Bayes net.

Parameters
variablesDetermines the variables whose marginal to compute, if provided as an Ordering they will be ordered in the returned BayesNet as specified, and if provided as a KeyVector they will be ordered using constrained COLAMD.
marginalizedVariableOrderingOptional ordering for the variables being marginalized out, i.e. all variables not in variables. If this is boost::none, the ordering will be computed with COLAMD.
functionOptional dense elimination function, if not provided the default will be used.
variableIndexOptional pre-computed VariableIndex for the factor graph, if not provided one will be computed.

◆ marginalMultifrontalBayesTree()

template<class FACTORGRAPH >
boost::shared_ptr< typename EliminateableFactorGraph< FACTORGRAPH >::BayesTreeType > gtsam::EliminateableFactorGraph< FACTORGRAPH >::marginalMultifrontalBayesTree ( boost::variant< const Ordering &, const KeyVector & >  variables,
OptionalOrdering  marginalizedVariableOrdering = boost::none,
const Eliminate function = EliminationTraitsType::DefaultEliminate,
OptionalVariableIndex  variableIndex = boost::none 
) const

Compute the marginal of the requested variables and return the result as a Bayes tree.

Parameters
variablesDetermines the variables whose marginal to compute, if provided as an Ordering they will be ordered in the returned BayesNet as specified, and if provided as a KeyVector they will be ordered using constrained COLAMD.
marginalizedVariableOrderingOptional ordering for the variables being marginalized out, i.e. all variables not in variables. If this is boost::none, the ordering will be computed with COLAMD.
functionOptional dense elimination function, if not provided the default will be used.
variableIndexOptional pre-computed VariableIndex for the factor graph, if not provided one will be computed.

The documentation for this class was generated from the following files: