From eada34bd765b452d84d3fe1b33a25b78c7bdfb24 Mon Sep 17 00:00:00 2001 From: Kai Ni Date: Thu, 30 Dec 2010 11:15:34 +0000 Subject: [PATCH] fixed a bug that causes the optimizer return an incorrect error --- gtsam/nonlinear/NonlinearOptimizer-inl.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/gtsam/nonlinear/NonlinearOptimizer-inl.h b/gtsam/nonlinear/NonlinearOptimizer-inl.h index 7cb0e6ae1..33f8d7cd4 100644 --- a/gtsam/nonlinear/NonlinearOptimizer-inl.h +++ b/gtsam/nonlinear/NonlinearOptimizer-inl.h @@ -149,10 +149,9 @@ namespace gtsam { if( lambdaMode >= Parameters::CAUTIOUS) throw runtime_error("CAUTIOUS mode not working yet, please use BOUNDED."); - bool first_iteration = true; double next_error = error_; - shared_values next_values; + shared_values next_values = values_; while(true) { if (verbosity >= Parameters::TRYLAMBDA) cout << "trying lambda = " << lambda << endl; @@ -189,12 +188,8 @@ namespace gtsam { if (verbosity >= Parameters::TRYLAMBDA) cout << "next error = " << error << endl; - if(first_iteration || error <= error_) { - next_values = newValues; - first_iteration = false; - } - if( error <= error_ ) { + next_values = newValues; next_error = error; lambda /= factor; break;