Skip to content

Conversation

@ChrisRackauckas
Copy link
Member

No description provided.

@ChrisRackauckas
Copy link
Member Author

Tested locally.

@ChrisRackauckas ChrisRackauckas merged commit 80e6ea5 into master May 12, 2025
39 of 59 checks passed
@ChrisRackauckas ChrisRackauckas deleted the stalledsuccess branch May 12, 2025 01:22
ChrisRackauckas added a commit to SciML/NonlinearSolve.jl that referenced this pull request May 12, 2025
Fixes #459. The crux of the issue is that `f(x) = residual` only applies in the NonlinearProblem and SteadyStateProblem cases. When `f(x)` is a nonlinear least squares problem, finding a local minima is a solution, not a failure of the algorithm. Thus this reclassifies Stalled in NLLSQ to StalledSuccess, which makes it a successful return.

Algorithms which require the NonlinearLeastSquares solution to have `||resid|| < tol` thus need to be careful with the return handling, as is done in the PR that introduces this return code SciML/SciMLBase.jl#1016. However, that's a fairly odd case because it's feasibility checking, while the normal use case for NLLSQ is for optimization, and in an optimization case there's no reason to believe you should always have a solution close to zero.
# A good local minima is not a success
resid = nlsol.resid
normresid = isdefined(integrator.opts, :internalnorm) ?
integrator.opts.internalnorm(resid, t) : norm(resid)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
integrator.opts.internalnorm(resid, t) : norm(resid)
integrator.opts.internalnorm(resid, t) : norm(resid)

Stalled

"""
ReturnCode.StalledSuccess
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
ReturnCode.StalledSuccess
ReturnCode.StalledSuccess

The solution process has stalled, but the stall is not considered a failure of the solver.
For example, a nonlinear optimizer may have stalled, that is its steps went to zero, which
is a valid local minima.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
is a valid local minima.
is a valid local minima.

Comment on lines +413 to +414
- For nonlinear least squares optimizations, this is given for local minima which exceed
the chosen tolerance, i.e. `f(x)=resid` where `||resid||>tol` so it's not considered
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
- For nonlinear least squares optimizations, this is given for local minima which exceed
the chosen tolerance, i.e. `f(x)=resid` where `||resid||>tol` so it's not considered
- For nonlinear least squares optimizations, this is given for local minima which exceed
the chosen tolerance, i.e. `f(x)=resid` where `||resid||>tol` so it's not considered

## Properties
- `successful_retcode` = `true`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

# Do not accept StalledSuccess as a solution
# A good local minima is not a success
resid = nlsol.resid
normresid = isdefined(integrator.opts, :internalnorm) ?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChrisRackauckas integrator is not defined here. This causes test errors in ModelingToolkit, e.g. https://github.com/SciML/ModelingToolkit.jl/actions/runs/14966367552/job/42037129153?pr=3624

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for noticing. #1020 addresses this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ehh fuck. thanks for catching this

ChrisRackauckas added a commit to SciML/NonlinearSolve.jl that referenced this pull request May 13, 2025
Fixes #459. The crux of the issue is that `f(x) = residual` only applies in the NonlinearProblem and SteadyStateProblem cases. When `f(x)` is a nonlinear least squares problem, finding a local minima is a solution, not a failure of the algorithm. Thus this reclassifies Stalled in NLLSQ to StalledSuccess, which makes it a successful return.

Algorithms which require the NonlinearLeastSquares solution to have `||resid|| < tol` thus need to be careful with the return handling, as is done in the PR that introduces this return code SciML/SciMLBase.jl#1016. However, that's a fairly odd case because it's feasibility checking, while the normal use case for NLLSQ is for optimization, and in an optimization case there's no reason to believe you should always have a solution close to zero.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants