24 #include <boost/variant.hpp> 42 double _wildfireThreshold =
46 : wildfireThreshold(_wildfireThreshold) {}
50 cout <<
str <<
"type: ISAM2GaussNewtonParams\n";
51 cout << str <<
"wildfireThreshold: " << wildfireThreshold <<
"\n";
57 this->wildfireThreshold = wildfireThreshold;
80 double _initialDelta = 1.0,
81 double _wildfireThreshold =
85 SEARCH_EACH_ITERATION,
88 : initialDelta(_initialDelta),
89 wildfireThreshold(_wildfireThreshold),
90 adaptationMode(_adaptationMode),
95 cout <<
str <<
"type: ISAM2DoglegParams\n";
96 cout << str <<
"initialDelta: " << initialDelta <<
"\n";
97 cout << str <<
"wildfireThreshold: " << wildfireThreshold <<
"\n";
99 <<
"adaptationMode: " << adaptationModeTranslator(adaptationMode)
107 return adaptationModeTranslator(adaptationMode);
111 this->initialDelta = initialDelta;
114 this->wildfireThreshold = wildfireThreshold;
117 this->adaptationMode = adaptationModeTranslator(adaptationMode);
121 std::string adaptationModeTranslator(
125 const std::string& adaptationMode)
const;
136 typedef boost::variant<ISAM2GaussNewtonParams, ISAM2DoglegParams>
138 typedef boost::variant<double, FastMap<char, Vector> >
232 int _relinearizeSkip = 10,
bool _enableRelinearization =
true,
233 bool _evaluateNonlinearError =
false,
235 bool _cacheLinearizedFactors =
true,
238 bool _enableDetailedResults =
false)
239 : optimizationParams(_optimizationParams),
240 relinearizeThreshold(_relinearizeThreshold),
241 relinearizeSkip(_relinearizeSkip),
242 enableRelinearization(_enableRelinearization),
243 evaluateNonlinearError(_evaluateNonlinearError),
244 factorization(_factorization),
245 cacheLinearizedFactors(_cacheLinearizedFactors),
246 keyFormatter(_keyFormatter),
247 enableDetailedResults(_enableDetailedResults),
248 enablePartialRelinearizationCheck(false),
249 findUnusedFactorSlots(false) {}
256 static const std::string kStr(
"optimizationParams: ");
258 boost::get<ISAM2GaussNewtonParams>(optimizationParams).
print();
260 boost::get<ISAM2DoglegParams>(optimizationParams).
print(kStr);
262 cout << kStr <<
"{unknown type}\n";
264 cout <<
"relinearizeThreshold: ";
265 if (relinearizeThreshold.type() ==
typeid(double)) {
266 cout << boost::get<double>(relinearizeThreshold) <<
"\n";
268 cout <<
"{mapped}\n";
269 for (
const ISAM2ThresholdMapValue&
value :
270 boost::get<ISAM2ThresholdMap>(relinearizeThreshold)) {
271 cout <<
" '" <<
value.first
272 <<
"' -> [" <<
value.second.transpose() <<
" ]\n";
276 cout <<
"relinearizeSkip: " << relinearizeSkip <<
"\n";
277 cout <<
"enableRelinearization: " << enableRelinearization
279 cout <<
"evaluateNonlinearError: " << evaluateNonlinearError
281 cout <<
"factorization: " 282 << factorizationTranslator(factorization) <<
"\n";
283 cout <<
"cacheLinearizedFactors: " << cacheLinearizedFactors
285 cout <<
"enableDetailedResults: " << enableDetailedResults
287 cout <<
"enablePartialRelinearizationCheck: " 288 << enablePartialRelinearizationCheck <<
"\n";
289 cout <<
"findUnusedFactorSlots: " << findUnusedFactorSlots
298 return this->optimizationParams;
301 return relinearizeThreshold;
307 return factorizationTranslator(factorization);
313 return enablePartialRelinearizationCheck;
317 this->optimizationParams = optimizationParams;
320 this->relinearizeThreshold = relinearizeThreshold;
323 this->relinearizeSkip = relinearizeSkip;
326 this->enableRelinearization = enableRelinearization;
329 this->evaluateNonlinearError = evaluateNonlinearError;
332 this->factorization = factorizationTranslator(factorization);
335 this->cacheLinearizedFactors = cacheLinearizedFactors;
338 this->keyFormatter = keyFormatter;
341 this->enableDetailedResults = enableDetailedResults;
344 bool enablePartialRelinearizationCheck) {
345 this->enablePartialRelinearizationCheck = enablePartialRelinearizationCheck;
349 return factorization == CHOLESKY
GaussianFactorGraph::Eliminate getEliminationFunction() const
void print(const Matrix &A, const string &s, ostream &stream)
bool findUnusedFactorSlots
KeyFormatter getKeyFormatter() const
void setRelinearizeSkip(int relinearizeSkip)
double getWildfireThreshold() const
KeyFormatter keyFormatter
void setEnablePartialRelinearizationCheck(bool enablePartialRelinearizationCheck)
void setEnableDetailedResults(bool enableDetailedResults)
ISAM2GaussNewtonParams(double _wildfireThreshold=0.001)
void setFactorization(const std::string &factorization)
void setInitialDelta(double initialDelta)
void setKeyFormatter(KeyFormatter keyFormatter)
Factorization factorization
bool isEvaluateNonlinearError() const
DoglegOptimizerImpl::TrustRegionAdaptationMode adaptationMode
static const KeyFormatter DefaultKeyFormatter
std::pair< boost::shared_ptr< GaussianConditional >, boost::shared_ptr< GaussianFactor > > EliminatePreferCholesky(const GaussianFactorGraph &factors, const Ordering &keys)
void setCacheLinearizedFactors(bool cacheLinearizedFactors)
void setVerbose(bool verbose)
bool isEnablePartialRelinearizationCheck() const
TrustRegionAdaptationMode
void print(const std::string str="") const
boost::variant< ISAM2GaussNewtonParams, ISAM2DoglegParams > OptimizationParams
void setEnableRelinearization(bool enableRelinearization)
void print(const std::string str="") const
Nonlinear factor graph optimizer using Powell's Dogleg algorithm (detail implementation) ...
double getInitialDelta() const
bool evaluateNonlinearError
std::string getFactorization() const
RelinearizationThreshold getRelinearizeThreshold() const
OptimizationParams getOptimizationParams() const
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
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)
bool isCacheLinearizedFactors() const
Linear Factor Graph where all factors are Gaussians.
OptimizationParams optimizationParams
void print(const std::string &str="") const
print iSAM2 parameters
void setWildfireThreshold(double wildfireThreshold)
void setOptimizationParams(OptimizationParams optimizationParams)
RelinearizationThreshold relinearizeThreshold
double getWildfireThreshold() const
bool isEnableRelinearization() const
int getRelinearizeSkip() const
bool enableRelinearization
void setWildfireThreshold(double wildfireThreshold)
double initialDelta
The initial trust region radius for Dogleg.
void setEvaluateNonlinearError(bool evaluateNonlinearError)
bool enablePartialRelinearizationCheck
std::string getAdaptationMode() const
boost::function< EliminationResult(const FactorGraphType &, const Ordering &)> Eliminate
The function type that does a single dense elimination step on a subgraph.
ISAM2ThresholdMap::value_type ISAM2ThresholdMapValue
boost::variant< double, FastMap< char, Vector > > RelinearizationThreshold
bool verbose
Whether Dogleg prints iteration and convergence information.
bool isEnableDetailedResults() const
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)
std::pair< GaussianConditional::shared_ptr, JacobianFactor::shared_ptr > EliminateQR(const GaussianFactorGraph &factors, const Ordering &keys)
void setRelinearizeThreshold(RelinearizationThreshold relinearizeThreshold)
FastMap< char, Vector > ISAM2ThresholdMap
bool cacheLinearizedFactors
void setAdaptationMode(const std::string &adaptationMode)