|
gtsam
|
A Bayes tree representing a Gaussian density.
Public Member Functions | |
| GaussianBayesTree () | |
| Default constructor, creates an empty Bayes tree. | |
| bool | equals (const This &other, double tol=1e-9) const |
| Check equality. | |
| VectorValues | optimize () const |
| Recursively optimize the BayesTree to produce a vector solution. | |
| VectorValues | optimizeGradientSearch () const |
| Optimize along the gradient direction, with a closed-form computation to perform the line search. | |
| VectorValues | gradient (const VectorValues &x0) const |
| Compute the gradient of the energy function, \( \nabla_{x=x_0} \left\Vert \Sigma^{-1} R x -
d \right\Vert^2 \), centered around \( x = x_0 \). | |
| VectorValues | gradientAtZero () const |
| Compute the gradient of the energy function, \( \nabla_{x=0} \left\Vert \Sigma^{-1} R x - d
\right\Vert^2 \), centered around zero. | |
| double | error (const VectorValues &x) const |
| 0.5 * sum of squared Mahalanobis distances. | |
| double | determinant () const |
| Computes the determinant of a GassianBayesTree, as if the Bayes tree is reorganized into a matrix. | |
| double | logDeterminant () const |
| Computes the determinant of a GassianBayesTree, as if the Bayes tree is reorganized into a matrix. | |
| Matrix | marginalInformation (Key key) const |
| Return the marginal information matrix on the requested variable. | |
| Matrix | marginalCovariance (Key key) const |
| Return the marginal covariance matrix on the requested variable. | |
| Matrix | marginalInformation (Key key, const Eliminate &eliminate) const |
| Return the marginal information matrix using a specific elimination rule. | |
| Matrix | marginalCovariance (Key key, const Eliminate &eliminate) const |
| Return the marginal covariance matrix using a specific elimination rule. | |
| JointMarginal | jointMarginalInformation (const KeyVector &queryKeys) const |
| Return the joint marginal information matrix in queryKeys order. | |
| JointMarginal | jointMarginalCovariance (const KeyVector &queryKeys) const |
| Return the joint marginal covariance matrix in queryKeys order. | |
| JointMarginal | jointMarginalInformation (const KeyVector &queryKeys, const Eliminate &eliminate) const |
| Return joint marginal information in queryKeys order using an elimination rule. | |
| JointMarginal | jointMarginalCovariance (const KeyVector &queryKeys, const Eliminate &eliminate) const |
| Return joint marginal covariance in queryKeys order using an elimination rule. | |
| Public Member Functions inherited from gtsam::BayesTree< GaussianBayesTreeClique > | |
| bool | equals (const This &other, double tol=1e-9) const |
| check equality | |
| void | print (const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const |
| print | |
| size_t | size () const |
| number of cliques | |
| bool | empty () const |
| Check if there are any cliques in the tree. | |
| const Nodes & | nodes () const |
| Return nodes. | |
| sharedClique | operator[] (Key j) const |
| Access node by variable. | |
| const Roots & | roots () const |
| return root cliques | |
| const sharedClique & | clique (Key j) const |
| alternate syntax for matlab: find the clique that contains the variable with Key j | |
| BayesTreeCliqueData | getCliqueData () const |
| Gather data on all cliques. | |
| size_t | numCachedSeparatorMarginals () const |
| Collect number of cliques with cached separator marginals. | |
| sharedConditional | marginalFactor (Key j, const Eliminate &function=EliminationTraitsType::DefaultEliminate) const |
| Return marginal on any variable. | |
| sharedFactorGraph | 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 | |
| sharedFactorGraph | joint (const KeyVector &keys, const Eliminate &function=EliminationTraitsType::DefaultEliminate) const |
| Return a joint factor graph on an arbitrary set of variables. | |
| sharedBayesNet | 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 | |
| sharedBayesNet | jointBayesNet (const KeyVector &keys, const Eliminate &function=EliminationTraitsType::DefaultEliminate) const |
| Return a joint marginal Bayes net whose elimination order follows the first occurrence of each key. | |
| 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. | |
| Key | findParentClique (const CONTAINER &parents) const |
| Find parent clique of a conditional. | |
| void | clear () |
| Remove all nodes. | |
| void | deleteCachedShortcuts () |
| Clear all shortcut caches - use before timing on marginal calculation to avoid residual cache data. | |
| void | 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. | |
| void | removeTop (const KeyVector &keys, BayesNetType *bn, Cliques *orphans) |
| Given a list of indices, turn "contaminated" part of the tree back into a factor graph. | |
| Cliques | removeSubtree (const sharedClique &subtree) |
| Remove the requested subtree. | |
| void | insertRoot (const sharedClique &subtree) |
| Insert a new subtree with known parent clique. | |
| void | addClique (const sharedClique &clique, const sharedClique &parent_clique=sharedClique()) |
| add a clique (top down) | |
| void | addFactorsToGraph (FactorGraph< FactorType > *graph) const |
| Add all cliques in this BayesTree to the specified factor graph. | |
| gtsam::KeySet | collectAffectedKeys (const gtsam::KeyVector &keys) const |
| Returns the set of keys from the tree that are affected by a update to 'keys'. | |
Public Types | |
| typedef GaussianBayesTree | This |
| typedef std::shared_ptr< This > | shared_ptr |
| Public Types inherited from gtsam::BayesTree< GaussianBayesTreeClique > | |
| typedef GaussianBayesTreeClique | Clique |
| The clique type, normally BayesTreeClique. | |
| typedef std::shared_ptr< Clique > | sharedClique |
| Shared pointer to a clique. | |
| typedef Clique | Node |
| Synonym for Clique (TODO: remove). | |
| typedef sharedClique | sharedNode |
| Synonym for sharedClique (TODO: remove). | |
| typedef GaussianBayesTreeClique::ConditionalType | ConditionalType |
| typedef std::shared_ptr< ConditionalType > | sharedConditional |
| typedef GaussianBayesTreeClique::BayesNetType | BayesNetType |
| typedef std::shared_ptr< BayesNetType > | sharedBayesNet |
| typedef GaussianBayesTreeClique::FactorType | FactorType |
| typedef std::shared_ptr< FactorType > | sharedFactor |
| typedef GaussianBayesTreeClique::FactorGraphType | FactorGraphType |
| typedef std::shared_ptr< FactorGraphType > | sharedFactorGraph |
| typedef FactorGraphType::Eliminate | Eliminate |
| typedef GaussianBayesTreeClique::EliminationTraitsType | EliminationTraitsType |
| typedef FastList< sharedClique > | Cliques |
| A convenience class for a list of shared cliques. | |
| typedef ConcurrentMap< Key, sharedClique > | Nodes |
| Map from keys to Clique. | |
| typedef FastVector< sharedClique > | Roots |
| Root cliques. | |
Additional Inherited Members | |
| Protected Types inherited from gtsam::BayesTree< GaussianBayesTreeClique > | |
| typedef BayesTree< GaussianBayesTreeClique > | This |
| typedef std::shared_ptr< This > | shared_ptr |
| Protected Member Functions inherited from gtsam::BayesTree< GaussianBayesTreeClique > | |
| ~BayesTree () | |
| Destructor. | |
| This & | operator= (const This &other) |
| Assignment operator. | |
| BayesTree () | |
| Create an empty Bayes Tree. | |
| BayesTree (const This &other) | |
| Copy constructor. | |
| void | dot (std::ostream &s, sharedClique clique, const KeyFormatter &keyFormatter, size_t parentnum=0) const |
| private helper method for saving the Tree to a text file in GraphViz format | |
| void | getCliqueData (sharedClique clique, BayesTreeCliqueData *stats) const |
| Gather data on a single clique. | |
| void | removeClique (sharedClique clique) |
| remove a clique: warning, can result in a forest | |
| void | fillNodesIndex (const sharedClique &subtree) |
| Fill the nodes index for a subtree. | |
| void | collectAffectedPathKeys (gtsam::KeySet &traversedKeys, const sharedClique &clique) const |
| Helper for collectAffectedKeys that recursively aggregates affected keys from a path from 'clique' to the root of tree. | |
| Protected Attributes inherited from gtsam::BayesTree< GaussianBayesTreeClique > | |
| Nodes | nodes_ |
| Map from indices to Clique. | |
| Roots | roots_ |
| Root cliques. | |
| double gtsam::GaussianBayesTree::determinant | ( | ) | const |
Computes the determinant of a GassianBayesTree, as if the Bayes tree is reorganized into a matrix.
A GassianBayesTree is equivalent to an upper triangular matrix, and for an upper triangular matrix determinant is the product of the diagonal elements. Instead of actually multiplying we add the logarithms of the diagonal elements and take the exponent at the end because this is more numerically stable.
| VectorValues gtsam::GaussianBayesTree::gradient | ( | const VectorValues & | x0 | ) | const |
Compute the gradient of the energy function, \( \nabla_{x=x_0} \left\Vert \Sigma^{-1} R x - d \right\Vert^2 \), centered around \( x = x_0 \).
The gradient is \( R^T(Rx-d) \).
| x0 | The center about which to compute the gradient |
| VectorValues gtsam::GaussianBayesTree::gradientAtZero | ( | ) | const |
Compute the gradient of the energy function, \( \nabla_{x=0} \left\Vert \Sigma^{-1} R x - d \right\Vert^2 \), centered around zero.
The gradient about zero is \( -R^T d \). See also gradient(const GaussianBayesNet&, const VectorValues&).
| double gtsam::GaussianBayesTree::logDeterminant | ( | ) | const |
Computes the determinant of a GassianBayesTree, as if the Bayes tree is reorganized into a matrix.
A GassianBayesTree is equivalent to an upper triangular matrix, and for an upper triangular matrix determinant is the product of the diagonal elements. Instead of actually multiplying we add the logarithms of the diagonal elements and take the exponent at the end because this is more numerically stable.
| VectorValues gtsam::GaussianBayesTree::optimizeGradientSearch | ( | ) | const |
Optimize along the gradient direction, with a closed-form computation to perform the line search.
The gradient is computed about \( \delta x=0 \).
This function returns \( \delta x \) that minimizes a reparametrized problem. The error function of a GaussianBayesNet is
\[ f(\delta x) = \frac{1}{2} |R \delta x - d|^2 = \frac{1}{2}d^T d - d^T R \delta x + \frac{1}{2} \delta x^T R^T R \delta x \]
with gradient and Hessian
\[ g(\delta x) = R^T(R\delta x - d), \qquad G(\delta x) = R^T R. \]
This function performs the line search in the direction of the gradient evaluated at \( g = g(\delta x = 0) \) with step size \( \alpha \) that minimizes \( f(\delta x = \alpha g) \):
\[ f(\alpha) = \frac{1}{2} d^T d + g^T \delta x + \frac{1}{2} \alpha^2 g^T G g \]
Optimizing by setting the derivative to zero yields \( \hat \alpha = (-g^T g) / (g^T G g) \). For efficiency, this function evaluates the denominator without computing the Hessian \( G \), returning
\[ \delta x = \hat\alpha g = \frac{-g^T g}{(R g)^T(R g)} \]