Termination Conditions
Provides a API to specify termination conditions for NonlinearProblem
and SteadyStateProblem
. For details on the various termination modes:
Termination Conditions
The termination condition is constructed as:
cache = init(du, u, AbsSafeBestTerminationMode(); abstol = 1e-9, reltol = 1e-9)
If abstol
and reltol
are not supplied, then we choose a default based on the element types of du
and u
.
We can query the cache
using DiffEqBase.get_termination_mode
, DiffEqBase.get_abstol
and DiffEqBase.get_reltol
.
To test for termination simply call the cache
:
terminated = cache(du, u, uprev)
Absolute Tolerance
DiffEqBase.AbsTerminationMode
— TypeAbsTerminationMode <: AbstractNonlinearTerminationMode
Terminates if $all \left( | \frac{\partial u}{\partial t} | \leq abstol \right)$.
DiffEqBase.AbsNormTerminationMode
— TypeAbsNormTerminationMode <: AbstractNonlinearTerminationMode
Terminates if $\| \frac{\partial u}{\partial t} \| \leq abstol$.
DiffEqBase.AbsSafeTerminationMode
— TypeAbsSafeTerminationMode <: AbstractSafeNonlinearTerminationMode
Essentially AbsNormTerminationMode
+ terminate if there has been no improvement for the last patience_steps
+ terminate if the solution blows up (diverges).
Constructor
AbsSafeTerminationMode(; protective_threshold = nothing, patience_steps = 100,
patience_objective_multiplier = 3, min_max_factor = 1.3, max_stalled_steps = nothing)
DiffEqBase.AbsSafeBestTerminationMode
— TypeAbsSafeBestTerminationMode <: AbstractSafeBestNonlinearTerminationMode
Essentially AbsSafeTerminationMode
, but caches the best solution found so far.
Constructor
AbsSafeBestTerminationMode(; protective_threshold = nothing, patience_steps = 100,
patience_objective_multiplier = 3, min_max_factor = 1.3, max_stalled_steps = nothing)
Relative Tolerance
DiffEqBase.RelTerminationMode
— TypeRelTerminationMode <: AbstractNonlinearTerminationMode
Terminates if $all \left(| \frac{\partial u}{\partial t} | \leq reltol \times | u | \right)$.
DiffEqBase.RelNormTerminationMode
— TypeRelNormTerminationMode <: AbstractNonlinearTerminationMode
Terminates if $\| \frac{\partial u}{\partial t} \| \leq reltol \times \| \frac{\partial u}{\partial t} + u \|$
DiffEqBase.RelSafeTerminationMode
— TypeRelSafeTerminationMode <: AbstractSafeNonlinearTerminationMode
Essentially RelNormTerminationMode
+ terminate if there has been no improvement for the last patience_steps
+ terminate if the solution blows up (diverges).
Constructor
RelSafeTerminationMode(; protective_threshold = nothing, patience_steps = 100,
patience_objective_multiplier = 3, min_max_factor = 1.3, max_stalled_steps = nothing)
DiffEqBase.RelSafeBestTerminationMode
— TypeRelSafeBestTerminationMode <: AbstractSafeBestNonlinearTerminationMode
Essentially RelSafeTerminationMode
, but caches the best solution found so far.
Constructor
RelSafeBestTerminationMode(; protective_threshold = nothing, patience_steps = 100,
patience_objective_multiplier = 3, min_max_factor = 1.3, max_stalled_steps = nothing)
Both Absolute and Relative Tolerance
DiffEqBase.NormTerminationMode
— TypeNormTerminationMode <: AbstractNonlinearTerminationMode
Terminates if $\| \frac{\partial u}{\partial t} \| \leq reltol \times \| \frac{\partial u}{\partial t} + u \|$ or $\| \frac{\partial u}{\partial t} \| \leq abstol$
DiffEqBase.SteadyStateDiffEqTerminationMode
— TypeSteadyStateDiffEqTerminationMode <: AbstractNonlinearTerminationMode
Check if all values of the derivative is close to zero wrt both relative and absolute tolerance.
The default used in SteadyStateDiffEq.jl! Not recommended for large problems, since the convergence criteria is very strict and never reliably satisfied for most problems.
The following was named to match an older version of SimpleNonlinearSolve. It is currently not used as a default anywhere.
DiffEqBase.SimpleNonlinearSolveTerminationMode
— TypeSimpleNonlinearSolveTerminationMode <: AbstractNonlinearTerminationMode
Check if all values of the derivative is close to zero wrt both relative and absolute tolerance. Or check that the value of the current and previous state is within the specified tolerances.
The default used in SimpleNonlinearSolve.jl! Not recommended for large problems, since the convergence criteria is very strict and never reliably satisfied for most problems.
Return Codes (Deprecated)
These are deprecated and will be removed in a future release. Use the use_deprecated_retcodes = Val(false)
option to SciMLBase.init
to use the new return ReturnCode
versions.
DiffEqBase.NonlinearSafeTerminationReturnCode
— ModuleNonlinearSafeTerminationReturnCode
Return Codes for the safe nonlinear termination conditions.
These return codes have been deprecated. Termination Conditions will return SciMLBase.Retcode.T
starting from v7.
DiffEqBase.NonlinearSafeTerminationReturnCode.Success
— ConstantNonlinearSafeTerminationReturnCode.Success
Termination Condition was satisfied!
DiffEqBase.NonlinearSafeTerminationReturnCode.Default
— ConstantNonlinearSafeTerminationReturnCode.Default
Default Return Code. Used for type stability and conveys no additional information!
DiffEqBase.NonlinearSafeTerminationReturnCode.Failure
— ConstantNonlinearSafeTerminationReturnCode.Failure
Termination Condition was not satisfied!
DiffEqBase.NonlinearSafeTerminationReturnCode.PatienceTermination
— ConstantNonlinearSafeTerminationReturnCode.PatienceTermination
Terminate if there has been no improvement for the last patience_steps
.
DiffEqBase.NonlinearSafeTerminationReturnCode.ProtectiveTermination
— ConstantNonlinearSafeTerminationReturnCode.ProtectiveTermination
Terminate if the objective value increased by this factor wrt initial objective or the value diverged.