-
-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| name = "SciMLBase" | ||
| uuid = "0bca4576-84f4-4d90-8ffe-ffa030f20462" | ||
| authors = ["Chris Rackauckas <[email protected]> and contributors"] | ||
| version = "2.88.0" | ||
| version = "2.89.0" | ||
|
|
||
| [deps] | ||
| ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b" | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -282,7 +282,17 @@ function get_initial_values(prob, valp, f, alg::OverrideInit, | |||||
| throw(OverrideInitNoTolerance(:reltol)) | ||||||
| end | ||||||
| nlsol = solve(initprob, nlsolve_alg; abstol = _abstol, reltol = _reltol, kwargs...) | ||||||
| success = SciMLBase.successful_retcode(nlsol) | ||||||
|
|
||||||
| success = if initprob isa NonlinearLeastSquaresProblem | ||||||
| # Do not accept StalledSuccess as a solution | ||||||
| # A good local minima is not a success | ||||||
| resid = nlsol.resid | ||||||
| normresid = isdefined(integrator.opts, :internalnorm) ? | ||||||
| integrator.opts.internalnorm(resid, t) : norm(resid) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||
| SciMLBase.successful_retcode(nlsol) && normresid <= abstol | ||||||
| else | ||||||
| SciMLBase.successful_retcode(nlsol) | ||||||
| end | ||||||
| end | ||||||
|
|
||||||
| if initdata.initializeprobmap !== nothing | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -392,15 +392,36 @@ EnumX.@enumx ReturnCode begin | |||||||||
| ReturnCode.Stalled | ||||||||||
|
|
||||||||||
| The solution has stalled. This is only returned by algorithms for which stalling is a | ||||||||||
| failure mode. Certain solvers like Nonlinear Least Squares solvers are considered | ||||||||||
| successful if the solution has stalled, in those cases `ReturnCode.Success` is returned. | ||||||||||
| failure mode, such as on a NonlinearProblem where the found solution is larger than | ||||||||||
| the accepted tolerance. | ||||||||||
|
|
||||||||||
| ## Properties | ||||||||||
|
|
||||||||||
| - `successful_retcode` = `false` | ||||||||||
| """ | ||||||||||
| Stalled | ||||||||||
|
|
||||||||||
| """ | ||||||||||
| ReturnCode.StalledSuccess | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||||
|
|
||||||||||
| 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. | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||||
|
|
||||||||||
| ## Common Reasons for Seeing this Return Code | ||||||||||
|
|
||||||||||
| - 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 | ||||||||||
|
Comment on lines
+413
to
+414
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||||
| ReturnCode.Success but it is still considered a sucessful return of the solver since | ||||||||||
| it's a valid local minima (and there no minima which achieves the tolerance). | ||||||||||
|
|
||||||||||
| ## Properties | ||||||||||
|
|
||||||||||
| - `successful_retcode` = `true` | ||||||||||
|
|
||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||||
| """ | ||||||||||
| StalledSuccess | ||||||||||
|
|
||||||||||
| """ | ||||||||||
| ReturnCode.InternalLinearSolveFailed | ||||||||||
|
|
||||||||||
|
|
@@ -510,6 +531,7 @@ function successful_retcode(retcode::ReturnCode.T) | |||||||||
| retcode == ReturnCode.Success || retcode == ReturnCode.Terminated || | ||||||||||
| retcode == ReturnCode.ExactSolutionLeft || | ||||||||||
| retcode == ReturnCode.ExactSolutionRight || | ||||||||||
| retcode == ReturnCode.FloatingPointLimit | ||||||||||
| retcode == ReturnCode.FloatingPointLimit || | ||||||||||
| retcode == ReturnCode.StalledSuccess | ||||||||||
| end | ||||||||||
| successful_retcode(sol::AbstractSciMLSolution) = successful_retcode(sol.retcode) | ||||||||||
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
integratoris not defined here. This causes test errors in ModelingToolkit, e.g. https://github.com/SciML/ModelingToolkit.jl/actions/runs/14966367552/job/42037129153?pr=3624There 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