Public Types | List of all members
gtsam::DiscreteConditional Class Reference

#include <DiscreteConditional.h>

Inheritance diagram for gtsam::DiscreteConditional:
Inheritance graph
[legend]

Public Types

typedef Conditional< BaseFactor, ThisBaseConditional
 Typedef to our conditional base class. More...
 
typedef DecisionTreeFactor BaseFactor
 Typedef to our factor base class. More...
 
typedef boost::shared_ptr< Thisshared_ptr
 shared_ptr to this class More...
 
typedef boost::shared_ptr< ValuessharedValues
 
typedef DiscreteConditional This
 Typedef to this class. More...
 
typedef Assignment< KeyValues
 
- Public Types inherited from gtsam::DecisionTreeFactor
typedef DiscreteFactor Base
 Typedef to base class. More...
 
typedef boost::shared_ptr< DecisionTreeFactorshared_ptr
 
typedef DecisionTreeFactor This
 
- Public Types inherited from gtsam::DiscreteFactor
typedef Factor Base
 Our base class. More...
 
typedef boost::shared_ptr< DiscreteFactorshared_ptr
 shared_ptr to this class More...
 
typedef boost::shared_ptr< ValuessharedValues
 
typedef DiscreteFactor This
 This class. More...
 
typedef Assignment< KeyValues
 
- Public Types inherited from gtsam::Factor
typedef KeyVector::const_iterator const_iterator
 Const iterator over keys. More...
 
typedef KeyVector::iterator iterator
 Iterator over keys. More...
 
- Public Types inherited from gtsam::Potentials
typedef AlgebraicDecisionTree< KeyADT
 
- Public Types inherited from gtsam::AlgebraicDecisionTree< Key >
typedef DecisionTree< Key, double > Super
 
- Public Types inherited from gtsam::DecisionTree< Key, double >
typedef boost::function< double(const double &, const double &)> Binary
 
typedef std::pair< Key, size_tLabelC
 
typedef Node::Ptr NodePtr
 
typedef boost::function< double(const double &)> Unary
 
- Public Types inherited from gtsam::Conditional< DecisionTreeFactor, DiscreteConditional >
typedef boost::iterator_range< typename DecisionTreeFactor::const_iteratorFrontals
 
typedef boost::iterator_range< typename DecisionTreeFactor::const_iteratorParents
 

Public Member Functions

Testable
void print (const std::string &s="Discrete Conditional: ", const KeyFormatter &formatter=DefaultKeyFormatter) const override
 GTSAM-style print. More...
 
bool equals (const DiscreteFactor &other, double tol=1e-9) const override
 GTSAM-style equals. More...
 
Standard Interface
void printSignature (const std::string &s="Discrete Conditional: ", const KeyFormatter &formatter=DefaultKeyFormatter) const
 print index signature only More...
 
double operator() (const Values &values) const override
 Evaluate, just look up in AlgebraicDecisonTree. More...
 
DecisionTreeFactor::shared_ptr toFactor () const
 
ADT choose (const Assignment< Key > &parentsValues) const
 
size_t solve (const Values &parentsValues) const
 
size_t sample (const Values &parentsValues) const
 
Advanced Interface
void solveInPlace (Values &parentsValues) const
 solve a conditional, in place More...
 
void sampleInPlace (Values &parentsValues) const
 sample in place, stores result in partial solution More...
 
- Public Member Functions inherited from gtsam::DecisionTreeFactor
 DecisionTreeFactor ()
 
 DecisionTreeFactor (const DiscreteKeys &keys, const ADT &potentials)
 
template<class SOURCE >
 DecisionTreeFactor (const DiscreteKeys &keys, SOURCE table)
 
 DecisionTreeFactor (const DiscreteConditional &c)
 
DecisionTreeFactor operator* (const DecisionTreeFactor &f) const override
 multiply two factors More...
 
DecisionTreeFactor operator/ (const DecisionTreeFactor &f) const
 divide by factor f (safely) More...
 
DecisionTreeFactor toDecisionTreeFactor () const override
 Convert into a decisiontree. More...
 
shared_ptr sum (size_t nrFrontals) const
 Create new factor by summing all values with the same separator values. More...
 
shared_ptr sum (const Ordering &keys) const
 Create new factor by summing all values with the same separator values. More...
 
shared_ptr max (size_t nrFrontals) const
 Create new factor by maximizing over all values with the same separator values. More...
 
