gtsam
Loading...
Searching...
No Matches
gtsam::Conditional< FACTOR, DERIVEDCONDITIONAL > Class Template Reference

Advanced Interface

FACTOR::const_iterator beginFrontals () const
 Iterator pointing to first frontal key.
FACTOR::const_iterator endFrontals () const
 Iterator pointing past the last frontal key.
FACTOR::const_iterator beginParents () const
 Iterator pointing to the first parent key.
FACTOR::const_iterator endParents () const
 Iterator pointing past the last parent key.
size_t & nrFrontals ()
 Mutable version of nrFrontals.
FACTOR::iterator beginFrontals ()
 Mutable iterator pointing to first frontal key.
FACTOR::iterator endFrontals ()
 Mutable iterator pointing past the last frontal key.
FACTOR::iterator beginParents ()
 Mutable iterator pointing to the first parent key.
FACTOR::iterator endParents ()
 Mutable iterator pointing past the last parent key.
template<class VALUES>
static bool CheckInvariants (const DERIVEDCONDITIONAL &conditional, const VALUES &x)
 Check invariants of this conditional, given the values x.

Public Member Functions

Testable
void print (const std::string &s="Conditional", const KeyFormatter &formatter=DefaultKeyFormatter) const
 print with optional formatter
bool equals (const This &c, double tol=1e-9) const
 check equality
Standard Interface
size_t nrFrontals () const
 return the number of frontals
size_t nrParents () const
 return the number of parents
Key firstFrontalKey () const
 Convenience function to get the first frontal key.
Frontals frontals () const
 return a view of the frontal keys
Parents parents () const
 return a view of the parent keys
virtual double logProbability (const HybridValues &c) const
 All conditional types need to implement a logProbability function, for which exp(logProbability(x)) = evaluate(x).
virtual double evaluate (const HybridValues &c) const
 All conditional types need to implement an evaluate function, that yields a true probability.
double operator() (const HybridValues &x) const
 Evaluate probability density, sugar.
virtual double negLogConstant () const
 All conditional types need to implement this as the negative log of the normalization constant to make it such that error>=0.

Public Types

typedef std::pair< typename FACTOR::const_iterator, typename FACTOR::const_iterator > ConstFactorRange
 A mini implementation of an iterator range, to share const views of frontals and parents.
typedef ConstFactorRangeIterator Frontals
 View of the frontal keys (call frontals()).
typedef ConstFactorRangeIterator Parents
 View of the separator keys (call parents()).

Classes

struct  ConstFactorRangeIterator

Protected Member Functions

Standard Constructors
 Conditional ()
 Empty Constructor to make serialization possible.
 Conditional (size_t nrFrontals)
 Constructor.

Protected Attributes

size_t nrFrontals_
 The first nrFrontal variables are frontal and the rest are parents.

Member Function Documentation

◆ CheckInvariants()

template<class FACTOR, class DERIVEDCONDITIONAL>
template<class VALUES>
bool gtsam::Conditional< FACTOR, DERIVEDCONDITIONAL >::CheckInvariants ( const DERIVEDCONDITIONAL & conditional,
const VALUES & x )
static

Check invariants of this conditional, given the values x.

It tests:

  • evaluate >= 0.0
  • evaluate(x) == conditional(x)
  • exp(logProbability(x)) == evaluate(x)
  • negLogConstant() = -log(normalizationConstant())
  • error >= 0.0
  • logProbability(x) == -(negLogConstant() + error(x))
Parameters
conditionalThe conditional to test, as a reference to the derived type.
Template Parameters
VALUESHybridValues, or a more narrow type like DiscreteValues.

◆ evaluate()

template<class FACTOR, class DERIVEDCONDITIONAL>
double gtsam::Conditional< FACTOR, DERIVEDCONDITIONAL >::evaluate ( const HybridValues & c) const
virtual

All conditional types need to implement an evaluate function, that yields a true probability.

The default implementation just exponentiates logProbability.

Reimplemented in gtsam::DiscreteConditional, gtsam::GaussianConditional, gtsam::HybridConditional, gtsam::HybridGaussianConditional, gtsam::SymbolicConditional, and gtsam::TableDistribution.

◆ logProbability()

template<class FACTOR, class DERIVEDCONDITIONAL>
double gtsam::Conditional< FACTOR, DERIVEDCONDITIONAL >::logProbability ( const HybridValues & c) const
virtual

All conditional types need to implement a logProbability function, for which exp(logProbability(x)) = evaluate(x).

Reimplemented in gtsam::DiscreteConditional, gtsam::GaussianConditional, gtsam::HybridConditional, gtsam::HybridGaussianConditional, and gtsam::SymbolicConditional.

◆ negLogConstant()

template<class FACTOR, class DERIVEDCONDITIONAL>
double gtsam::Conditional< FACTOR, DERIVEDCONDITIONAL >::negLogConstant ( ) const
virtual

All conditional types need to implement this as the negative log of the normalization constant to make it such that error>=0.

Returns
double

Reimplemented in gtsam::DiscreteConditional, gtsam::GaussianConditional, gtsam::HybridConditional, and gtsam::HybridGaussianConditional.


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