gtsam
Loading...
Searching...
No Matches
ISAM2Result.h
Go to the documentation of this file.
1/* ----------------------------------------------------------------------------
2
3 * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4 * Atlanta, Georgia 30332-0415
5 * All Rights Reserved
6 * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7
8 * See LICENSE for the license information
9
10 * -------------------------------------------------------------------------- */
11
17
18// \callgraph
19
20#pragma once
21
22#include <string>
23#include <vector>
24
29
30namespace gtsam {
31
39struct ISAM2Result {
52 std::optional<double> errorBefore;
53
64 std::optional<double> errorAfter;
65
75
83
87
89 size_t cliques;
90
96 size_t treeNnz;
97
101
107
112
115
118
121
129 struct VariableStatus {
142 bool isRelinearized;
147 bool isNew;
149 VariableStatus()
150 : isReeliminated(false),
153 isRelinearized(false),
154 isObserved(false),
155 isNew(false),
156 inRootClique(false) {}
157 };
158
159 using StatusMap = FastMap<Key, VariableStatus>;
160
162 StatusMap variableStatus;
163 };
164
167 std::optional<DetailedResults> detail;
168
169 explicit ISAM2Result(bool enableDetailedResults = false)
173 cliques(0),
174 treeNnz(0),
175 batchReorderTriggered(false) {
176 if (enableDetailedResults) detail = DetailedResults();
177 }
178
181 if (detail.has_value()) {
182 return &(*detail);
183 } else {
184 return nullptr;
185 }
186 }
187
189 void print(const std::string str = "") const {
190 using std::cout;
191 cout << str << " Reelimintated: " << variablesReeliminated
192 << " Relinearized: " << variablesRelinearized
193 << " Cliques: " << cliques
194 << " Nnz: " << treeNnz;
195 if (batchReorderTriggered) cout << " [REORDERED]";
196 cout << std::endl;
197 }
198
201 size_t getVariablesReeliminated() const { return variablesReeliminated; }
202 FactorIndices getNewFactorsIndices() const { return newFactorsIndices; }
203 size_t getCliques() const { return cliques; }
204 size_t getTreeNnz() const { return treeNnz; }
205 bool getBatchReorderTriggered() const { return batchReorderTriggered; }
206 double getErrorBefore() const { return errorBefore ? *errorBefore : std::nan(""); }
207 double getErrorAfter() const { return errorAfter ? *errorAfter : std::nan(""); }
208 size_t getFactorsRecalculated() const { return factorsRecalculated; }
209 const KeySet& getUnusedKeys() const { return unusedKeys; }
210 const KeyVector& getObservedKeys() const { return observedKeys; }
211 const KeySet& getKeysWithRemovedFactors() const {
213 }
214 const KeySet& getMarkedKeys() const { return markedKeys; }
215};
216
217} // namespace gtsam
Gaussian Bayes Tree, the result of eliminating a GaussianJunctionTree.
Nonlinear factor graph optimizer using Powell's Dogleg algorithm (detail implementation).
Parameters for iSAM 2.
Factor Graph consisting of non-linear factors.
Global functions in a separate testing namespace.
Definition chartTesting.h:28
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition Key.h:91
FastVector< FactorIndex > FactorIndices
Define collection types:
Definition Factor.h:37
FastMap is a thin wrapper around std::map that uses the boost fast_pool_allocator instead of the defa...
Definition FastMap.h:40
size_t variablesRelinearized
The number of variables that were relinearized because their linear deltas exceeded the reslinearizat...
Definition ISAM2Result.h:74
size_t getVariablesRelinearized() const
Getters and Setters.
Definition ISAM2Result.h:200
std::optional< double > errorAfter
The nonlinear error of all of the factors computed after the current update, meaning that variables a...
Definition ISAM2Result.h:64
size_t treeNnz
Total number of nonzero entries in the Bayes tree (upper-triangular R and rectangular S blocks of eve...
Definition ISAM2Result.h:96
size_t factorsRecalculated
The number of factors that were included in reelimination of the Bayes' tree.
Definition ISAM2Result.h:86
DetailedResults * details()
Return pointer to detail, 0 if no detail requested.
Definition ISAM2Result.h:180
bool batchReorderTriggered
Whether a full batch reorder was triggered during this update, either by the adaptive reorder heurist...
Definition ISAM2Result.h:100
void print(const std::string str="") const
Print results.
Definition ISAM2Result.h:189
std::optional< double > errorBefore
The nonlinear error of all of the factors, including new factors and variables added during the curre...
Definition ISAM2Result.h:52
size_t cliques
The number of cliques in the Bayes' Tree.
Definition ISAM2Result.h:89
KeySet keysWithRemovedFactors
Keys of variables that had factors removed.
Definition ISAM2Result.h:117
std::optional< DetailedResults > detail
Detailed results, if enabled by ISAM2Params::enableDetailedResults.
Definition ISAM2Result.h:167
size_t variablesReeliminated
The number of variables that were reeliminated as parts of the Bayes' Tree were recalculated,...
Definition ISAM2Result.h:82
KeySet unusedKeys
Unused keys, and indices for unused keys, i.e., keys that are empty now and do not appear in the new ...
Definition ISAM2Result.h:111
KeyVector observedKeys
keys for variables that were observed, i.e., not unused.
Definition ISAM2Result.h:114
KeySet markedKeys
All keys that were marked during the update process.
Definition ISAM2Result.h:120
FactorIndices newFactorsIndices
The indices of the newly-added factors, in 1-to-1 correspondence with the factors passed as newFactor...
Definition ISAM2Result.h:106
A struct holding detailed results, which must be enabled with ISAM2Params::enableDetailedResults.
Definition ISAM2Result.h:126
StatusMap variableStatus
The status of each variable during this update, see VariableStatus.
Definition ISAM2Result.h:162
bool isRelinearizeInvolved
Whether the variable was below the relinearization threshold but was relinearized by being involved i...
Definition ISAM2Result.h:137
bool isObserved
Whether the variable was relinearized, either by being above the relinearization threshold or by invo...
Definition ISAM2Result.h:145
bool isNew
Whether the variable itself was just added.
Definition ISAM2Result.h:147
bool isAboveRelinThreshold
Whether the variable was just relinearized due to being above the relinearization threshold.
Definition ISAM2Result.h:134
bool isReeliminated
Whether the variable was just reeliminated, due to being relinearized, observed, new,...
Definition ISAM2Result.h:133
bool inRootClique
Whether the variable is in the root clique.
Definition ISAM2Result.h:148