DecisionTreeFactor apply (const DecisionTreeFactor &f, ADT::Binary op) const
 
shared_ptr combine (size_t nrFrontals, ADT::Binary op) const
 
shared_ptr combine (const Ordering &keys, ADT::Binary op) const
 
- Public Member Functions inherited from gtsam::DiscreteFactor
 DiscreteFactor ()
 
template<typename CONTAINER >
 DiscreteFactor (const CONTAINER &keys)
 
virtual ~DiscreteFactor ()
 Virtual destructor. More...
 
void print (const std::string &s="DiscreteFactor\n", const KeyFormatter &formatter=DefaultKeyFormatter) const override
 print More...
 
virtual bool empty () const
 
- Public Member Functions inherited from gtsam::Factor
virtual ~Factor ()=default
 Default destructor. More...
 
KeyVectorkeys ()
 
iterator begin ()
 
iterator end ()
 
virtual void printKeys (const std::string &s="Factor", const KeyFormatter &formatter=DefaultKeyFormatter) const
 print only keys More...
 
Key front () const
 First key. More...
 
Key back () const
 Last key. More...
 
const_iterator find (Key key) const
 find More...
 
const KeyVectorkeys () const
 Access the factor's involved variable keys. More...
 
const_iterator begin () const
 
const_iterator end () const
 
size_t size () const
 
- Public Member Functions inherited from gtsam::Potentials
size_t cardinality (Key j) const
 
GTSAM_EXPORT bool equals (const Potentials &other, double tol=1e-9) const
 
GTSAM_EXPORT Potentials ()
 
GTSAM_EXPORT Potentials (const DiscreteKeys &keys, const ADT &decisionTree)
 
template<class SOURCE >
 Potentials (const DiscreteKeys &keys, SOURCE table)
 
GTSAM_EXPORT void print (const std::string &s="Potentials: ", const KeyFormatter &formatter=DefaultKeyFormatter) const
 
- Public Member Functions inherited from gtsam::AlgebraicDecisionTree< Key >
 AlgebraicDecisionTree ()
 
 AlgebraicDecisionTree (const Super &add)
 
 AlgebraicDecisionTree (const Key &label, double y1, double y2)
 
 AlgebraicDecisionTree (const typename Super::LabelC &labelC, double y1, double y2)
 
 AlgebraicDecisionTree (const std::vector< typename Super::LabelC > &labelCs, const std::vector< double > &ys)
 
 AlgebraicDecisionTree (const std::vector< typename Super::LabelC > &labelCs, const std::string &table)
 
 AlgebraicDecisionTree (Iterator begin, Iterator end, const Key &label)
 
 AlgebraicDecisionTree (const AlgebraicDecisionTree< M > &other, const std::map< M, Key > &map)
 
AlgebraicDecisionTree operator* (const AlgebraicDecisionTree &g) const
 
AlgebraicDecisionTree operator+ (const AlgebraicDecisionTree &g) const
 
AlgebraicDecisionTree operator/ (const AlgebraicDecisionTree &g) const
 
AlgebraicDecisionTree sum (const Key &label, size_t cardinality) const
 
AlgebraicDecisionTree sum (const typename Super::LabelC &labelC) const
 
- Public Member Functions inherited from gtsam::DecisionTree< Key, double >
 DecisionTree (const double &y)
 
 DecisionTree (const Key &label, const double &y1, const double &y2)
 
 DecisionTree (const LabelC &label, const double &y1, const double &y2)
 
 DecisionTree (const std::vector< LabelC > &labelCs, const std::vector< double > &ys)
 
 DecisionTree (const std::vector< LabelC > &labelCs, const std::string &table)
 
 DecisionTree (Iterator begin, Iterator end, const Key &label)
 
 DecisionTree (const Key &label, const DecisionTree &f0, const DecisionTree &f1)
 
 DecisionTree (const DecisionTree< M, X > &other, const std::map< M, Key > &map, boost::function< double(const X &)> op)
 
 DecisionTree (const NodePtr &root)
 
NodePtr compose (Iterator begin, Iterator end, const Key &label) const
 
void print (const std::string &s="DecisionTree") const
 
bool equals (const DecisionTree &other, double tol=1e-9) const
 
virtual ~DecisionTree ()
 
bool operator== (const DecisionTree &q) const
 
const double & operator() (const Assignment< Key > &x) const
 
DecisionTree apply (const Unary &op) const
 
