#include <BayesTree.h>
Public Types | |
typedef CLIQUE::BayesNetType | BayesNetType |
typedef CLIQUE | Clique |
The clique type, normally BayesTreeClique. More... | |
typedef FastList< sharedClique > | Cliques |
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, sharedClique > | Nodes |
typedef FastVector< sharedClique > | Roots |
typedef std::shared_ptr< BayesNetType > | sharedBayesNet |
typedef std::shared_ptr< Clique > | sharedClique |
Shared pointer to a clique. More... | |
typedef std::shared_ptr< ConditionalType > | sharedConditional |
typedef std::shared_ptr< FactorType > | sharedFactor |
typedef std::shared_ptr< FactorGraphType > | sharedFactorGraph |
typedef sharedClique | sharedNode |
Synonym for sharedClique (TODO: remove) More... | |
Protected Types | |
typedef std::shared_ptr< This > | shared_ptr |
typedef BayesTree< CLIQUE > | This |
Protected Member Functions | |
This & | operator= (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 Nodes & | nodes () const |
sharedClique | operator[] (Key j) const |
const Roots & | roots () const |
const sharedClique & | clique (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 |
Bayes tree
CONDITIONAL | The 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. |
CLIQUE | The 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.
typedef CLIQUE::BayesNetType gtsam::BayesTree< CLIQUE >::BayesNetType |
Definition at line 79 of file BayesTree.h.
typedef CLIQUE gtsam::BayesTree< CLIQUE >::Clique |
The clique type, normally BayesTreeClique.
Definition at line 73 of file BayesTree.h.
typedef FastList<sharedClique> gtsam::BayesTree< CLIQUE >::Cliques |
A convenience class for a list of shared cliques
Definition at line 89 of file BayesTree.h.
typedef CLIQUE::ConditionalType gtsam::BayesTree< CLIQUE >::ConditionalType |
Definition at line 77 of file BayesTree.h.
typedef FactorGraphType::Eliminate gtsam::BayesTree< CLIQUE >::Eliminate |
Definition at line 85 of file BayesTree.h.
typedef CLIQUE::EliminationTraitsType gtsam::BayesTree< CLIQUE >::EliminationTraitsType |
Definition at line 86 of file BayesTree.h.
typedef CLIQUE::FactorGraphType gtsam::BayesTree< CLIQUE >::FactorGraphType |
Definition at line 83 of file BayesTree.h.
typedef CLIQUE::FactorType gtsam::BayesTree< CLIQUE >::FactorType |
Definition at line 81 of file BayesTree.h.
typedef Clique gtsam::BayesTree< CLIQUE >::Node |
Synonym for Clique (TODO: remove)
Definition at line 75 of file BayesTree.h.
typedef ConcurrentMap<Key, sharedClique> gtsam::BayesTree< CLIQUE >::Nodes |
Map from keys to Clique
Definition at line 92 of file BayesTree.h.
typedef FastVector<sharedClique> gtsam::BayesTree< CLIQUE >::Roots |
Root cliques
Definition at line 95 of file BayesTree.h.
|
protected |
Definition at line 70 of file BayesTree.h.
typedef std::shared_ptr<BayesNetType> gtsam::BayesTree< CLIQUE >::sharedBayesNet |
Definition at line 80 of file BayesTree.h.
typedef std::shared_ptr<Clique> gtsam::BayesTree< CLIQUE >::sharedClique |
Shared pointer to a clique.
Definition at line 74 of file BayesTree.h.
typedef std::shared_ptr<ConditionalType> gtsam::BayesTree< CLIQUE >::sharedConditional |
Definition at line 78 of file BayesTree.h.
typedef std::shared_ptr<FactorType> gtsam::BayesTree< CLIQUE >::sharedFactor |
Definition at line 82 of file BayesTree.h.
typedef std::shared_ptr<FactorGraphType> gtsam::BayesTree< CLIQUE >::sharedFactorGraph |
Definition at line 84 of file BayesTree.h.
typedef sharedClique gtsam::BayesTree< CLIQUE >::sharedNode |
Synonym for sharedClique (TODO: remove)
Definition at line 76 of file BayesTree.h.
|
protected |
Definition at line 69 of file BayesTree.h.
|
inlineprotected |
Create an empty Bayes Tree
Definition at line 109 of file BayesTree.h.
|
protected |
Copy constructor
Definition at line 178 of file BayesTree-inst.h.
|
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.
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.
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.
void gtsam::BayesTree< CLIQUE >::clear | ( | void | ) |
Remove all nodes
Definition at line 449 of file BayesTree-inst.h.
|
inline |
alternate syntax for matlab: find the clique that contains the variable with Key j
Definition at line 155 of file BayesTree.h.
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.
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.
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.
|
protected |
private helper method for saving the Tree to a text file in GraphViz format
Definition at line 94 of file BayesTree-inst.h.
|
inline |
Check if there are any cliques in the tree
Definition at line 141 of file BayesTree.h.
|
protected |
check equality
Definition at line 269 of file BayesTree-inst.h.
|
protected |
Fill the nodes index for a subtree
Definition at line 285 of file BayesTree-inst.h.
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.
BayesTreeCliqueData gtsam::BayesTree< CLIQUE >::getCliqueData | ( | ) | const |
Gather data on all cliques
Definition at line 35 of file BayesTree-inst.h.
|
protected |
Gather data on a single clique
Definition at line 43 of file BayesTree-inst.h.
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.
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.
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.
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.
|
inline |
Return nodes. Each node is a clique of variables obtained after elimination.
Definition at line 146 of file BayesTree.h.
size_t gtsam::BayesTree< CLIQUE >::numCachedSeparatorMarginals | ( | ) | const |
Collect number of cliques with cached separator marginals
Definition at line 55 of file BayesTree-inst.h.
|
protected |
Assignment operator
Definition at line 238 of file BayesTree-inst.h.
|
inline |
Access node by variable
Definition at line 149 of file BayesTree.h.
void gtsam::BayesTree< CLIQUE >::print | ( | const std::string & | s = "" , |
const KeyFormatter & | keyFormatter = DefaultKeyFormatter |
||
) | const |
Definition at line 251 of file BayesTree-inst.h.
|
protected |
remove a clique: warning, can result in a forest
Definition at line 465 of file BayesTree-inst.h.
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.
BayesTree< CLIQUE >::Cliques gtsam::BayesTree< CLIQUE >::removeSubtree | ( | const sharedClique & | subtree | ) |
Remove the requested subtree.
Definition at line 537 of file BayesTree-inst.h.
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.
|
inline |
return root cliques
Definition at line 152 of file BayesTree.h.
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_t gtsam::BayesTree< CLIQUE >::size | ( | ) | const |
number of cliques
Definition at line 133 of file BayesTree-inst.h.
|
friend |
Definition at line 262 of file BayesTree.h.
|
protected |
Map from indices to Clique
Definition at line 100 of file BayesTree.h.
|
protected |
Root cliques
Definition at line 103 of file BayesTree.h.