Public Types | Protected Types | Protected Member Functions | Protected Attributes | List of all members
gtsam::BayesTree< CLIQUE > Class Template Reference

#include <BayesTree.h>

Public Types

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

Protected Types

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

Protected Member Functions

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

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. More...
 
std::string dot (const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
 Output to graphviz format string. More...
 
void saveGraph (const std::string &filename, const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
 output to file with graphviz format. More...
 

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.

Definition at line 66 of file BayesTree.h.

Member Typedef Documentation

◆ BayesNetType

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

Definition at line 79 of file BayesTree.h.

◆ Clique

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

The clique type, normally BayesTreeClique.

Definition at line 73 of file BayesTree.h.

◆ Cliques

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

A convenience class for a list of shared cliques

Definition at line 89 of file BayesTree.h.

◆ ConditionalType

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

Definition at line 77 of file BayesTree.h.

◆ Eliminate

template<class CLIQUE >
typedef FactorGraphType::Eliminate gtsam::BayesTree< CLIQUE >::Eliminate

Definition at line 85 of file BayesTree.h.

◆ EliminationTraitsType

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

Definition at line 86 of file BayesTree.h.

◆ FactorGraphType

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

Definition at line 83 of file BayesTree.h.

◆ FactorType

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

Definition at line 81 of file BayesTree.h.

◆ Node

template<class CLIQUE >
typedef Clique gtsam::BayesTree< CLIQUE >::Node

Synonym for Clique (TODO: remove)

Definition at line 75 of file BayesTree.h.

◆ Nodes

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

Map from keys to Clique

Definition at line 92 of file BayesTree.h.

◆ Roots

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

Root cliques

Definition at line 95 of file BayesTree.h.

◆ shared_ptr

template<class CLIQUE >
typedef std::shared_ptr<This> gtsam::BayesTree< CLIQUE >::shared_ptr
protected

Definition at line 70 of file BayesTree.h.

◆ sharedBayesNet

template<class CLIQUE >
typedef std::shared_ptr<BayesNetType> gtsam::BayesTree< CLIQUE >::sharedBayesNet

Definition at line 80 of file BayesTree.h.

◆ sharedClique

template<class CLIQUE >
typedef std::shared_ptr<Clique> gtsam::BayesTree< CLIQUE >::sharedClique

Shared pointer to a clique.

Definition at line 74 of file BayesTree.h.

◆ sharedConditional

template<class CLIQUE >
typedef std::shared_ptr<ConditionalType> gtsam::BayesTree< CLIQUE >::sharedConditional

Definition at line 78 of file BayesTree.h.

◆ sharedFactor

template<class CLIQUE >
typedef std::shared_ptr<FactorType> gtsam::BayesTree< CLIQUE >::sharedFactor

Definition at line 82 of file BayesTree.h.

◆ sharedFactorGraph

template<class CLIQUE >
typedef std::shared_ptr<FactorGraphType> gtsam::BayesTree< CLIQUE >::sharedFactorGraph

Definition at line 84 of file BayesTree.h.

◆ sharedNode

template<class CLIQUE >
typedef sharedClique gtsam::BayesTree< CLIQUE >::sharedNode

Synonym for sharedClique (TODO: remove)

Definition at line 76 of file BayesTree.h.

◆ This

template<class CLIQUE >
typedef BayesTree<CLIQUE> gtsam::BayesTree< CLIQUE >::This
protected

Definition at line 69 of file BayesTree.h.

Constructor & Destructor Documentation

◆ BayesTree() [1/2]

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

Create an empty Bayes Tree

Definition at line 109 of file BayesTree.h.

◆ BayesTree() [2/2]

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

Copy constructor

Definition at line 178 of file BayesTree-inst.h.

◆ ~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.

Definition at line 190 of file BayesTree-inst.h.

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)

Definition at line 142 of file BayesTree-inst.h.

◆ addFactorsToGraph()

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

Add all cliques in this BayesTree to the specified factor graph

Definition at line 168 of file BayesTree-inst.h.

◆ clear()

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

Remove all nodes

Definition at line 449 of file BayesTree-inst.h.

◆ 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

Definition at line 155 of file BayesTree.h.

◆ deleteCachedShortcuts()

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

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

Definition at line 457 of file BayesTree-inst.h.

◆ dot() [1/3]

template<class CLIQUE >
std::string gtsam::BayesTree< CLIQUE >::dot ( const KeyFormatter keyFormatter = DefaultKeyFormatter) const

Output to graphviz format string.

Definition at line 77 of file BayesTree-inst.h.

◆ dot() [2/3]

template<class CLIQUE >
void gtsam::BayesTree< CLIQUE >::dot ( std::ostream &  os,
const KeyFormatter keyFormatter = DefaultKeyFormatter 
) const

Output to graphviz format, stream version.

Definition at line 64 of file BayesTree-inst.h.

◆ dot() [3/3]

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

Definition at line 94 of file BayesTree-inst.h.

◆ empty()

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

Check if there are any cliques in the tree

Definition at line 141 of file BayesTree.h.

◆ equals()

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

check equality

Definition at line 269 of file BayesTree-inst.h.

◆ fillNodesIndex()

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

Fill the nodes index for a subtree

Definition at line 285 of file BayesTree-inst.h.

◆ 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.

Definition at line 277 of file BayesTree-inst.h.

◆ getCliqueData() [1/2]

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

Gather data on all cliques

Definition at line 35 of file BayesTree-inst.h.

◆ getCliqueData() [2/2]

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

Gather data on a single clique

Definition at line 43 of file BayesTree-inst.h.

◆ 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.

Definition at line 299 of file BayesTree-inst.h.

◆ 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

Definition at line 332 of file BayesTree-inst.h.

◆ 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

Definition at line 341 of file BayesTree-inst.h.

◆ 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.

Definition at line 309 of file BayesTree-inst.h.

◆ nodes()

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

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

Definition at line 146 of file BayesTree.h.

◆ numCachedSeparatorMarginals()

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

Collect number of cliques with cached separator marginals

Definition at line 55 of file BayesTree-inst.h.

◆ operator=()

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

Assignment operator

Definition at line 238 of file BayesTree-inst.h.

◆ operator[]()

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

Access node by variable

Definition at line 149 of file BayesTree.h.

◆ print()

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

print

Definition at line 251 of file BayesTree-inst.h.

◆ removeClique()

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

remove a clique: warning, can result in a forest

Definition at line 465 of file BayesTree-inst.h.

◆ 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.

Definition at line 489 of file BayesTree-inst.h.

◆ removeSubtree()

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

Remove the requested subtree.

Definition at line 537 of file BayesTree-inst.h.

◆ 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.

Definition at line 516 of file BayesTree-inst.h.

◆ roots()

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

return root cliques

Definition at line 152 of file BayesTree.h.

◆ saveGraph()

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

output to file with graphviz format.

Definition at line 85 of file BayesTree-inst.h.

◆ size()

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

number of cliques

Definition at line 133 of file BayesTree-inst.h.

Friends And Related Function Documentation

◆ EliminatableClusterTree

template<class CLIQUE >
template<class BAYESTREE , class GRAPH >
friend class EliminatableClusterTree
friend

Definition at line 262 of file BayesTree.h.

Member Data Documentation

◆ nodes_

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

Map from indices to Clique

Definition at line 100 of file BayesTree.h.

◆ roots_

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

Root cliques

Definition at line 103 of file BayesTree.h.


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


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:23:31