DecisionTree apply (const DecisionTree &g, const Binary &op) const
 
DecisionTree choose (const Key &label, size_t index) const
 
DecisionTree combine (const Key &label, size_t cardinality, const Binary &op) const
 
DecisionTree combine (const LabelC &labelC, const Binary &op) const
 
void dot (std::ostream &os, bool showZero=true) const
 
void dot (const std::string &name, bool showZero=true) const
 
- Public Member Functions inherited from gtsam::Conditional< DecisionTreeFactor, DiscreteConditional >
void print (const std::string &s="Conditional", const KeyFormatter &formatter=DefaultKeyFormatter) const
 
bool equals (const This &c, double tol=1e-9) const
 
size_t nrFrontals () const
 
size_t nrParents () const
 
Key firstFrontalKey () const
 
Frontals frontals () const
 
Parents parents () const
 
DecisionTreeFactor::const_iterator beginFrontals () const
 
DecisionTreeFactor::const_iterator endFrontals () const
 
DecisionTreeFactor::const_iterator beginParents () const
 
DecisionTreeFactor::const_iterator endParents () const
 
size_tnrFrontals ()
 
DecisionTreeFactor::iterator beginFrontals ()
 
DecisionTreeFactor::iterator endFrontals ()
 
DecisionTreeFactor::iterator beginParents ()
 
DecisionTreeFactor::iterator endParents ()
 

Standard Constructors

 DiscreteConditional ()
 
 DiscreteConditional (size_t nFrontals, const DecisionTreeFactor &f)
 
 DiscreteConditional (const Signature &signature)
 
 DiscreteConditional (const DecisionTreeFactor &joint, const DecisionTreeFactor &marginal)
 
 DiscreteConditional (const DecisionTreeFactor &joint, const DecisionTreeFactor &marginal, const Ordering &orderedKeys)
 
template<typename ITERATOR >
static shared_ptr Combine (ITERATOR firstConditional, ITERATOR lastConditional)
 

Additional Inherited Members

- Public Attributes inherited from gtsam::DecisionTree< Key, double >
NodePtr root_
 
- Protected Member Functions inherited from gtsam::Factor
 Factor ()
 
template<typename CONTAINER >
 Factor (const CONTAINER &keys)
 
template<typename ITERATOR >
 Factor (ITERATOR first, ITERATOR last)
 
bool equals (const This &other, double tol=1e-9) const
 check equality More...
 
- Protected Member Functions inherited from gtsam::Potentials
 Potentials (const ADT &potentials)
 
- Protected Member Functions inherited from gtsam::DecisionTree< Key, double >
NodePtr convert (const typename DecisionTree< M, X >::NodePtr &f, const std::map< M, Key > &map, boost::function< double(const X &)> op)
 
NodePtr create (It begin, It end, ValueIt beginY, ValueIt endY) const
 
 DecisionTree ()
 
- Protected Member Functions inherited from gtsam::Conditional< DecisionTreeFactor, DiscreteConditional >
 Conditional ()
 
 Conditional (size_t nrFrontals)
 
- Static Protected Member Functions inherited from gtsam::Factor
template<typename CONTAINER >
static Factor FromKeys (const CONTAINER &keys)
 
template<typename ITERATOR >
static Factor FromIterators (ITERATOR first, ITERATOR last)
 
- Static Protected Member Functions inherited from gtsam::Potentials
static GTSAM_EXPORT double safe_div (const double &a, const double &b)
 
- Protected Attributes inherited from gtsam::Factor
KeyVector keys_
 The keys involved in this factor. More...
 
- Protected Attributes inherited from gtsam::Potentials
std::map< Key, size_tcardinalities_
 Cardinality for each key, used in combine. More...
 
- Protected Attributes inherited from gtsam::Conditional< DecisionTreeFactor, DiscreteConditional >
size_t nrFrontals_
 

Detailed Description

Discrete Conditional Density Derives from DecisionTreeFactor

Definition at line 35 of file DiscreteConditional.h.

Member Typedef Documentation

Typedef to our conditional base class.

Definition at line 43 of file DiscreteConditional.h.

Typedef to our factor base class.

Definition at line 42 of file DiscreteConditional.h.

typedef boost::shared_ptr<This> gtsam::DiscreteConditional::shared_ptr

shared_ptr to this class

Definition at line 41 of file DiscreteConditional.h.

Definition at line 48 of file DiscreteConditional.h.

Typedef to this class.

