38 SILENT = 0, SUMMARY, TERMINATION, LAMBDA, TRYLAMBDA, TRYCONFIG, DAMPED, TRYDELTA
41 static VerbosityLM verbosityLMTranslator(
const std::string &s);
42 static std::string verbosityLMTranslator(VerbosityLM value);
59 : verbosityLM(SILENT),
60 diagonalDamping(false),
63 SetLegacyDefaults(
this);
82 static void SetCeresDefaults(LevenbergMarquardtParams* p) {
84 p->maxIterations = 50;
85 p->absoluteErrorTol = 0;
86 p->relativeErrorTol = 1e-6;
88 p->lambdaUpperBound = 1e32;
89 p->lambdaLowerBound = 1e-16;
90 p->lambdaInitial = 1e-04;
91 p->lambdaFactor = 2.0;
92 p->minModelFidelity = 1e-3;
93 p->diagonalDamping =
true;
94 p->useFixedLambdaFactor =
false;
97 static LevenbergMarquardtParams LegacyDefaults() {
98 LevenbergMarquardtParams p;
99 SetLegacyDefaults(&p);
103 static LevenbergMarquardtParams CeresDefaults() {
104 LevenbergMarquardtParams p;
105 SetCeresDefaults(&p);
109 static LevenbergMarquardtParams EnsureHasOrdering(LevenbergMarquardtParams params,
110 const NonlinearFactorGraph& graph) {
111 if (!params.ordering)
112 params.ordering = Ordering::Create(params.orderingType, graph);
116 static LevenbergMarquardtParams ReplaceOrdering(LevenbergMarquardtParams params,
117 const Ordering& ordering) {
118 params.ordering = ordering;
122 virtual ~LevenbergMarquardtParams() {}
123 void print(
const std::string& str =
"")
const override;
127 bool getDiagonalDamping()
const {
return diagonalDamping; }
128 double getlambdaFactor()
const {
return lambdaFactor; }
129 double getlambdaInitial()
const {
return lambdaInitial; }
130 double getlambdaLowerBound()
const {
return lambdaLowerBound; }
131 double getlambdaUpperBound()
const {
return lambdaUpperBound; }
132 bool getUseFixedLambdaFactor() {
return useFixedLambdaFactor; }
133 std::string getLogFile()
const {
return logFile; }
134 std::string getVerbosityLM()
const {
return verbosityLMTranslator(verbosityLM);}
136 void setDiagonalDamping(
bool flag) { diagonalDamping = flag; }
137 void setlambdaFactor(
double value) { lambdaFactor = value; }
138 void setlambdaInitial(
double value) { lambdaInitial = value; }
139 void setlambdaLowerBound(
double value) { lambdaLowerBound = value; }
140 void setlambdaUpperBound(
double value) { lambdaUpperBound = value; }
141 void setUseFixedLambdaFactor(
bool flag) { useFixedLambdaFactor = flag;}
142 void setLogFile(
const std::string& s) { logFile = s; }
143 void setVerbosityLM(
const std::string& s) { verbosityLM = verbosityLMTranslator(s);}
149 boost::shared_ptr<NonlinearOptimizerParams>
clone()
const {
boost::shared_ptr< NonlinearOptimizerParams > clone() const
Definition: LevenbergMarquardtParams.h:149
VerbosityLM verbosityLM
The verbosity level for Levenberg-Marquardt (default: SILENT), see also NonlinearOptimizerParams::ver...
Definition: LevenbergMarquardtParams.h:50
double absoluteErrorTol
The maximum absolute error decrease to stop iterating (default 1e-5)
Definition: NonlinearOptimizerParams.h:43
VerbosityLM
See LevenbergMarquardtParams::lmVerbosity.
Definition: LevenbergMarquardtParams.h:37
double lambdaUpperBound
The maximum lambda to try before assuming the optimization has failed (default: 1e5)
Definition: LevenbergMarquardtParams.h:48
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition: Matrix.cpp:141
double lambdaInitial
The initial Levenberg-Marquardt damping term (default: 1e-5)
Definition: LevenbergMarquardtParams.h:46
size_t maxIterations
The maximum iterations to stop iterating (default 100)
Definition: NonlinearOptimizerParams.h:41
Factor Graph Constsiting of non-linear factors.
double lambdaFactor
The amount by which to multiply or divide lambda when adjusting lambda (default: 10....
Definition: LevenbergMarquardtParams.h:47
Parameters for Levenberg-Marquardt optimization.
Definition: LevenbergMarquardtParams.h:33
double maxDiagonal
when using diagonal damping saturates the maximum diagonal entries (default: 1e32)
Definition: LevenbergMarquardtParams.h:56
std::string logFile
an optional CSV log file, with [iteration, time, error, lambda]
Definition: LevenbergMarquardtParams.h:52
Parameters for nonlinear optimization.
double lambdaLowerBound
The minimum lambda used in LM (default: 0)
Definition: LevenbergMarquardtParams.h:49
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
bool useFixedLambdaFactor
if true applies constant increase (or decrease) to lambda according to lambdaFactor
Definition: LevenbergMarquardtParams.h:54
The common parameters for Nonlinear optimizers.
Definition: NonlinearOptimizerParams.h:34
double minDiagonal
when using diagonal damping saturates the minimum diagonal entries (default: 1e-6)
Definition: LevenbergMarquardtParams.h:55
double minModelFidelity
Lower bound for the modelFidelity to accept the result of an LM iteration.
Definition: LevenbergMarquardtParams.h:51
bool diagonalDamping
if true, use diagonal of Hessian
Definition: LevenbergMarquardtParams.h:53
double relativeErrorTol
The maximum relative error decrease to stop iterating (default 1e-5)
Definition: NonlinearOptimizerParams.h:42