Added a check to NonlinearOptimizer to short circuit optimization if the initial error is below the absolute threshold.

release/4.3a0
Alex Cunningham 2010-03-04 22:46:27 +00:00
parent 4ae9b72a35
commit d6c2b415a5
3 changed files with 7 additions and 3 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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));
}
/* ********************************************************************* */