Added threshold for lambda in NonlinearOptimizer so that if lambda has gotten unreasonably large, optimization will throw a runtime exception to prevent infinite loops where lambda goes to infinity.

release/4.3a0
Alex Cunningham 2010-03-01 16:31:05 +00:00
parent c20498c688
commit a46dc4cea0
1 changed files with 2 additions and 0 deletions

View File

@ -147,6 +147,8 @@ namespace gtsam {
// if error decreased, return the new state
if (next.error_ <= error_)
return next;
else if (lambda_ / factor > 1e+80) // if lambda gets too big, something is broken
throw runtime_error("Lambda has grown too large!");
else {
// TODO: can we avoid copying the config ?
NonlinearOptimizer cautious(graph_, config_, solver_, lambda_ * factor);