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).
|
|
| HybridConditional ()=default |
| | Default constructor needed for serialization.
|
| | HybridConditional (const KeyVector &continuousKeys, const DiscreteKeys &discreteKeys, size_t nFrontals) |
| | Construct a new Hybrid Conditional object.
|
| | HybridConditional (const KeyVector &continuousFrontals, const DiscreteKeys &discreteFrontals, const KeyVector &continuousParents, const DiscreteKeys &discreteParents) |
| | Construct a new Hybrid Conditional object.
|
| | HybridConditional (const std::shared_ptr< GaussianConditional > &continuousConditional) |
| | Construct a new Hybrid Conditional object.
|
| | HybridConditional (const std::shared_ptr< DiscreteConditional > &discreteConditional) |
| | Construct a new Hybrid Conditional object.
|
| | HybridConditional (const std::shared_ptr< HybridGaussianConditional > &hybridGaussianCond) |
| | Construct a new Hybrid Conditional object.
|
| 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.
|
| HybridGaussianConditional::shared_ptr | asHybrid () const |
| | Return HybridConditional as a HybridGaussianConditional.
|
| GaussianConditional::shared_ptr | asGaussian () const |
| | Return HybridConditional as a GaussianConditional.
|
| template<typename T = DiscreteConditional> |
| T::shared_ptr | asDiscrete () const |
| | Return conditional as a DiscreteConditional or specified type T.
|
|
std::shared_ptr< Factor > | inner () const |
| | Get the type-erased pointer to the inner type.
|
| double | error (const HybridValues &hybridValues) const override |
| | Return the error of the underlying conditional.
|
| AlgebraicDecisionTree< Key > | errorTree (const VectorValues &continuousValues) const override |
| | Compute error of the HybridConditional as a tree.
|
| double | logProbability (const HybridValues &values) const override |
| | Return the log-probability (or density) of the underlying conditional.
|
| double | negLogConstant () const override |
| | Return the negative log of the normalization constant.
|
| 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.
|
| std::shared_ptr< Factor > | restrict (const DiscreteValues &assignment) const override |
| | Return a HybridConditional by choosing branches based on the given discrete values.
|
|
| 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.
|
| void | print (const std::string &s="HybridFactor\n", const KeyFormatter &formatter=DefaultKeyFormatter) const override |
| | print
|
|
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.
|
|
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.
|
|
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
|
|
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
|
|
double | operator() (const HybridValues &x) const |
| | Evaluate probability density, sugar.
|
|
HybridFactor::const_iterator | beginFrontals () const |
| | Iterator pointing to first frontal key.
|
|
HybridFactor::const_iterator | endFrontals () const |
| | Iterator pointing past the last frontal key.
|
|
HybridFactor::const_iterator | beginParents () const |
| | Iterator pointing to the first parent key.
|
|
HybridFactor::const_iterator | endParents () const |
| | Iterator pointing past the last parent key.
|
|
|
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.
|
| enum class | Category { None
, Discrete
, Continuous
, Hybrid
} |
| | Enum to help with categorizing hybrid factors.
|
|
typedef HybridFactor | This |
| | This class.
|
|
typedef std::shared_ptr< HybridFactor > | shared_ptr |
| | shared_ptr to this 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 |
| | 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()).
|
|
| static bool | CheckInvariants (const HybridConditional &conditional, const VALUES &x) |
| | Check invariants of this conditional, given the values x.
|
|
| 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.
|
|
| Conditional () |
| | Empty Constructor to make serialization possible.
|
| 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.
|