Skip to content

Commit

Permalink
Fix issue 468 (Levenberg-Marquardt damping term)
Browse files Browse the repository at this point in the history
The damping term doesn't blow up so rapidly when the refinement is fully
converged (i.e. objective stops changing)
  • Loading branch information
dwpaley committed May 8, 2020
1 parent 351af37 commit 53f5d2c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scitbx/lstbx/normal_eqns_solving.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def do(self):
objective_new = self.non_linear_ls.objective()
actual_decrease = objective - objective_new
rho = actual_decrease/expected_decrease
if rho > 0:
if rho >= 0:
if self.has_gradient_converged_to_zero(): break
self.mu *= max(1/3, 1 - (2*rho - 1)**3)
nu = 2
Expand Down Expand Up @@ -325,7 +325,7 @@ def do(self):
rho = actual_decrease/expected_decrease
if self.objective_decrease_threshold is not None:
if actual_decrease/objective < self.objective_decrease_threshold: break
if rho > 0:
if rho >= 0:
if self.has_gradient_converged_to_zero(): break
self.mu *= max(1/3, 1 - (2*rho - 1)**3)
nu = 2
Expand Down
8 changes: 8 additions & 0 deletions scitbx/lstbx/tests/tst_normal_equations.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ def exercise_levenberg_marquardt(non_linear_ls, plot=False):
print("\[Mu]=%s;" % iterations.mu_history.mathematica_form(), file=f)
print("ListLogPlot[{g,\[Mu]},Joined->True]", file=f)
f.close()
non_linear_ls.restart()
iterations = normal_eqns_solving.levenberg_marquardt_iterations(
non_linear_ls,
track_all=True,
gradient_threshold=0,
step_threshold=0,
n_max_iterations=200)
assert iterations.n_iterations == 200

def run():
import sys
Expand Down

0 comments on commit 53f5d2c

Please sign in to comment.