RODE Problems
SciMLBase.RODEProblem
— TypeDefines a random ordinary differential equation (RODE) problem. Documentation Page: https://docs.sciml.ai/DiffEqDocs/stable/types/rode_types/
Mathematical Specification of a RODE Problem
To define a RODE Problem, you simply need to give the function $f$ and the initial condition $u_0$ which define an ODE:
\[\frac{du}{dt} = f(u,p,t,W(t))\]
where W(t)
is a random process. f
should be specified as f(u,p,t,W)
(or in-place as f(du,u,p,t,W)
), and u₀
should be an AbstractArray (or number) whose geometry matches the desired geometry of u
. Note that we are not limited to numbers or vectors for u₀
; one is allowed to provide u₀
as arbitrary matrices / higher dimension tensors as well.
Constructors
RODEProblem(f::RODEFunction,u0,tspan,p=NullParameters();noise=WHITE_NOISE,rand_prototype=nothing,callback=nothing)
RODEProblem{isinplace,specialize}(f,u0,tspan,p=NullParameters();noise=WHITE_NOISE,rand_prototype=nothing,callback=nothing,mass_matrix=I)
: Defines the RODE with the specified functions. The default noise isWHITE_NOISE
.isinplace
optionally sets whether the function is inplace or not. This is determined automatically, but not inferred.specialize
optionally controls the specialization level. See the specialization levels section of the SciMLBase documentation for more details. The default is `AutoSpecialize.
For more details on the in-place and specialization controls, see the ODEFunction documentation.
Parameters are optional, and if not given, then a NullParameters()
singleton will be used which will throw nice errors if you try to index non-existent parameters. Any extra keyword arguments are passed on to the solvers. For example, if you set a callback
in the problem, then that callback
will be added in every solve call.
For specifying Jacobians and mass matrices, see the DiffEqFunctions page.
Fields
f
: The drift function in the SDE.u0
: The initial condition.tspan
: The timespan for the problem.p
: The optional parameters for the problem. Defaults toNullParameters
.noise
: The noise process applied to the noise upon generation. Defaults to Gaussian white noise. For information on defining different noise processes, see the noise process documentation pagerand_prototype
: A prototype type instance for the noise vector. It defaults tonothing
, which means the problem should be interpreted as having a noise vector whose size matchesu0
.kwargs
: The keyword arguments passed onto the solves.
SciMLBase.RODEFunction
— TypeDocStringExtensions.TypeDefinition()
A representation of a RODE function f
, defined by:
\[M \frac{du}{dt} = f(u,p,t,W)dt\]
and all of its related functions, such as the Jacobian of f
, its gradient with respect to time, and more. For all cases, u0
is the initial condition, p
are the parameters, and t
is the independent variable.
Constructor
RODEFunction{iip,specialize}(f;
mass_matrix = __has_mass_matrix(f) ? f.mass_matrix : I,
analytic = __has_analytic(f) ? f.analytic : nothing,
tgrad= __has_tgrad(f) ? f.tgrad : nothing,
jac = __has_jac(f) ? f.jac : nothing,
jvp = __has_jvp(f) ? f.jvp : nothing,
vjp = __has_vjp(f) ? f.vjp : nothing,
jac_prototype = __has_jac_prototype(f) ? f.jac_prototype : nothing,
sparsity = __has_sparsity(f) ? f.sparsity : jac_prototype,
paramjac = __has_paramjac(f) ? f.paramjac : nothing,
colorvec = __has_colorvec(f) ? f.colorvec : nothing,
sys = __has_sys(f) ? f.sys : nothing,
analytic_full = __has_analytic_full(f) ? f.analytic_full : false)
Note that only the function f
itself is required. This function should be given as f!(du,u,p,t,W)
or du = f(u,p,t,W)
. See the section on iip
for more details on in-place vs out-of-place handling.
All of the remaining functions are optional for improving or accelerating the usage of f
. These include:
mass_matrix
: the mass matrixM
represented in the RODE function. Can be used to determine that the equation is actually a random differential-algebraic equation (RDAE) ifM
is singular.analytic
: (u0,p,t,W)or
analytic(sol): used to pass an analytical solution function for the analytical solution of the RODE. Generally only used for testing and development of the solvers. The exact form depends on the field
analytic_full`.analytic_full
: a boolean to indicate whether to use the formanalytic(u0,p,t,W)
(iffalse
) or the formanalytic!(sol)
(iftrue
). The former is expected to return the solutionu(t)
of the equation, given the initial conditionu0
, the parameterp
, the current timet
and the valueW=W(t)
of the noise at the given timet
. The latter case is useful when the solution of the RODE depends on the whole history of the noise, which is available insol.W.W
, at timessol.W.t
. In this case,analytic(sol)
must mutate explicitly the fieldsol.u_analytic
with the corresponding expected solution atsol.W.t
orsol.t
.tgrad(dT,u,p,t,W)
or dT=tgrad(u,p,t,W): returns $\frac{\partial f(u,p,t,W)}{\partial t}$jac(J,u,p,t,W)
orJ=jac(u,p,t,W)
: returns $\frac{df}{du}$jvp(Jv,v,u,p,t,W)
orJv=jvp(v,u,p,t,W)
: returns the directional derivative $\frac{df}{du} v$vjp(Jv,v,u,p,t,W)
orJv=vjp(v,u,p,t,W)
: returns the adjoint derivative $\frac{df}{du}^\ast v$jac_prototype
: a prototype matrix matching the type that matches the Jacobian. For example, if the Jacobian is tridiagonal, then an appropriately sizedTridiagonal
matrix can be used as the prototype and integrators will specialize on this structure where possible. Non-structured sparsity patterns should use aSparseMatrixCSC
with a correct sparsity pattern for the Jacobian. The default isnothing
, which means a dense Jacobian.paramjac(pJ,u,p,t,W)
: returns the parameter Jacobian $\frac{df}{dp}$.colorvec
: a color vector according to the SparseDiffTools.jl definition for the sparsity pattern of thejac_prototype
. This specializes the Jacobian construction when using finite differences and automatic differentiation to be computed in an accelerated manner based on the sparsity pattern. Defaults tonothing
, which means a color vector will be internally computed on demand when required. The cost of this operation is highly dependent on the sparsity pattern.
iip: In-Place vs Out-Of-Place
For more details on this argument, see the ODEFunction documentation.
specialize: Controlling Compilation and Specialization
For more details on this argument, see the ODEFunction documentation.
Fields
The fields of the RODEFunction type directly match the names of the inputs.
Solution Type
SciMLBase.RODESolution
— Typestruct RODESolution{T, N, uType, uType2, DType, tType, randType, discType, P, A, IType, S, AC<:Union{Nothing, Vector{Int64}}, V} <: SciMLBase.AbstractRODESolution{T, N, uType}
Representation of the solution to an stochastic differential equation defined by an SDEProblem, or of a random ordinary differential equation defined by an RODEProblem.
DESolution Interface
For more information on interacting with DESolution
types, check out the Solution Handling page of the DifferentialEquations.jl documentation.
https://docs.sciml.ai/DiffEqDocs/stable/basics/solution/
Fields
u
: the representation of the SDE or RODE solution. Given as an array of solutions, whereu[i]
corresponds to the solution at timet[i]
. It is recommended in most cases one does not accesssol.u
directly and instead use the array interface described in the Solution Handling page of the DifferentialEquations.jl documentation.t
: the time points corresponding to the saved values of the ODE solution.W
: the representation of the saved noise process from the solution. See the Noise Processes page of the DifferentialEquations.jl. Note that this noise is only saved in full ifsave_noise=true
in the solver.prob
: the original SDEProblem/RODEProblem that was solved.alg
: the algorithm type used by the solver.stats
: statistics of the solver, such as the number of function evaluations required, number of Jacobians computed, and more.retcode
: the return code from the solver. Used to determine whether the solver solved successfully, whether it terminated early due to a user-defined callback, or whether it exited due to an error. For more details, see the return code documentation.
Alias Specifier
SciMLBase.RODEAliasSpecifier
— TypeHolds information on what variables to alias when solving an RODEProblem. Conforms to the AbstractAliasSpecifier interface. RODEAliasSpecifier(;alias_p = nothing, alias_f = nothing, alias_u0 = false, alias_du0 = false, alias_tstops = false, alias = nothing)
When a keyword argument is nothing
, the default behaviour of the solver is used.
Keywords
alias_p::Union{Bool, Nothing}
alias_f::Union{Bool, Nothing}
alias_u0::Union{Bool, Nothing}
: alias the u0 array. Defaults to false .alias_du0::Union{Bool, Nothing}
: alias the du0 array for DAEs. Defaults to false.alias_tstops::Union{Bool, Nothing}
: alias the tstops arrayalias_noise::Union{Bool,Nothing}
: alias the noise processalias_jumps::Union{Bool, Nothing}
: alias jump process if wrapped in a JumpProcessalias::Union{Bool, Nothing}
: sets all fields of theRODEAliasSpecifier
toalias