-
-
Notifications
You must be signed in to change notification settings - Fork 113
Add StalledSuccess and improve return code documentation #1016
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
Conversation
|
Tested locally. |
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
| integrator.opts.internalnorm(resid, t) : norm(resid) | |
| integrator.opts.internalnorm(resid, t) : norm(resid) |
| Stalled | ||
|
|
||
| """ | ||
| ReturnCode.StalledSuccess |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
| 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
| is a valid local minima. | |
| is a valid local minima. |
| - 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
| - 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` | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
| # Do not accept StalledSuccess as a solution | ||
| # A good local minima is not a success | ||
| resid = nlsol.resid | ||
| normresid = isdefined(integrator.opts, :internalnorm) ? |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
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.
No description provided.