GTSAM  4.0.2
C++ library for smoothing and mapping (SAM)
Public Types | Protected Types | Protected Member Functions | Protected Attributes | List of all members
gtsam::BayesTree< CLIQUE > Class Template Reference

#include <BayesTree.h>

Inheritance diagram for gtsam::BayesTree< CLIQUE >:
Inheritance graph
[legend]
Collaboration diagram for gtsam::BayesTree< CLIQUE >:
Collaboration graph
[legend]

Public Types

typedef CLIQUE Clique
 The clique type, normally BayesTreeClique.
 
typedef std::shared_ptr< CliquesharedClique
 Shared pointer to a clique.
 
typedef Clique Node
 Synonym for Clique (TODO: remove)
 
typedef sharedClique sharedNode
 Synonym for sharedClique (TODO: remove)
 
typedef CLIQUE::ConditionalType ConditionalType
 
typedef std::shared_ptr< ConditionalType > sharedConditional
 
typedef CLIQUE::BayesNetType BayesNetType
 
typedef std::shared_ptr< BayesNetType > sharedBayesNet
 
typedef CLIQUE::FactorType FactorType
 
typedef std::shared_ptr< FactorType > sharedFactor
 
typedef CLIQUE::FactorGraphType FactorGraphType
 
typedef std::shared_ptr< FactorGraphType > sharedFactorGraph
 
typedef FactorGraphType::Eliminate Eliminate
 
typedef CLIQUE::EliminationTraitsType EliminationTraitsType
 
typedef FastList< sharedCliqueCliques
 
typedef ConcurrentMap< Key, sharedCliqueNodes
 
typedef FastVector< sharedCliqueRoots
 

Protected Types

typedef BayesTree< CLIQUE > This
 
typedef std::shared_ptr< Thisshared_ptr
 

Protected Member Functions

 ~BayesTree ()
 
Thisoperator= (const This &other)
 

Protected Attributes

Nodes nodes_
 
Roots roots_
 

Standard Constructors

 BayesTree ()
 
 BayesTree (const This &other)
 

Testable

bool equals (const This &other, double tol=1e-9) const
 
