Skip to content

Commit da6b151

Browse files
Merge pull request #797 from SciML/fix-issue-734-retcode-docs
Update return code documentation to reflect enum implementation
2 parents 7bc71f7 + 3865303 commit da6b151

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

docs/src/basics/faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ the solution quickly diverges to infinity! This means, double-check your paramet
3232
are indexed correctly!
3333

3434
**Note: if you see these warnings during a parameter estimation process, this is
35-
likely the underlying problem. Simply check `SciMLBase.successful_retcode(sol.retcode)` and throw
35+
likely the underlying problem. Simply check `SciMLBase.successful_retcode(sol)` and throw
3636
an `Inf` cost. Most optimizers will then reject steps in those parameter regimes!**
3737

3838
There are a few other things to check as well. Often, the stability of

docs/src/basics/solution.md

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -181,23 +181,41 @@ SciMLBase.DEStats
181181

182182
## [Return Codes (RetCodes)](@id retcodes)
183183

184-
The solution types have a `retcode` field which returns a symbol signifying the
185-
error state of the solution. The retcodes are as follows:
184+
The solution types have a `retcode` field which returns an enum value signifying the
185+
error state of the solution. Return codes are now implemented as an enum using EnumX.jl
186+
rather than symbols.
186187

187-
- `:Default`: The solver did not set retcodes.
188-
- `:Success`: The integration completed without erroring or the steady state solver
188+
To check if a solution was successful, use:
189+
```julia
190+
SciMLBase.successful_retcode(sol)
191+
```
192+
193+
!!! warning
194+
Previous iterations of the interface suggested using `sol.retcode == :Success`,
195+
however, that is now not advised because there are more than one return code that can be interpreted
196+
as successful. For example, `Terminated` is a successful run to a manual termination, and would be missed
197+
if only checking for Success. Therefore we highly recommend you use `SciMLBase.successful_retcode(sol)` instead.
198+
199+
The return codes include are accessed via the ReturnCode module, i.e. `SciMLBase.ReturnCode.Success`. The
200+
following are major return codes to know:
201+
202+
- `Default`: The solver did not set retcodes.
203+
- `Success`: The integration completed without erroring or the steady state solver
189204
from `SteadyStateDiffEq` found the steady state.
190-
- `:Terminated`: The integration is terminated with `terminate!(integrator)`.
205+
- `Terminated`: The integration is terminated with `terminate!(integrator)`.
191206
Note that this may occur by using `TerminateSteadyState` from the callback
192207
library `DiffEqCallbacks`.
193-
- `:MaxIters`: The integration exited early because it reached its maximum number
208+
- `MaxIters`: The integration exited early because it reached its maximum number
194209
of iterations.
195-
- `:DtLessThanMin`: The timestep method chose a stepsize which is smaller than the
210+
- `DtLessThanMin`: The timestep method chose a stepsize which is smaller than the
196211
allowed minimum timestep, and exited early.
197-
- `:Unstable`: The solver detected that the solution was unstable and exited early.
198-
- `:InitialFailure`: The DAE solver could not find consistent initial conditions.
199-
- `:ConvergenceFailure`: The internal implicit solvers failed to converge.
200-
- `:Failure`: General uncategorized failures or errors.
212+
- `Unstable`: The solver detected that the solution was unstable and exited early.
213+
- `InitialFailure`: The DAE solver could not find consistent initial conditions.
214+
- `ConvergenceFailure`: The internal implicit solvers failed to converge.
215+
- `Failure`: General uncategorized failures or errors.
216+
217+
For a complete list of return codes and their properties, see the
218+
[SciMLBase ReturnCode documentation](https://docs.sciml.ai/SciMLBase/stable/interfaces/Solutions/#retcodes).
201219

202220
## Problem-Specific Features
203221

0 commit comments

Comments
 (0)