Added a check to NonlinearOptimizer to short circuit optimization if the initial error is below the absolute threshold.
parent
4ae9b72a35
commit
d6c2b415a5
|
@ -186,6 +186,10 @@ namespace gtsam {
|
|||
double relativeThreshold, double absoluteThreshold,
|
||||
verbosityLevel verbosity, int maxIterations, double lambdaFactor) const {
|
||||
|
||||
// check if we're already close enough
|
||||
if (error_ < absoluteThreshold)
|
||||
return *this;
|
||||
|
||||
// do one iteration of LM
|
||||
NonlinearOptimizer next = iterateLM(verbosity, lambdaFactor);
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ using namespace boost;
|
|||
using namespace gtsam;
|
||||
using namespace example;
|
||||
|
||||
const double tol = 1e-6;
|
||||
const double tol = 1e-5;
|
||||
|
||||
typedef NonlinearOptimizer<Graph,Config> Optimizer;
|
||||
|
||||
|
|
|
@ -627,14 +627,14 @@ TEST (SQP, stereo_truth_noisy ) {
|
|||
VOptimizer optimizer(optimizer0.levenbergMarquardt(relThresh, absThresh, VOptimizer::SILENT));
|
||||
|
||||
// verify
|
||||
DOUBLES_EQUAL(0.0, optimizer.error(), 1e-9);
|
||||
DOUBLES_EQUAL(0.0, optimizer.error(), 1e-5);
|
||||
|
||||
// check if correct
|
||||
if (verbose) {
|
||||
optimizer.config()->print("After iteration");
|
||||
cout << "Final error: " << optimizer.error() << endl;
|
||||
}
|
||||
CHECK(assert_equal(*truthConfig,*(optimizer.config())));
|
||||
CHECK(assert_equal(*truthConfig,*(optimizer.config()), 1e-5));
|
||||
}
|
||||
|
||||
/* ********************************************************************* */
|
||||
|
|
Loading…
Reference in New Issue