Skip to content

Commit

Permalink
fix: update the success flag of lm
Browse files Browse the repository at this point in the history
  • Loading branch information
rzyu45 committed Dec 28, 2024
1 parent 0b5fbcc commit 08628f8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Solverz/solvers/nlaesolver/lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ def lm(eqn: nAE,

# optimize.root func cannot handle callable jac that returns scipy.sparse.csc_array
sol = optimize.root(lambda x: eqn.F(x, p), y, jac=lambda x: eqn.J(x, p).toarray(), method='lm', tol=tol)
stats.succeed = sol.success
dF = eqn.F(sol.y, eqn.p)
if np.max(np.abs(dF)) < tol:
stats.succeed = True
stats.nfeval = sol.nfev

return aesol(sol.x, stats)

0 comments on commit 08628f8

Please sign in to comment.