#include <ISAM2.h>
Public Member Functions | |
Values | calculateEstimate () const |
template<class VALUE > | |
VALUE | calculateEstimate (Key key) const |
const Value & | calculateEstimate (Key key) const |
virtual bool | equals (const ISAM2 &other, double tol=1e-9) const |
const Values & | getLinearizationPoint () const |
Access the current linearization point. More... | |
ISAM2 () | |
ISAM2 (const ISAM2Params ¶ms) | |
Matrix | marginalCovariance (Key key) const |
void | marginalizeLeaves (const FastList< Key > &leafKeys, FactorIndices *marginalFactorsIndices=nullptr, FactorIndices *deletedFactorsIndices=nullptr) |
template<class... OptArgs> | |
void | marginalizeLeaves (const FastList< Key > &leafKeys, OptArgs &&... optArgs) |
virtual ISAM2Result | update (const NonlinearFactorGraph &newFactors, const Values &newTheta, const ISAM2UpdateParams &updateParams) |
virtual ISAM2Result | update (const NonlinearFactorGraph &newFactors=NonlinearFactorGraph(), const Values &newTheta=Values(), const FactorIndices &removeFactorIndices=FactorIndices(), const std::optional< FastMap< Key, int > > &constrainedKeys={}, const std::optional< FastList< Key > > &noRelinKeys={}, const std::optional< FastList< Key > > &extraReelimKeys={}, bool force_relinearize=false) |
bool | valueExists (Key key) const |
Check whether variable with given key exists in linearization point. More... | |
virtual | ~ISAM2 () |
Public members for non-typical usage | |
Values | calculateBestEstimate () const |
const VectorValues & | getDelta () const |
double | error (const VectorValues &x) const |
const NonlinearFactorGraph & | getFactorsUnsafe () const |
const VariableIndex & | getVariableIndex () const |
const KeySet & | getFixedVariables () const |
const ISAM2Params & | params () const |
void | printStats () const |
VectorValues | gradientAtZero () const |
![]() | |
bool | equals (const This &other, double tol=1e-9) const |
void | print (const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const |
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 |
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... | |
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 |
Protected Member Functions | |
void | addVariables (const Values &newTheta, ISAM2Result::DetailedResults *detail=0) |
void | recalculate (const ISAM2UpdateParams &updateParams, const KeySet &relinKeys, ISAM2Result *result) |
Remove marked top and either recalculate in batch or incrementally. More... | |
void | recalculateBatch (const ISAM2UpdateParams &updateParams, KeySet *affectedKeysSet, ISAM2Result *result) |
void | recalculateIncremental (const ISAM2UpdateParams &updateParams, const KeySet &relinKeys, const FastList< Key > &affectedKeys, KeySet *affectedKeysSet, Cliques *orphans, ISAM2Result *result) |
Perform an incremental update of the factor graph to return a new Bayes Tree with affected keys. More... | |
GaussianFactorGraph | relinearizeAffectedFactors (const ISAM2UpdateParams &updateParams, const FastList< Key > &affectedKeys, const KeySet &relinKeys) |
void | removeVariables (const KeySet &unusedKeys) |
void | updateDelta (bool forceFullSolve=false) const |
![]() | |
This & | operator= (const This &other) |
~BayesTree () | |
BayesTree () | |
BayesTree (const This &other) | |
void | getCliqueData (sharedClique clique, BayesTreeCliqueData *stats) const |
void | dot (std::ostream &s, sharedClique clique, const KeyFormatter &keyFormatter, int parentnum=0) const |
void | removeClique (sharedClique clique) |
void | fillNodesIndex (const sharedClique &subtree) |
Protected Attributes | |
VectorValues | delta_ |
VectorValues | deltaNewton_ |
KeySet | deltaReplacedMask_ |
std::optional< double > | doglegDelta_ |
KeySet | fixedVariables_ |
GaussianFactorGraph | linearFactors_ |
NonlinearFactorGraph | nonlinearFactors_ |
ISAM2Params | params_ |
VectorValues | RgProd_ |
Values | theta_ |
int | update_count_ |
VariableIndex | variableIndex_ |
![]() | |
Nodes | nodes_ |
Roots | roots_ |
Additional Inherited Members | |
![]() | |
typedef std::shared_ptr< This > | shared_ptr |
typedef BayesTree< ISAM2Clique > | This |
Implementation of the full ISAM2 algorithm for incremental nonlinear optimization.
The typical cycle of using this class to create an instance by providing ISAM2Params to the constructor, then add measurements and variables as they arrive using the update() method. At any time, calculateEstimate() may be called to obtain the current estimate of all variables.
using gtsam::ISAM2::Base = BayesTree<ISAM2Clique> |
using gtsam::ISAM2::Clique = Base::Clique |
using gtsam::ISAM2::Cliques = Base::Cliques |
using gtsam::ISAM2::This = ISAM2 |
|
explicit |
gtsam::ISAM2::ISAM2 | ( | ) |
Create an empty ISAM2 instance using the default set of parameters (see ISAM2Params)
|
inlinevirtual |
|
protected |
Values gtsam::ISAM2::calculateBestEstimate | ( | ) | const |
Values gtsam::ISAM2::calculateEstimate | ( | ) | const |
|
inline |
Compute an estimate for a single variable using its incomplete linear delta computed during the last update. This is faster than calling the no-argument version of calculateEstimate, which operates on all variables. This is a non-templated version that returns a Value base class for use with the MATLAB wrapper.
key |
double gtsam::ISAM2::error | ( | const VectorValues & | x | ) | const |
const VectorValues & gtsam::ISAM2::getDelta | ( | ) | const |
|
inline |
|
inline |
|
inline |
|
inline |
VectorValues gtsam::ISAM2::gradientAtZero | ( | ) | const |
Compute the gradient of the energy function, , centered around zero. The gradient about zero is
. See also gradient(const GaussianBayesNet&, const VectorValues&).
void gtsam::ISAM2::marginalizeLeaves | ( | const FastList< Key > & | leafKeys, |
FactorIndices * | marginalFactorsIndices = nullptr , |
||
FactorIndices * | deletedFactorsIndices = nullptr |
||
) |
Marginalize out variables listed in leafKeys. These keys must be leaves in the BayesTree. Throws MarginalizeNonleafException if non-leaves are requested to be marginalized. Marginalization leaves a linear approximation of the marginal in the system, and the linearization points of any variables involved in this linear marginal become fixed. The set fixed variables will include any key involved with the marginalized variables in the original factors, and possibly additional ones due to fill-in.
If provided, 'marginalFactorsIndices' will be augmented with the factor graph indices of the marginal factors added during the 'marginalizeLeaves' call
If provided, 'deletedFactorsIndices' will be augmented with the factor graph indices of any factor that was removed during the 'marginalizeLeaves' call
|
inline |
|
inline |
|
protected |
|
protected |
|
protected |
Perform an incremental update of the factor graph to return a new Bayes Tree with affected keys.
updateParams | Parameters for the ISAM2 update. |
relinKeys | Keys of variables to relinearize. |
affectedKeys | The set of keys which are affected in the update. |
affectedKeysSet | [output] Affected and contaminated keys. |
orphans | [output] List of orphanes cliques after elimination. |
result | [output] The result of the incremental update step. |
|
protected |
|
protected |
|
virtual |
Add new factors, updating the solution and relinearizing as needed.
Alternative signature of update() (see its documentation above), with all additional parameters in one structure. This form makes easier to keep future API/ABI compatibility if parameters change.
newFactors | The new factors to be added to the system |
newTheta | Initialization points for new variables to be added to the system. You must include here all new variables occuring in newFactors (which were not already in the system). There must not be any variables here that do not occur in newFactors, and additionally, variables that were already in the system must not be included here. |
updateParams | Additional parameters to control relinearization, constrained keys, etc. |
|
virtual |
Add new factors, updating the solution and relinearizing as needed.
Optionally, this function remove existing factors from the system to enable behaviors such as swapping existing factors with new ones.
Add new measurements, and optionally new variables, to the current system. This runs a full step of the ISAM2 algorithm, relinearizing and updating the solution as needed, according to the wildfire and relinearize thresholds.
newFactors | The new factors to be added to the system |
newTheta | Initialization points for new variables to be added to the system. You must include here all new variables occuring in newFactors (which were not already in the system). There must not be any variables here that do not occur in newFactors, and additionally, variables that were already in the system must not be included here. |
removeFactorIndices | Indices of factors to remove from system |
force_relinearize | Relinearize any variables whose delta magnitude is sufficiently large (Params::relinearizeThreshold), regardless of the relinearization interval (Params::relinearizeSkip). |
constrainedKeys | is an optional map of keys to group labels, such that a variable can be constrained to a particular grouping in the BayesTree |
noRelinKeys | is an optional set of nonlinear keys that iSAM2 will hold at a constant linearization point, regardless of the size of the linear delta |
extraReelimKeys | is an optional set of nonlinear keys that iSAM2 will re-eliminate, regardless of the size of the linear delta. This allows the provided keys to be reordered. |
|
protected |
|
inline |
|
mutableprotected |
The linear delta from the last linear solution, an update to the estimate in theta
This is mutable
because it is a "cached" variable - it is not updated until either requested with getDelta() or calculateEstimate(), or needed during update() to evaluate whether to relinearize variables.
|
mutableprotected |
|
mutableprotected |
A cumulative mask for the variables that were replaced and have not yet been updated in the linear solution delta_, this is only used internally, delta will always be updated if necessary when requested with getDelta() or calculateEstimate().
This is mutable
because it is used internally to not update delta_ until it is needed.
|
mutableprotected |
|
protected |
|
mutableprotected |
|
protected |
|
protected |
|
mutableprotected |
|
protected |
|
protected |
|
protected |
VariableIndex lets us look up factors by involved variable and keeps track of dimensions