28class LevenbergMarquardtOptimizer;
40 SILENT = 0, SUMMARY, TERMINATION, LAMBDA, TRYLAMBDA, TRYCONFIG, DAMPED, TRYDELTA
43 static VerbosityLM verbosityLMTranslator(
const std::string &s);
44 static std::string verbosityLMTranslator(VerbosityLM value);
62 : verbosityLM(SILENT),
63 diagonalDamping(false),
66 SetLegacyDefaults(
this);
85 static void SetCeresDefaults(LevenbergMarquardtParams* p) {
87 p->maxIterations = 50;
88 p->absoluteErrorTol = 0;
89 p->relativeErrorTol = 1e-6;
91 p->lambdaUpperBound = 1e32;
92 p->lambdaLowerBound = 1e-16;
93 p->lambdaInitial = 1e-04;
94 p->lambdaFactor = 2.0;
95 p->minModelFidelity = 1e-3;
96 p->diagonalDamping =
true;
97 p->useFixedLambdaFactor =
false;
100 static LevenbergMarquardtParams LegacyDefaults() {
101 LevenbergMarquardtParams p;
102 SetLegacyDefaults(&p);
106 static LevenbergMarquardtParams CeresDefaults() {
107 LevenbergMarquardtParams p;
108 SetCeresDefaults(&p);
112 static LevenbergMarquardtParams EnsureHasOrdering(LevenbergMarquardtParams params,
113 const NonlinearFactorGraph& graph) {
114 if (!params.ordering)
115 params.ordering = Ordering::Create(params.orderingType, graph);
119 static LevenbergMarquardtParams ReplaceOrdering(LevenbergMarquardtParams params,
120 const Ordering& ordering) {
121 params.ordering = ordering;
125 ~LevenbergMarquardtParams()
override {}
126 void print(
const std::string& str =
"")
const override;
130 bool getDiagonalDamping()
const {
return diagonalDamping; }
131 double getlambdaFactor()
const {
return lambdaFactor; }
132 double getlambdaInitial()
const {
return lambdaInitial; }
133 double getlambdaLowerBound()
const {
return lambdaLowerBound; }
134 double getlambdaUpperBound()
const {
return lambdaUpperBound; }
135 bool getUseFixedLambdaFactor() {
return useFixedLambdaFactor; }
136 std::string getLogFile()
const {
return logFile; }
137 std::string getVerbosityLM()
const {
return verbosityLMTranslator(verbosityLM);}
139 void setDiagonalDamping(
bool flag) { diagonalDamping = flag; }
140 void setlambdaFactor(
double value) { lambdaFactor = value; }
141 void setlambdaInitial(
double value) { lambdaInitial = value; }
142 void setlambdaLowerBound(
double value) { lambdaLowerBound = value; }
143 void setlambdaUpperBound(
double value) { lambdaUpperBound = value; }
144 void setUseFixedLambdaFactor(
bool flag) { useFixedLambdaFactor = flag;}
145 void setLogFile(
const std::string& s) { logFile = s; }
146 void setVerbosityLM(
const std::string& s) { verbosityLM = verbosityLMTranslator(s);}
152 boost::shared_ptr<NonlinearOptimizerParams>
clone()
const {
Parameters for nonlinear optimization.
Factor Graph consisting of non-linear factors.
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition: Matrix.cpp:155
This class performs Levenberg-Marquardt nonlinear optimization.
Definition: LevenbergMarquardtOptimizer.h:35
Parameters for Levenberg-Marquardt optimization.
Definition: LevenbergMarquardtParams.h:35
double lambdaFactor
The amount by which to multiply or divide lambda when adjusting lambda (default: 10....
Definition: LevenbergMarquardtParams.h:50
double minDiagonal
when using diagonal damping saturates the minimum diagonal entries (default: 1e-6)
Definition: LevenbergMarquardtParams.h:58
double lambdaUpperBound
The maximum lambda to try before assuming the optimization has failed (default: 1e5)
Definition: LevenbergMarquardtParams.h:51
double lambdaInitial
The initial Levenberg-Marquardt damping term (default: 1e-5)
Definition: LevenbergMarquardtParams.h:49
double maxDiagonal
when using diagonal damping saturates the maximum diagonal entries (default: 1e32)
Definition: LevenbergMarquardtParams.h:59
double minModelFidelity
Lower bound for the modelFidelity to accept the result of an LM iteration.
Definition: LevenbergMarquardtParams.h:54
double lambdaLowerBound
The minimum lambda used in LM (default: 0)
Definition: LevenbergMarquardtParams.h:52
boost::shared_ptr< NonlinearOptimizerParams > clone() const
Definition: LevenbergMarquardtParams.h:152
bool diagonalDamping
if true, use diagonal of Hessian
Definition: LevenbergMarquardtParams.h:56
bool useFixedLambdaFactor
if true applies constant increase (or decrease) to lambda according to lambdaFactor
Definition: LevenbergMarquardtParams.h:57
std::string logFile
an optional CSV log file, with [iteration, time, error, lambda]
Definition: LevenbergMarquardtParams.h:55
VerbosityLM
See LevenbergMarquardtParams::lmVerbosity.
Definition: LevenbergMarquardtParams.h:39
VerbosityLM verbosityLM
The verbosity level for Levenberg-Marquardt (default: SILENT), see also NonlinearOptimizerParams::ver...
Definition: LevenbergMarquardtParams.h:53
The common parameters for Nonlinear optimizers.
Definition: NonlinearOptimizerParams.h:34
double absoluteErrorTol
The maximum absolute error decrease to stop iterating (default 1e-5)
Definition: NonlinearOptimizerParams.h:43
size_t maxIterations
The maximum iterations to stop iterating (default 100)
Definition: NonlinearOptimizerParams.h:41
double relativeErrorTol
The maximum relative error decrease to stop iterating (default 1e-5)
Definition: NonlinearOptimizerParams.h:42