void print (const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
 

Standard Interface

size_t size () const
 
bool empty () const
 
const Nodesnodes () const
 
sharedClique operator[] (Key j) const
 
const Rootsroots () const
 
const sharedCliqueclique (Key j) const
 
BayesTreeCliqueData getCliqueData () const
 
size_t numCachedSeparatorMarginals () const
 
sharedConditional marginalFactor (Key j, const Eliminate &function=EliminationTraitsType::DefaultEliminate) const
 
sharedFactorGraph joint (Key j1, Key j2, const Eliminate &function=EliminationTraitsType::DefaultEliminate) const
 
sharedBayesNet jointBayesNet (Key j1, Key j2, const Eliminate &function=EliminationTraitsType::DefaultEliminate) const
 

Graph Display

void dot (std::ostream &os, const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
 Output to graphviz format, stream version.
 
std::string dot (const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
 Output to graphviz format string.
 
void saveGraph (const std::string &filename, const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
 output to file with graphviz format.
 

Advanced Interface

template<class BAYESTREE , class GRAPH >
class EliminatableClusterTree
 
void dot (std::ostream &s, sharedClique clique, const KeyFormatter &keyFormatter, int parentnum=0) const
 
void getCliqueData (sharedClique clique, BayesTreeCliqueData *stats) const
 
void removeClique (sharedClique clique)
 
void fillNodesIndex (const sharedClique &subtree)
 
template<class CONTAINER >
Key findParentClique (const CONTAINER &parents) const
 
void clear ()
 
void deleteCachedShortcuts ()
 
void removePath (sharedClique clique, BayesNetType *bn, Cliques *orphans)
 
void removeTop (const KeyVector &keys, BayesNetType *bn, Cliques *orphans)
 
Cliques removeSubtree (const sharedClique &subtree)
 
void insertRoot (const sharedClique &subtree)
 
void addClique (const sharedClique &clique, const sharedClique &parent_clique=sharedClique())
 
void addFactorsToGraph (FactorGraph< FactorType > *graph) const
 

Detailed Description

template<class CLIQUE>
class gtsam::BayesTree< CLIQUE >

Bayes tree

Template Parameters
CONDITIONALThe type of the conditional densities, i.e. the type of node in the underlying Bayes chain, which could be a ConditionalProbabilityTable, a GaussianConditional, or a SymbolicConditional.
CLIQUEThe type of the clique data structure, defaults to BayesTreeClique, normally do not change this as it is only used when developing special versions of BayesTree, e.g. for ISAM2.

Member Typedef Documentation

◆ Cliques

template<class CLIQUE>
typedef FastList<sharedClique> gtsam::BayesTree< CLIQUE >::Cliques

A convenience class for a list of shared cliques

◆ Nodes

template<class CLIQUE>
typedef ConcurrentMap<Key, sharedClique> gtsam::BayesTree< CLIQUE >::Nodes

Map from keys to Clique

◆ Roots

template<class CLIQUE>
typedef FastVector<sharedClique> gtsam::BayesTree< CLIQUE >::Roots

Root cliques

Constructor & Destructor Documentation

◆ BayesTree() [1/2]

template<class CLIQUE>
gtsam::BayesTree< CLIQUE >::BayesTree ( )
inlineprotected

Create an empty Bayes Tree

◆ BayesTree() [2/2]

template<class CLIQUE >
gtsam::BayesTree< CLIQUE >::BayesTree ( const This other)
protected

Copy constructor

◆ ~BayesTree()

template<class CLIQUE >
gtsam::BayesTree< CLIQUE >::~BayesTree ( )
protected

Destructor

Destructor Using default destructor causes stack overflow for large trees due to recursive destruction of nodes; so we manually decrease the reference count of each node in the tree through a BFS, and the nodes with reference count 0 will be deleted. Please see PR-1441 for more details.

Member Function Documentation

◆ addClique()

template<class CLIQUE >
void gtsam::BayesTree< CLIQUE >::addClique ( const sharedClique clique,
const sharedClique parent_clique = sharedClique() 
)

add a clique (top down)

◆ addFactorsToGraph()

template<class CLIQUE >
void gtsam::BayesTree< CLIQUE >::addFactorsToGraph ( FactorGraph< FactorType > *  graph) const

Add all cliques in this BayesTree to the specified factor graph

◆ clear()

template<class CLIQUE >
void gtsam::BayesTree< CLIQUE >::clear ( )

Remove all nodes

◆ clique()

template<class CLIQUE>
const sharedClique& gtsam::BayesTree< CLIQUE >::clique ( Key  j) const
inline

alternate syntax for matlab: find the clique that contains the variable with Key j

◆ deleteCachedShortcuts()

template<class CLIQUE >
void gtsam::BayesTree< CLIQUE >::deleteCachedShortcuts ( )

Clear all shortcut caches - use before timing on marginal calculation to avoid residual cache data

◆ dot()

template<class CLIQUE >
void gtsam::BayesTree< CLIQUE >::dot ( std::ostream &  s,
sharedClique  clique,
const KeyFormatter keyFormatter,
int  parentnum = 0 
) const
protected

private helper method for saving the Tree to a text file in GraphViz format

◆ empty()

template<class CLIQUE>
bool gtsam::BayesTree< CLIQUE >::empty ( ) const
inline

Check if there are any cliques in the tree

◆ equals()

template<class CLIQUE >
bool gtsam::BayesTree< CLIQUE >::equals ( const This other,
double  tol = 1e-9 
) const
protected

check equality

◆ fillNodesIndex()

template<class CLIQUE >
void gtsam::BayesTree< CLIQUE >::fillNodesIndex ( const sharedClique subtree)
protected

Fill the nodes index for a subtree

◆ findParentClique()

template<class CLIQUE >
template<class CONTAINER >
Key gtsam::BayesTree< CLIQUE >::findParentClique ( const CONTAINER &  parents) const

Find parent clique of a conditional. It will look at all parents and return the one with the lowest index in the ordering.

◆ getCliqueData() [1/2]

template<class CLIQUE >
BayesTreeCliqueData gtsam::BayesTree< CLIQUE >::getCliqueData ( ) const

Gather data on all cliques

◆ getCliqueData() [2/2]

template<class CLIQUE >
void gtsam::BayesTree< CLIQUE >::getCliqueData ( sharedClique  clique,
BayesTreeCliqueData stats 
) const
protected

Gather data on a single clique

◆ insertRoot()

template<class CLIQUE >
void gtsam::BayesTree< CLIQUE >::insertRoot ( const sharedClique subtree)

Insert a new subtree with known parent clique. This function does not check that the specified parent is the correct parent. This function updates all of the internal data structures associated with adding a subtree, such as populating the nodes index.

◆ joint()

template<class CLIQUE >
BayesTree< CLIQUE >::sharedFactorGraph gtsam::BayesTree< CLIQUE >::joint ( Key  j1,
Key  j2,
const Eliminate &  function = EliminationTraitsType::DefaultEliminate 
) const

return joint on two variables Limitation: can only calculate joint if cliques are disjoint or one of them is root

◆ jointBayesNet()

template<class CLIQUE >
BayesTree< CLIQUE >::sharedBayesNet gtsam::BayesTree< CLIQUE >::jointBayesNet ( Key  j1,
Key  j2,
const Eliminate &  function = EliminationTraitsType::DefaultEliminate 
) const

return joint on two variables as a BayesNet Limitation: can only calculate joint if cliques are disjoint or one of them is root

◆ marginalFactor()

template<class CLIQUE >
BayesTree< CLIQUE >::sharedConditional gtsam::BayesTree< CLIQUE >::marginalFactor ( Key  j,
const Eliminate &  function = EliminationTraitsType::DefaultEliminate 
) const

Return marginal on any variable. Note that this actually returns a conditional, for which a solution may be directly obtained by calling .solve() on the returned object. Alternatively, it may be directly used as its factor base class. For example, for Gaussian systems, this returns a GaussianConditional, which inherits from JacobianFactor and GaussianFactor.

◆ nodes()

template<class CLIQUE>
const Nodes& gtsam::BayesTree< CLIQUE >::nodes ( ) const
inline

Return nodes. Each node is a clique of variables obtained after elimination.

◆ numCachedSeparatorMarginals()

template<class CLIQUE >
size_t gtsam::BayesTree< CLIQUE >::numCachedSeparatorMarginals ( ) const

Collect number of cliques with cached separator marginals

◆ operator=()

template<class CLIQUE >
BayesTree< CLIQUE > & gtsam::BayesTree< CLIQUE >::operator= ( const This other)
protected

Assignment operator

◆ operator[]()

template<class CLIQUE>
sharedClique gtsam::BayesTree< CLIQUE >::operator[] ( Key  j) const
inline

Access node by variable

◆ print()

template<class CLIQUE >
void gtsam::BayesTree< CLIQUE >::print ( const std::string &  s = "",
const KeyFormatter keyFormatter = DefaultKeyFormatter 
) const

print

◆ removeClique()

template<class CLIQUE >
void gtsam::BayesTree< CLIQUE >::removeClique ( sharedClique  clique)
protected

remove a clique: warning, can result in a forest

◆ removePath()

template<class CLIQUE >
void gtsam::BayesTree< CLIQUE >::removePath ( sharedClique  clique,
BayesNetType *  bn,
Cliques orphans 
)

Remove path from clique to root and return that path as factors plus a list of orphaned subtree roots. Used in removeTop below.

◆ removeSubtree()

template<class CLIQUE >
BayesTree< CLIQUE >::Cliques gtsam::BayesTree< CLIQUE >::removeSubtree ( const sharedClique subtree)

Remove the requested subtree.

◆ removeTop()

template<class CLIQUE >
void gtsam::BayesTree< CLIQUE >::removeTop ( const KeyVector keys,
BayesNetType *  bn,
Cliques orphans 
)

Given a list of indices, turn "contaminated" part of the tree back into a factor graph. Factors and orphans are added to the in/out arguments.

◆ roots()

template<class CLIQUE>
const Roots& gtsam::BayesTree< CLIQUE >::roots ( ) const
inline

return root cliques

◆ size()

template<class CLIQUE >
size_t gtsam::BayesTree< CLIQUE >::size ( ) const

number of cliques

Member Data Documentation

◆ nodes_

template<class CLIQUE>
Nodes gtsam::BayesTree< CLIQUE >::nodes_
protected

Map from indices to Clique

◆ roots_

template<class CLIQUE>
Roots gtsam::BayesTree< CLIQUE >::roots_
protected

Root cliques


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