#include <DiscreteBayesNet.h>
Public Types | |
typedef BayesNet< DiscreteConditional > | Base |
typedef DiscreteConditional | ConditionalType |
typedef std::shared_ptr< This > | shared_ptr |
typedef std::shared_ptr< ConditionalType > | sharedConditional |
typedef DiscreteBayesNet | This |
Public Types inherited from gtsam::BayesNet< DiscreteConditional > | |
typedef std::shared_ptr< DiscreteConditional > | sharedConditional |
A shared pointer to a conditional. More... | |
Public Types inherited from gtsam::FactorGraph< DiscreteConditional > | |
typedef FastVector< sharedFactor >::const_iterator | const_iterator |
typedef DiscreteConditional | FactorType |
factor type More... | |
typedef FastVector< sharedFactor >::iterator | iterator |
typedef std::shared_ptr< DiscreteConditional > | sharedFactor |
Shared pointer to a factor. More... | |
typedef sharedFactor | value_type |
Public Member Functions | |
Standard Constructors | |
DiscreteBayesNet () | |
Construct empty Bayes net. More... | |
template<typename ITERATOR > | |
DiscreteBayesNet (ITERATOR firstConditional, ITERATOR lastConditional) | |
template<class CONTAINER > | |
DiscreteBayesNet (const CONTAINER &conditionals) | |
template<class DERIVEDCONDITIONAL > | |
DiscreteBayesNet (const FactorGraph< DERIVEDCONDITIONAL > &graph) | |
Testable | |
bool | equals (const This &bn, double tol=1e-9) const |
Standard Interface | |
void | add (const DiscreteKey &key, const std::string &spec) |
template<typename... Args> | |
void | add (Args &&... args) |
double | evaluate (const DiscreteValues &values) const |
double | operator() (const DiscreteValues &values) const |
double | logProbability (const DiscreteValues &values) const |
DiscreteValues | sample () const |
do ancestral sampling More... | |
DiscreteValues | sample (DiscreteValues given) const |
do ancestral sampling, given certain variables. More... | |
Wrapper support | |
std::string | markdown (const KeyFormatter &keyFormatter=DefaultKeyFormatter, const DiscreteFactor::Names &names={}) const |
Render as markdown tables. More... | |
std::string | html (const KeyFormatter &keyFormatter=DefaultKeyFormatter, const DiscreteFactor::Names &names={}) const |
Render as html tables. More... | |
Public Member Functions inherited from gtsam::BayesNet< DiscreteConditional > | |
void | print (const std::string &s="BayesNet", const KeyFormatter &formatter=DefaultKeyFormatter) const override |
void | dot (std::ostream &os, const KeyFormatter &keyFormatter=DefaultKeyFormatter, const DotWriter &writer=DotWriter()) const |
Output to graphviz format, stream version. More... | |
std::string | dot (const KeyFormatter &keyFormatter=DefaultKeyFormatter, const DotWriter &writer=DotWriter()) const |
Output to graphviz format string. More... | |
void | saveGraph (const std::string &filename, const KeyFormatter &keyFormatter=DefaultKeyFormatter, const DotWriter &writer=DotWriter()) const |
output to file with graphviz format. More... | |
double | logProbability (const HybridValues &x) const |
double | evaluate (const HybridValues &c) const |
Public Member Functions inherited from gtsam::FactorGraph< DiscreteConditional > | |
FactorGraph (std::initializer_list< std::shared_ptr< DERIVEDFACTOR >> sharedFactors) | |
virtual | ~FactorGraph ()=default |
void | reserve (size_t size) |
IsDerived< DERIVEDFACTOR > | push_back (std::shared_ptr< DERIVEDFACTOR > factor) |
Add a factor directly using a shared_ptr. More... | |
IsDerived< DERIVEDFACTOR > | push_back (const DERIVEDFACTOR &factor) |
IsDerived< DERIVEDFACTOR > | emplace_shared (Args &&... args) |
Emplace a shared pointer to factor of given type. More... | |
IsDerived< DERIVEDFACTOR > | add (std::shared_ptr< DERIVEDFACTOR > factor) |
add is a synonym for push_back. More... | |
std::enable_if< std::is_base_of< FactorType, DERIVEDFACTOR >::value, This >::type & | operator+= (std::shared_ptr< DERIVEDFACTOR > factor) |
Append factor to factor graph. More... | |
std::enable_if< std::is_base_of< FactorType, DERIVEDFACTOR >::value, This >::type & | operator, (std::shared_ptr< DERIVEDFACTOR > factor) |
Overload comma operator to allow for append chaining. More... | |
HasDerivedElementType< ITERATOR > | push_back (ITERATOR firstFactor, ITERATOR lastFactor) |
HasDerivedValueType< ITERATOR > | push_back (ITERATOR firstFactor, ITERATOR lastFactor) |
Push back many factors with an iterator (factors are copied) More... | |
HasDerivedElementType< CONTAINER > | push_back (const CONTAINER &container) |
HasDerivedValueType< CONTAINER > | push_back (const CONTAINER &container) |
Push back non-pointer objects in a container (factors are copied). More... | |
void | add (const FACTOR_OR_CONTAINER &factorOrContainer) |
This & | operator+= (const FACTOR_OR_CONTAINER &factorOrContainer) |
std::enable_if< std::is_base_of< This, typename CLIQUE::FactorGraphType >::value >::type | push_back (const BayesTree< CLIQUE > &bayesTree) |
FactorIndices | add_factors (const CONTAINER &factors, bool useEmptySlots=false) |
bool | equals (const This &fg, double tol=1e-9) const |
Check equality up to tolerance. More... | |
size_t | size () const |
bool | empty () const |
const sharedFactor | at (size_t i) const |
sharedFactor & | at (size_t i) |
std::shared_ptr< F > | at (size_t i) |
const std::shared_ptr< F > | at (size_t i) const |
Const version of templated at method. More... | |
const sharedFactor | operator[] (size_t i) const |
sharedFactor & | operator[] (size_t i) |
const_iterator | begin () const |
const_iterator | end () const |
sharedFactor | front () const |
sharedFactor | back () const |
double | error (const HybridValues &values) const |
iterator | begin () |
iterator | end () |
virtual void | resize (size_t size) |
void | remove (size_t i) |
void | replace (size_t index, sharedFactor factor) |
iterator | erase (iterator item) |
iterator | erase (iterator first, iterator last) |
void | dot (std::ostream &os, const KeyFormatter &keyFormatter=DefaultKeyFormatter, const DotWriter &writer=DotWriter()) const |
Output to graphviz format, stream version. More... | |
std::string | dot (const KeyFormatter &keyFormatter=DefaultKeyFormatter, const DotWriter &writer=DotWriter()) const |
Output to graphviz format string. More... | |
void | saveGraph (const std::string &filename, const KeyFormatter &keyFormatter=DefaultKeyFormatter, const DotWriter &writer=DotWriter()) const |
output to file with graphviz format. More... | |
size_t | nrFactors () const |
KeySet | keys () const |
KeyVector | keyVector () const |
bool | exists (size_t idx) const |
Additional Inherited Members | |
Protected Member Functions inherited from gtsam::BayesNet< DiscreteConditional > | |
BayesNet () | |
BayesNet (ITERATOR firstConditional, ITERATOR lastConditional) | |
BayesNet (std::initializer_list< sharedConditional > conditionals) | |
Protected Member Functions inherited from gtsam::FactorGraph< DiscreteConditional > | |
bool | isEqual (const FactorGraph &other) const |
Check exact equality of the factor pointers. Useful for derived ==. More... | |
FactorGraph () | |
FactorGraph (ITERATOR firstFactor, ITERATOR lastFactor) | |
FactorGraph (const CONTAINER &factors) | |
Protected Attributes inherited from gtsam::FactorGraph< DiscreteConditional > | |
FastVector< sharedFactor > | factors_ |
A Bayes net made from discrete conditional distributions.
Definition at line 38 of file DiscreteBayesNet.h.
Definition at line 40 of file DiscreteBayesNet.h.
Definition at line 42 of file DiscreteBayesNet.h.
typedef std::shared_ptr<This> gtsam::DiscreteBayesNet::shared_ptr |
Definition at line 43 of file DiscreteBayesNet.h.
typedef std::shared_ptr<ConditionalType> gtsam::DiscreteBayesNet::sharedConditional |
Definition at line 44 of file DiscreteBayesNet.h.
Definition at line 41 of file DiscreteBayesNet.h.
|
inline |
Construct empty Bayes net.
Definition at line 50 of file DiscreteBayesNet.h.
|
inline |
Construct from iterator over conditionals
Definition at line 54 of file DiscreteBayesNet.h.
|
inlineexplicit |
Construct from container of factors (shared_ptr or plain objects)
Definition at line 59 of file DiscreteBayesNet.h.
|
inline |
Implicit copy/downcast constructor to override explicit template container constructor
Definition at line 65 of file DiscreteBayesNet.h.
|
inline |
Add a DiscreteCondtional
Definition at line 91 of file DiscreteBayesNet.h.
|
inline |
Add a DiscreteDistribution using a table or a string
Definition at line 85 of file DiscreteBayesNet.h.
Check equality
Definition at line 29 of file DiscreteBayesNet.cpp.
double gtsam::DiscreteBayesNet::evaluate | ( | const DiscreteValues & | values | ) | const |
Definition at line 43 of file DiscreteBayesNet.cpp.
std::string gtsam::DiscreteBayesNet::html | ( | const KeyFormatter & | keyFormatter = DefaultKeyFormatter , |
const DiscreteFactor::Names & | names = {} |
||
) | const |
Render as html tables.
Definition at line 84 of file DiscreteBayesNet.cpp.
double gtsam::DiscreteBayesNet::logProbability | ( | const DiscreteValues & | values | ) | const |
Definition at line 34 of file DiscreteBayesNet.cpp.
std::string gtsam::DiscreteBayesNet::markdown | ( | const KeyFormatter & | keyFormatter = DefaultKeyFormatter , |
const DiscreteFactor::Names & | names = {} |
||
) | const |
Render as markdown tables.
Definition at line 72 of file DiscreteBayesNet.cpp.
|
inline |
Definition at line 99 of file DiscreteBayesNet.h.
DiscreteValues gtsam::DiscreteBayesNet::sample | ( | ) | const |
do ancestral sampling
Assumes the Bayes net is reverse topologically sorted, i.e. last conditional will be sampled first. If the Bayes net resulted from eliminating a factor graph, this is true for the elimination ordering.
Definition at line 52 of file DiscreteBayesNet.cpp.
DiscreteValues gtsam::DiscreteBayesNet::sample | ( | DiscreteValues | given | ) | const |
do ancestral sampling, given certain variables.
Assumes the Bayes net is reverse topologically sorted and that the Bayes net does not contain any conditionals for the given values.
Definition at line 57 of file DiscreteBayesNet.cpp.