Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue 468 (Levenberg-Marquardt damping term) #473

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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