43 double _wildfireThreshold =
47 : wildfireThreshold(_wildfireThreshold) {}
51 cout <<
str <<
"type: ISAM2GaussNewtonParams\n";
52 cout << str <<
"wildfireThreshold: " << wildfireThreshold <<
"\n";
58 this->wildfireThreshold = wildfireThreshold;
81 double _initialDelta = 1.0,
82 double _wildfireThreshold =
86 SEARCH_EACH_ITERATION,
89 : initialDelta(_initialDelta),
90 wildfireThreshold(_wildfireThreshold),
91 adaptationMode(_adaptationMode),
96 cout <<
str <<
"type: ISAM2DoglegParams\n";
97 cout << str <<
"initialDelta: " << initialDelta <<
"\n";
98 cout << str <<
"wildfireThreshold: " << wildfireThreshold <<
"\n";
100 <<
"adaptationMode: " << adaptationModeTranslator(adaptationMode)
108 return adaptationModeTranslator(adaptationMode);
112 this->initialDelta = initialDelta;
115 this->wildfireThreshold = wildfireThreshold;
118 this->adaptationMode = adaptationModeTranslator(adaptationMode);
122 std::string adaptationModeTranslator(
126 const std::string& adaptationMode)
const;
137 typedef std::variant<ISAM2GaussNewtonParams, ISAM2DoglegParams>
139 typedef std::variant<double, FastMap<char, Vector> >
233 int _relinearizeSkip = 10,
bool _enableRelinearization =
true,
234 bool _evaluateNonlinearError =
false,
236 bool _cacheLinearizedFactors =
true,
239 bool _enableDetailedResults =
false)
240 : optimizationParams(_optimizationParams),
241 relinearizeThreshold(_relinearizeThreshold),
242 relinearizeSkip(_relinearizeSkip),
243 enableRelinearization(_enableRelinearization),
244 evaluateNonlinearError(_evaluateNonlinearError),
245 factorization(_factorization),
246 cacheLinearizedFactors(_cacheLinearizedFactors),
247 keyFormatter(_keyFormatter),
248 enableDetailedResults(_enableDetailedResults),
249 enablePartialRelinearizationCheck(false),
250 findUnusedFactorSlots(false) {}
257 static const std::string kStr(
"optimizationParams: ");
258 if (std::holds_alternative<ISAM2GaussNewtonParams>(optimizationParams)) {
259 std::get<ISAM2GaussNewtonParams>(optimizationParams).
print();
260 }
else if (std::holds_alternative<ISAM2DoglegParams>(optimizationParams)) {
261 std::get<ISAM2DoglegParams>(optimizationParams).
print(kStr);
263 cout << kStr <<
"{unknown type}\n";
266 cout <<
"relinearizeThreshold: ";
267 if (std::holds_alternative<double>(relinearizeThreshold)) {
268 cout << std::get<double>(relinearizeThreshold) <<
"\n";
270 cout <<
"{mapped}\n";
271 for (
const ISAM2ThresholdMapValue&
value :
272 std::get<ISAM2ThresholdMap>(relinearizeThreshold)) {
273 cout <<
" '" <<
value.first
274 <<
"' -> [" <<
value.second.transpose() <<
" ]\n";
278 cout <<
"relinearizeSkip: " << relinearizeSkip <<
"\n";
279 cout <<
"enableRelinearization: " << enableRelinearization
281 cout <<
"evaluateNonlinearError: " << evaluateNonlinearError
283 cout <<
"factorization: " 284 << factorizationTranslator(factorization) <<
"\n";
285 cout <<
"cacheLinearizedFactors: " << cacheLinearizedFactors
287 cout <<
"enableDetailedResults: " << enableDetailedResults
289 cout <<
"enablePartialRelinearizationCheck: " 290 << enablePartialRelinearizationCheck <<
"\n";
291 cout <<
"findUnusedFactorSlots: " << findUnusedFactorSlots
300 return this->optimizationParams;
303 return relinearizeThreshold;
306 return factorizationTranslator(factorization);
311 this->optimizationParams = optimizationParams;
314 this->relinearizeThreshold = relinearizeThreshold;
317 this->factorization = factorizationTranslator(factorization);
320 this->keyFormatter = keyFormatter;
324 return factorization == CHOLESKY
void print(const Matrix &A, const string &s, ostream &stream)
FastMap< char, Vector > ISAM2ThresholdMap
bool findUnusedFactorSlots
std::variant< double, FastMap< char, Vector > > RelinearizationThreshold
KeyFormatter keyFormatter
void print(const std::string &str="") const
print iSAM2 parameters
std::variant< ISAM2GaussNewtonParams, ISAM2DoglegParams > OptimizationParams
void print(const std::string str="") const
ISAM2GaussNewtonParams(double _wildfireThreshold=0.001)
void setFactorization(const std::string &factorization)
std::pair< std::shared_ptr< GaussianConditional >, std::shared_ptr< GaussianFactor > > EliminatePreferCholesky(const GaussianFactorGraph &factors, const Ordering &keys)
KeyFormatter getKeyFormatter() const
void setInitialDelta(double initialDelta)
void setKeyFormatter(KeyFormatter keyFormatter)
Factorization factorization
DoglegOptimizerImpl::TrustRegionAdaptationMode adaptationMode
static const KeyFormatter DefaultKeyFormatter
void setVerbose(bool verbose)
std::string getFactorization() const
TrustRegionAdaptationMode
Nonlinear factor graph optimizer using Powell's Dogleg algorithm (detail implementation) ...
bool evaluateNonlinearError
GaussianFactorGraph::Eliminate getEliminationFunction() const
std::function< EliminationResult(const FactorGraphType &, const Ordering &)> Eliminate
The function type that does a single dense elimination step on a subgraph.
RelinearizationThreshold getRelinearizeThreshold() const
Array< double, 1, 3 > e(1./3., 0.5, 2.)
ISAM2DoglegParams(double _initialDelta=1.0, double _wildfireThreshold=1e-5, DoglegOptimizerImpl::TrustRegionAdaptationMode _adaptationMode=DoglegOptimizerImpl::SEARCH_EACH_ITERATION, bool _verbose=false)
Linear Factor Graph where all factors are Gaussians.
std::pair< GaussianConditional::shared_ptr, JacobianFactor::shared_ptr > EliminateQR(const GaussianFactorGraph &factors, const Ordering &keys)
OptimizationParams optimizationParams
double getInitialDelta() const
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
double getWildfireThreshold() const
void setWildfireThreshold(double wildfireThreshold)
void setOptimizationParams(OptimizationParams optimizationParams)
RelinearizationThreshold relinearizeThreshold
bool enableRelinearization
void setWildfireThreshold(double wildfireThreshold)
double initialDelta
The initial trust region radius for Dogleg.
bool enablePartialRelinearizationCheck
std::string getAdaptationMode() const
double getWildfireThreshold() const
ISAM2ThresholdMap::value_type ISAM2ThresholdMapValue
OptimizationParams getOptimizationParams() const
bool verbose
Whether Dogleg prints iteration and convergence information.
bool enableDetailedResults
ISAM2Params(OptimizationParams _optimizationParams=ISAM2GaussNewtonParams(), RelinearizationThreshold _relinearizeThreshold=0.1, int _relinearizeSkip=10, bool _enableRelinearization=true, bool _evaluateNonlinearError=false, Factorization _factorization=ISAM2Params::CHOLESKY, bool _cacheLinearizedFactors=true, const KeyFormatter &_keyFormatter=DefaultKeyFormatter, bool _enableDetailedResults=false)
void print(const std::string str="") const
void setRelinearizeThreshold(RelinearizationThreshold relinearizeThreshold)
bool cacheLinearizedFactors
void setAdaptationMode(const std::string &adaptationMode)