GTSAM
4.0.2
C++ library for smoothing and mapping (SAM)
|
#include <HybridConditional.h>
Public Types | |
typedef HybridConditional | This |
Typedef to this class. | |
typedef std::shared_ptr< This > | shared_ptr |
shared_ptr to this class | |
typedef HybridFactor | BaseFactor |
Typedef to our factor base class. | |
typedef Conditional< BaseFactor, This > | BaseConditional |
Typedef to our conditional base class. | |
typedef Factor | Base |
Our base class. | |
typedef KeyVector::iterator | iterator |
Iterator over keys. | |
typedef KeyVector::const_iterator | const_iterator |
Const iterator over keys. | |
typedef std::pair< typename HybridFactor ::const_iterator, typename HybridFactor ::const_iterator > | ConstFactorRange |
typedef ConstFactorRangeIterator | Frontals |
typedef ConstFactorRangeIterator | Parents |
Public Member Functions | |
Standard Constructors | |
HybridConditional ()=default | |
Default constructor needed for serialization. | |
HybridConditional (const KeyVector &continuousKeys, const DiscreteKeys &discreteKeys, size_t nFrontals) | |
Construct a new Hybrid Conditional object. More... | |
HybridConditional (const KeyVector &continuousFrontals, const DiscreteKeys &discreteFrontals, const KeyVector &continuousParents, const DiscreteKeys &discreteParents) | |
Construct a new Hybrid Conditional object. More... | |
HybridConditional (const std::shared_ptr< GaussianConditional > &continuousConditional) | |
Construct a new Hybrid Conditional object. More... | |
HybridConditional (const std::shared_ptr< DiscreteConditional > &discreteConditional) | |
Construct a new Hybrid Conditional object. More... | |
HybridConditional (const std::shared_ptr< GaussianMixture > &gaussianMixture) | |
Construct a new Hybrid Conditional object. More... | |
Testable | |
void | print (const std::string &s="Hybrid Conditional: ", const KeyFormatter &formatter=DefaultKeyFormatter) const override |
GTSAM-style print. | |
bool | equals (const HybridFactor &other, double tol=1e-9) const override |
GTSAM-style equals. | |
Standard Interface | |
GaussianMixture::shared_ptr | asMixture () const |
Return HybridConditional as a GaussianMixture. More... | |
GaussianConditional::shared_ptr | asGaussian () const |
Return HybridConditional as a GaussianConditional. More... | |
DiscreteConditional::shared_ptr | asDiscrete () const |
Return conditional as a DiscreteConditional. More... | |
std::shared_ptr< Factor > | inner () const |
Get the type-erased pointer to the inner type. | |
double | error (const HybridValues &values) const override |
Return the error of the underlying conditional. | |
double | logProbability (const HybridValues &values) const override |
Return the log-probability (or density) of the underlying conditional. | |
double | logNormalizationConstant () const override |
double | evaluate (const HybridValues &values) const override |
Return the probability (or density) of the underlying conditional. | |
bool | frontalsIn (const VectorValues &measurements) const |
Check if VectorValues measurements contains all frontal keys. | |
Testable | |
bool | equals (const This &other, double tol=1e-9) const |
check equality | |
virtual void | printKeys (const std::string &s="Factor", const KeyFormatter &formatter=DefaultKeyFormatter) const |
print only keys | |
Standard Interface | |
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. | |
Standard Interface | |
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 |
const_iterator | end () const |
size_t | size () const |
Advanced Interface | |
KeyVector & | keys () |
iterator | begin () |
iterator | end () |
Testable | |
bool | equals (const This &c, double tol=1e-9) const |
Standard Interface | |
size_t | nrFrontals () const |
size_t | nrParents () const |
Key | firstFrontalKey () const |
Frontals | frontals () const |
Parents | parents () const |
double | operator() (const HybridValues &x) const |
Evaluate probability density, sugar. | |
double | normalizationConstant () const |
Static Protected Member Functions | |
Standard Constructors | |
template<typename CONTAINER > | |
static Factor | FromKeys (const CONTAINER &keys) |
template<typename ITERATOR > | |
static Factor | FromIterators (ITERATOR first, ITERATOR last) |
Protected Attributes | |
std::shared_ptr< Factor > | inner_ |
Type-erased pointer to the inner type. | |
DiscreteKeys | discreteKeys_ |
KeyVector | continuousKeys_ |
Record continuous keys for book-keeping. | |
KeyVector | keys_ |
The keys involved in this factor. | |
size_t | nrFrontals_ |
Advanced Interface | |
size_t & | nrFrontals () |
HybridFactor ::const_iterator | beginFrontals () const |
HybridFactor ::iterator | beginFrontals () |
HybridFactor ::const_iterator | endFrontals () const |
HybridFactor ::iterator | endFrontals () |
HybridFactor ::const_iterator | beginParents () const |
HybridFactor ::iterator | beginParents () |
HybridFactor ::const_iterator | endParents () const |
HybridFactor ::iterator | endParents () |
static bool | CheckInvariants (const HybridConditional &conditional, const VALUES &x) |
Hybrid Conditional Density
As a type-erased variant of:
The reason why this is important is that Conditional<T>
is a CRTP class. CRTP is static polymorphism such that all CRTP classes, while bearing the same name, are different classes not sharing a vtable. This prevents them from being contained in any container, and thus it is impossible to dynamically cast between them. A better option, as illustrated here, is treating them as an implementation detail - such that the hybrid mechanism does not know what is inside the HybridConditional. This prevents us from having diamond inheritances, and neutralized the need to change other components of GTSAM to make hybrid elimination work.
A great reference to the type-erasure pattern is Eduardo Madrid's CppCon talk (https://www.youtube.com/watch?v=s082Qmd_nHs).
|
inherited |
A mini implementation of an iterator range, to share const views of frontals and parents.
|
inherited |
View of the frontal keys (call frontals())
|
inherited |
View of the separator keys (call parents())
|
inline |
Construct a new Hybrid Conditional object.
continuousKeys | Vector of keys for continuous variables. |
discreteKeys | Keys and cardinalities for discrete variables. |
nFrontals | The number of frontal variables in the conditional. |
gtsam::HybridConditional::HybridConditional | ( | const KeyVector & | continuousFrontals, |
const DiscreteKeys & | discreteFrontals, | ||
const KeyVector & | continuousParents, | ||
const DiscreteKeys & | discreteParents | ||
) |
Construct a new Hybrid Conditional object.
continuousFrontals | Vector of keys for continuous variables. |
discreteFrontals | Keys and cardinalities for discrete variables. |
continuousParents | Vector of keys for parent continuous variables. |
discreteParents | Keys and cardinalities for parent discrete variables. |
gtsam::HybridConditional::HybridConditional | ( | const std::shared_ptr< GaussianConditional > & | continuousConditional | ) |
Construct a new Hybrid Conditional object.
continuousConditional | Conditional used to create the HybridConditional. |
gtsam::HybridConditional::HybridConditional | ( | const std::shared_ptr< DiscreteConditional > & | discreteConditional | ) |
Construct a new Hybrid Conditional object.
discreteConditional | Conditional used to create the HybridConditional. |
gtsam::HybridConditional::HybridConditional | ( | const std::shared_ptr< GaussianMixture > & | gaussianMixture | ) |
Construct a new Hybrid Conditional object.
gaussianMixture | Gaussian Mixture Conditional used to create the HybridConditional. |
|
inline |
Return conditional as a DiscreteConditional.
|
inline |
Return HybridConditional as a GaussianConditional.
|
inline |
Return HybridConditional as a GaussianMixture.
|
inlineinherited |
Iterator at beginning of involved variable keys
|
inlineinherited |
Iterator at beginning of involved variable keys
|
inlineinherited |
Iterator pointing to first frontal key.
|
inlineinherited |
Mutable iterator pointing to first frontal key.
|
inlineinherited |
Iterator pointing to the first parent key.
|
inlineinherited |
Mutable iterator pointing to the first parent key.
|
staticinherited |
Check invariants of this conditional, given the values x
. It tests:
conditional | The conditional to test, as a reference to the derived type. |
VALUES | HybridValues, or a more narrow type like DiscreteValues. |
|
inlineinherited |
Iterator at end of involved variable keys
|
inlineinherited |
Iterator at end of involved variable keys
|
inlineinherited |
Iterator pointing past the last frontal key.
|
inlineinherited |
Mutable iterator pointing past the last frontal key.
|
inlineinherited |
Iterator pointing past the last parent key.
|
inlineinherited |
Mutable iterator pointing past the last parent key.
|
inherited |
check equality
|
inlineinherited |
Convenience function to get the first frontal key
|
inlinestaticprotectedinherited |
Construct factor from iterator keys. This is called internally from derived factor static factor methods, as a workaround for not being able to call the protected constructors above.
|
inlinestaticprotectedinherited |
Construct factor from container of keys. This is called internally from derived factor static factor methods, as a workaround for not being able to call the protected constructors above.
|
inlineinherited |
return a view of the frontal keys
|
inlineinherited |
|
overridevirtual |
Return the log normalization constant. Note this is 0.0 for discrete and hybrid conditionals, but depends on the continuous parameters for Gaussian conditionals.
Reimplemented from gtsam::Conditional< HybridFactor, HybridConditional >.
|
inherited |
Non-virtual, exponentiate logNormalizationConstant.
|
inlineinherited |
return the number of frontals
|
inlineinherited |
Mutable version of nrFrontals
|
inlineinherited |
return the number of parents
|
inlineinherited |
return a view of the parent keys
|
inlineinherited |
|
protectedinherited |
The first nrFrontal variables are frontal and the rest are parents.