SciML / NonlinearSolve.jl

High-performance and differentiation-enabled nonlinear solvers (Newton methods), bracketed rootfinding (bisection, Falsi), with sparsity and Newton-Krylov support.
https://docs.sciml.ai/NonlinearSolve/stable/
MIT License
226 stars 40 forks source link

GaussNewton returns unstable when problem is converged #284

Closed vpuri3 closed 9 months ago

vpuri3 commented 9 months ago
julia> sol = solve(NonlinearLeastSquaresProblem((x, p) -> x, ones(3)), GaussNewton())
u: 3-element Vector{Float64}:
 0.0
 0.0
 0.0

julia> sol.retcode
ReturnCode.Success = 1

julia> sol = solve(NonlinearLeastSquaresProblem((x, p) -> x, zeros(3)), GaussNewton())
u: 3-element Vector{Float64}:
 0.0
 0.0
 0.0

julia> sol.retcode
ReturnCode.Unstable = 6
avik-pal commented 9 months ago

https://github.com/SciML/DiffEqBase.jl/blob/8c0db9efb1a3907e3abb596545474621986b36fc/src/termination_conditions.jl#L290 line needs to be > else if the initial point is the solution, we hit protective termination