created infrastruction for more general lambda policies in LM
parent
8755e08dad
commit
8be9d37d72
|
@ -74,6 +74,16 @@ GaussianFactorGraph::shared_ptr LevenbergMarquardtOptimizer::linearize() const {
|
||||||
return graph_.linearize(state_.values);
|
return graph_.linearize(state_.values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ************************************************************************* */
|
||||||
|
void LevenbergMarquardtOptimizer::increaseLambda(){
|
||||||
|
state_.lambda *= params_.lambdaFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ************************************************************************* */
|
||||||
|
void LevenbergMarquardtOptimizer::decreaseLambda(){
|
||||||
|
state_.lambda /= params_.lambdaFactor;
|
||||||
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
void LevenbergMarquardtOptimizer::iterate() {
|
void LevenbergMarquardtOptimizer::iterate() {
|
||||||
|
|
||||||
|
@ -146,7 +156,7 @@ void LevenbergMarquardtOptimizer::iterate() {
|
||||||
if (error <= state_.error) {
|
if (error <= state_.error) {
|
||||||
state_.values.swap(newValues);
|
state_.values.swap(newValues);
|
||||||
state_.error = error;
|
state_.error = error;
|
||||||
state_.lambda /= params_.lambdaFactor;
|
decreaseLambda();
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
// Either we're not cautious, or the same lambda was worse than the current error.
|
// Either we're not cautious, or the same lambda was worse than the current error.
|
||||||
|
@ -157,7 +167,8 @@ void LevenbergMarquardtOptimizer::iterate() {
|
||||||
cout << "Warning: Levenberg-Marquardt giving up because cannot decrease error with maximum lambda" << endl;
|
cout << "Warning: Levenberg-Marquardt giving up because cannot decrease error with maximum lambda" << endl;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
state_.lambda *= params_.lambdaFactor;
|
cout << "increasing lambda: old error (" << state_.error << ") new error (" << error << ")" << endl;
|
||||||
|
increaseLambda();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IndeterminantLinearSystemException& e) {
|
} catch (IndeterminantLinearSystemException& e) {
|
||||||
|
@ -172,7 +183,7 @@ void LevenbergMarquardtOptimizer::iterate() {
|
||||||
cout << "Warning: Levenberg-Marquardt giving up because cannot decrease error with maximum lambda" << endl;
|
cout << "Warning: Levenberg-Marquardt giving up because cannot decrease error with maximum lambda" << endl;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
state_.lambda *= params_.lambdaFactor;
|
increaseLambda();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Frank asks: why would we do that?
|
// Frank asks: why would we do that?
|
||||||
|
|
|
@ -174,6 +174,12 @@ public:
|
||||||
return state_.lambda;
|
return state_.lambda;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apply policy to increase lambda if the current update was successful
|
||||||
|
virtual void increaseLambda();
|
||||||
|
|
||||||
|
// Apply policy to decrease lambda if the current update was NOT successful
|
||||||
|
virtual void decreaseLambda();
|
||||||
|
|
||||||
/// Access the current number of inner iterations
|
/// Access the current number of inner iterations
|
||||||
int getInnerIterations() const {
|
int getInnerIterations() const {
|
||||||
return state_.totalNumberInnerIterations;
|
return state_.totalNumberInnerIterations;
|
||||||
|
|
Loading…
Reference in New Issue