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

#include <DiscreteBayesNet.h>

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

Public Types

typedef BayesNet< DiscreteConditionalBase
 
typedef DiscreteConditional ConditionalType
 
typedef std::shared_ptr< Thisshared_ptr
 
typedef std::shared_ptr< ConditionalTypesharedConditional
 
typedef DiscreteBayesNet This
 
- Public Types inherited from gtsam::BayesNet< DiscreteConditional >
typedef std::shared_ptr< DiscreteConditionalsharedConditional
 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< DiscreteConditionalsharedFactor
 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 >::typeoperator+= (std::shared_ptr< DERIVEDFACTOR > factor)
 Append factor to factor graph. More...
 
std::enable_if< std::is_base_of< FactorType, DERIVEDFACTOR >::value, This >::typeoperator, (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)
 
Thisoperator+= (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
 
sharedFactorat (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
 
sharedFactoroperator[] (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< sharedFactorfactors_
 

Detailed Description

A Bayes net made from discrete conditional distributions.

Definition at line 38 of file DiscreteBayesNet.h.

Member Typedef Documentation

◆ Base

Definition at line 40 of file DiscreteBayesNet.h.

◆ ConditionalType

Definition at line 42 of file DiscreteBayesNet.h.

◆ shared_ptr

typedef std::shared_ptr<This> gtsam::DiscreteBayesNet::shared_ptr

Definition at line 43 of file DiscreteBayesNet.h.

◆ sharedConditional

Definition at line 44 of file DiscreteBayesNet.h.

◆ This

Definition at line 41 of file DiscreteBayesNet.h.

Constructor & Destructor Documentation

◆ DiscreteBayesNet() [1/4]

gtsam::DiscreteBayesNet::DiscreteBayesNet ( )
inline

Construct empty Bayes net.

Definition at line 50 of file DiscreteBayesNet.h.

◆ DiscreteBayesNet() [2/4]

template<typename ITERATOR >
gtsam::DiscreteBayesNet::DiscreteBayesNet ( ITERATOR  firstConditional,
ITERATOR  lastConditional 
)
inline

Construct from iterator over conditionals

Definition at line 54 of file DiscreteBayesNet.h.

◆ DiscreteBayesNet() [3/4]

template<class CONTAINER >
gtsam::DiscreteBayesNet::DiscreteBayesNet ( const CONTAINER &  conditionals)
inlineexplicit

Construct from container of factors (shared_ptr or plain objects)

Definition at line 59 of file DiscreteBayesNet.h.

◆ DiscreteBayesNet() [4/4]

template<class DERIVEDCONDITIONAL >
gtsam::DiscreteBayesNet::DiscreteBayesNet ( const FactorGraph< DERIVEDCONDITIONAL > &  graph)
inline

Implicit copy/downcast constructor to override explicit template container constructor

Definition at line 65 of file DiscreteBayesNet.h.

Member Function Documentation

◆ add() [1/2]

template<typename... Args>
void gtsam::DiscreteBayesNet::add ( Args &&...  args)
inline

Add a DiscreteCondtional

Definition at line 91 of file DiscreteBayesNet.h.

◆ add() [2/2]

void gtsam::DiscreteBayesNet::add ( const DiscreteKey key,
const std::string &  spec 
)
inline

Add a DiscreteDistribution using a table or a string

Definition at line 85 of file DiscreteBayesNet.h.

◆ equals()

bool gtsam::DiscreteBayesNet::equals ( const This bn,
double  tol = 1e-9 
) const

Check equality

Definition at line 29 of file DiscreteBayesNet.cpp.

◆ evaluate()

double gtsam::DiscreteBayesNet::evaluate ( const DiscreteValues values) const

Definition at line 43 of file DiscreteBayesNet.cpp.

◆ html()

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.

◆ logProbability()

double gtsam::DiscreteBayesNet::logProbability ( const DiscreteValues values) const

Definition at line 34 of file DiscreteBayesNet.cpp.

◆ markdown()

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.

◆ operator()()

double gtsam::DiscreteBayesNet::operator() ( const DiscreteValues values) const
inline

Definition at line 99 of file DiscreteBayesNet.h.

◆ sample() [1/2]

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.

Returns
a sampled value for all variables.

Definition at line 52 of file DiscreteBayesNet.cpp.

◆ sample() [2/2]

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.

Returns
given values extended with sampled value for all other variables.

Definition at line 57 of file DiscreteBayesNet.cpp.


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


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:15:21