Loading...
Searching...
No Matches
gtsam::MixtureFactor Class Reference

## Detailed Description

Implementation of a discrete conditional mixture factor.

Implements a joint discrete-continuous factor where the discrete variable serves to "select" a mixture component corresponding to a NonlinearFactor type of measurement.

This class stores all factors as HybridFactors which can then be typecast to one of (NonlinearFactor, GaussianFactor) which can then be checked to perform the correct operation.

Inheritance diagram for gtsam::MixtureFactor:

## Public Member Functions

| MixtureFactor (const KeyVector &keys, const DiscreteKeys &discreteKeys, const Factors &factors, bool normalized=false)
| Construct from Decision tree.
template<typename FACTOR>
| MixtureFactor (const KeyVector &keys, const DiscreteKeys &discreteKeys, const std::vector< boost::shared_ptr< FACTOR > > &factors, bool normalized=false)
| Convenience constructor that generates the underlying factor decision tree for us.
AlgebraicDecisionTree< Key > | error (const Values &continuousValues) const
| Compute error of the MixtureFactor as a tree.
double | error (const Values &continuousValues, const DiscreteValues &discreteValues) const
| Compute error of factor given both continuous and discrete values.
double | error (const HybridValues &values) const override
| Compute error of factor given hybrid values.
size_t | dim () const
| Get the dimension of the factor (number of rows on linearization).
GaussianFactor::shared_ptr | linearize (const Values &continuousValues, const DiscreteValues &discreteValues) const
| Linearize specific nonlinear factors based on the assignment in discreteValues.
boost::shared_ptr< GaussianMixtureFactor > | linearize (const Values &continuousValues) const
| Linearize all the continuous factors to get a GaussianMixtureFactor.
double | nonlinearFactorLogNormalizingConstant (const sharedFactor &factor, const Values &values) const
| If the component factors are not already normalized, we want to compute their normalizing constants so that the resulting joint distribution is appropriately computed.
void | print (const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
| Testable.
bool | equals (const HybridFactor &other, double tol=1e-9) const override
| Check equality.
Public Member Functions inherited from gtsam::HybridFactor
| HybridFactor ()=default
| Default constructor creates empty factor.
| HybridFactor (const KeyVector &keys)
| Construct hybrid factor from continuous keys.
| HybridFactor (const DiscreteKeys &discreteKeys)
| Construct hybrid factor from discrete keys.
| HybridFactor (const KeyVector &continuousKeys, const DiscreteKeys &discreteKeys)
| Construct a new Hybrid Factor object.
virtual | ~HybridFactor ()=default
| Virtual destructor.
bool | isDiscrete () const
| True if this is a factor of discrete variables only.
bool | isContinuous () const
| True if this is a factor of continuous variables only.
bool | isHybrid () const
| True is this is a Discrete-Continuous factor.
size_t | nrContinuous () const
| Return the number of continuous variables in this factor.
const DiscreteKeys & | discreteKeys () const
| Return the discrete keys for this factor.
const KeyVector & | continuousKeys () const
| Return only the continuous keys for this factor.
Public Member Functions inherited from gtsam::Factor
virtual | ~Factor ()=default
| Default destructor.
bool | empty () const
| Whether the factor is empty (involves zero variables).
Key | front () const
| First key.
Key | back () const
| Last key.
const_iterator | find (Key key) const
| find
const KeyVector & | keys () const
| Access the factor's involved variable keys.
const_iterator | begin () const
| Iterator at beginning of involved variable keys.
const_iterator | end () const
| Iterator at end of involved variable keys.
size_t | size () const
virtual void | printKeys (const std::string &s="Factor", const KeyFormatter &formatter=DefaultKeyFormatter) const
| print only keys
bool | equals (const This &other, double tol=1e-9) const
| check equality
KeyVector & | keys ()
iterator | begin ()
| Iterator at beginning of involved variable keys.
iterator | end ()
| Iterator at end of involved variable keys.

## Public Types

using | Base = HybridFactor
using | This = MixtureFactor
using | shared_ptr = boost::shared_ptr<MixtureFactor>
using | sharedFactor = boost::shared_ptr<NonlinearFactor>
using | Factors = DecisionTree<Key, sharedFactor>
| typedef for DecisionTree which has Keys as node labels and NonlinearFactor as leaf nodes.
Public Types inherited from gtsam::HybridFactor
typedef HybridFactor | This
| This class.
typedef boost::shared_ptr< HybridFactor > | shared_ptr
| shared_ptr to this class
typedef Factor | Base
| Our base class.
Public Types inherited from gtsam::Factor
typedef KeyVector::iterator | iterator
| Iterator over keys.
typedef KeyVector::const_iterator | const_iterator
| Const iterator over keys.

## Additional Inherited Members

| Factor ()
| Default constructor for I/O.
template<typename CONTAINER>
| Factor (const CONTAINER &keys)
| Construct factor from container of keys.
template<typename ITERATOR>
| Factor (ITERATOR first, ITERATOR last)
| Construct factor from iterator keys.
template<typename CONTAINER>
static Factor | FromKeys (const CONTAINER &keys)
| Construct factor from container of keys.
template<typename ITERATOR>
static Factor | FromIterators (ITERATOR first, ITERATOR last)
| Construct factor from iterator keys.
Protected Attributes inherited from gtsam::HybridFactor
DiscreteKeys | discreteKeys_
KeyVector | continuousKeys_
| Record continuous keys for book-keeping.
Protected Attributes inherited from gtsam::Factor
KeyVector | keys_
| The keys involved in this factor.

## Constructor & Destructor Documentation

## MixtureFactor() [1/2]

gtsam::MixtureFactor::MixtureFactor | ( | const KeyVector & | keys,
|  | const DiscreteKeys & | discreteKeys,
|  | const Factors & | factors,
|  | bool | normalized = false )

inline

Construct from Decision tree.

Parameters

  keys | Vector of keys for continuous factors.
  discreteKeys | Vector of discrete keys.
  factors | Decision tree with of shared factors.
  normalized | Flag indicating if the factor error is already normalized.

## MixtureFactor() [2/2]

template<typename FACTOR>

gtsam::MixtureFactor::MixtureFactor | ( | const KeyVector & | keys,
|  | const DiscreteKeys & | discreteKeys,
|  | const std::vector< boost::shared_ptr< FACTOR > > & | factors,
|  | bool | normalized = false )

inline

Convenience constructor that generates the underlying factor decision tree for us.

Here it is important that the vector of factors has the correct number of elements based on the number of discrete keys and the cardinality of the keys, so that the decision tree is constructed appropriately.

Template Parameters

  FACTOR | The type of the factor shared pointers being passed in. Will be typecast to NonlinearFactor shared pointers.

Parameters

  keys | Vector of keys for continuous factors.
  discreteKeys | Vector of discrete keys.
  factors | Vector of nonlinear factors.
  normalized | Flag indicating if the factor error is already normalized.

## Member Function Documentation

## dim()

size_t gtsam::MixtureFactor::dim | ( |  | ) | const

inline

Get the dimension of the factor (number of rows on linearization).

Returns the dimension of the first component factor.

Returns
  size_t

## equals()

bool gtsam::MixtureFactor::equals | ( | const HybridFactor & | other,
|  | double | tol = 1e-9 ) const

inline override virtual

Check equality.

Reimplemented from gtsam::HybridFactor.

## error() [1/3]

double gtsam::MixtureFactor::error | ( | const HybridValues & | values | ) | const

inline override virtual

Compute error of factor given hybrid values.

Parameters

  values | The continuous Values and the discrete assignment.

Returns
  double The error of this factor.

Reimplemented from gtsam::Factor.

## error() [2/3]

AlgebraicDecisionTree< Key > gtsam::MixtureFactor::error | ( | const Values & | continuousValues | ) | const

inline

Compute error of the MixtureFactor as a tree.

Parameters

  continuousValues | The continuous values for which to compute the error.

Returns
  AlgebraicDecisionTree<Key> A decision tree with the same keys as the factor, and leaf values as the error.

## error() [3/3]

double gtsam::MixtureFactor::error | ( | const Values & | continuousValues,
|  | const DiscreteValues & | discreteValues ) const

inline

Compute error of factor given both continuous and discrete values.

Parameters

  continuousValues | The continuous Values.
  discreteValues | The discrete Values.

Returns
  double The error of this factor.

## nonlinearFactorLogNormalizingConstant()

double gtsam::MixtureFactor::nonlinearFactorLogNormalizingConstant | ( | const sharedFactor & | factor,
|  | const Values & | values ) const

inline

If the component factors are not already normalized, we want to compute their normalizing constants so that the resulting joint distribution is appropriately computed.

Remember, this is the negative normalizing constant for the measurement likelihood (since we are minimizing the negative log-likelihood).

## print()

void gtsam::MixtureFactor::print | ( | const std::string & | s = "",
|  | const KeyFormatter & | keyFormatter = DefaultKeyFormatter ) const

inline override virtual

Testable.

print to stdout

Reimplemented from gtsam::HybridFactor.

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

- /build/gtsam-gchP9J/gtsam-4.2.2+dfsg/gtsam/hybrid/MixtureFactor.h