Definition at line 40 of file DiscreteConditional.h.

A map from keys to values.. TODO: Again, do we need this???

Definition at line 47 of file DiscreteConditional.h.

Constructor & Destructor Documentation

gtsam::DiscreteConditional::DiscreteConditional ( )
inline

default constructor needed for serialization

Definition at line 54 of file DiscreteConditional.h.

gtsam::DiscreteConditional::DiscreteConditional ( size_t  nFrontals,
const DecisionTreeFactor f 
)

constructor from factor

Definition at line 41 of file DiscreteConditional.cpp.

gtsam::DiscreteConditional::DiscreteConditional ( const Signature signature)

Construct from signature

Definition at line 65 of file DiscreteConditional.cpp.

gtsam::DiscreteConditional::DiscreteConditional ( const DecisionTreeFactor joint,
const DecisionTreeFactor marginal 
)

construct P(X|Y)=P(X,Y)/P(Y) from P(X,Y) and P(Y)

Definition at line 47 of file DiscreteConditional.cpp.

gtsam::DiscreteConditional::DiscreteConditional ( const DecisionTreeFactor joint,
const DecisionTreeFactor marginal,
const Ordering orderedKeys 
)

construct P(X|Y)=P(X,Y)/P(Y) from P(X,Y) and P(Y)

Definition at line 57 of file DiscreteConditional.cpp.

Member Function Documentation

Potentials::ADT gtsam::DiscreteConditional::choose ( const Assignment< Key > &  parentsValues) const

Restrict to given parent values, returns AlgebraicDecisionDiagram

Definition at line 100 of file DiscreteConditional.cpp.

template<typename ITERATOR >
DiscreteConditional::shared_ptr gtsam::DiscreteConditional::Combine ( ITERATOR  firstConditional,
ITERATOR  lastConditional 
)
static

Combine several conditional into a single one. The conditionals must be given in increasing order, meaning that the parents of any conditional may not include a conditional coming before it.

Parameters
firstConditionalIterator to the first conditional to combine, must dereference to a shared_ptr<DiscreteConditional>.
lastConditionalIterator to after the last conditional to combine, must dereference to a shared_ptr<DiscreteConditional>.

Definition at line 151 of file DiscreteConditional.h.

bool gtsam::DiscreteConditional::equals ( const DiscreteFactor other,
double  tol = 1e-9 
) const
overridevirtual

GTSAM-style equals.

Reimplemented from gtsam::DecisionTreeFactor.

Definition at line 88 of file DiscreteConditional.cpp.

double gtsam::DiscreteConditional::operator() ( const Values values) const
inlineoverridevirtual

Evaluate, just look up in AlgebraicDecisonTree.

Reimplemented from gtsam::DecisionTreeFactor.

Definition at line 105 of file DiscreteConditional.h.

void gtsam::DiscreteConditional::print ( const std::string &  s = "Discrete Conditional: ",
const KeyFormatter formatter = DefaultKeyFormatter 
) const
overridevirtual

GTSAM-style print.

Reimplemented from gtsam::DecisionTreeFactor.

Definition at line 70 of file DiscreteConditional.cpp.

void gtsam::DiscreteConditional::printSignature ( const std::string &  s = "Discrete Conditional: ",
const KeyFormatter formatter = DefaultKeyFormatter 
) const
inline

print index signature only

Definition at line 98 of file DiscreteConditional.h.

size_t gtsam::DiscreteConditional::sample ( const Values parentsValues) const

sample

Parameters
parentsValuesKnown values of the parents
Returns
sample from conditional

Definition at line 186 of file DiscreteConditional.cpp.

void gtsam::DiscreteConditional::sampleInPlace ( Values parentsValues) const

sample in place, stores result in partial solution

Definition at line 153 of file DiscreteConditional.cpp.

size_t gtsam::DiscreteConditional::solve ( const Values parentsValues) const

solve a conditional

Parameters
parentsValuesKnown values of the parents
Returns
MPE value of the child (1 frontal variable).

Definition at line 161 of file DiscreteConditional.cpp.

void gtsam::DiscreteConditional::solveInPlace ( Values parentsValues) const

solve a conditional, in place

Definition at line 120 of file DiscreteConditional.cpp.

DecisionTreeFactor::shared_ptr gtsam::DiscreteConditional::toFactor ( ) const
inline

Convert to a factor

Definition at line 110 of file DiscreteConditional.h.


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


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:58:08