SDDE Problems
#
SciMLBase.SDDEProblem
— Type
Defines a stochastic delay differential equation (SDDE) problem. Documentation Page: https://docs.sciml.ai/DiffEqDocs/stable/types/sdde_types/
Mathematical Specification of a Stochastic Delay Differential Equation (SDDE) Problem
To define a SDDE Problem, you simply need to give the drift function , the diffusion function g
, the initial condition at time point , and the history function which together define a SDDE:
should be specified as f(u, h, p, t)
(or in-place as f(du, u, h, p, t)
) (and should match). should be an AbstractArray (or number) whose geometry matches the desired geometry of u
, and should be specified as described below. The history function h
is accessed for all delayed values. Note that we are not limited to numbers or vectors for ; one is allowed to provide as arbitrary matrices / higher dimension tensors as well.
Note that this functionality should be considered experimental.
Functional Forms of the History Function
The history function h
can be called in the following ways:
-
h(p, t)
: out-of-place calculation -
h(out, p, t)
: in-place calculation -
h(p, t, deriv::Type{Val{i}})
: out-of-place calculation of thei
th derivative -
h(out, p, t, deriv::Type{Val{i}})
: in-place calculation of thei
th derivative -
h(args...; idxs)
: calculation ofh(args...)
for indicesidxs
Note that a dispatch for the supplied history function of matching form is required for whichever function forms are used in the user derivative function f
.
Declaring Lags
Lags are declared separately from their use. One can use any lag by simply using the interpolant of h
at that point. However, one should use caution in order to achieve the best accuracy. When lags are declared, the solvers can more efficiently be more accurate and thus this is recommended.
Neutral, Retarded, and Algebraic Stochastic Delay Differential Equations
Note that the history function specification can be used to specify general retarded arguments, i.e. h(p,α(u,t))
. Neutral delay differential equations can be specified by using the deriv
value in the history interpolation. For example, h(p,t-τ, Val{1})
returns the first derivative of the history values at time t-τ
.
Note that algebraic equations can be specified by using a singular mass matrix.
Problem Type
Constructors
SDDEProblem(f,g[, u0], h, tspan[, p]; <keyword arguments>) SDDEProblem{isinplace,specialize}(f,g[, u0], h, tspan[, p]; <keyword arguments>)
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.
Arguments
-
f
: The drift function in the SDDE. -
g
: The diffusion function in the SDDE. -
u0
: The initial condition. Defaults to the valueh(p, first(tspan))
of the history function evaluated at the initial time point. -
h
: The history function for the DDE beforet0
. -
tspan
: The timespan for the problem. -
p
: The parameters with which functionf
is called. Defaults toNullParameters
. -
constant_lags
: A collection of constant lags used by the history functionh
. Defaults to()
. -
dependent_lags
A tuple of functions(u, p, t) -> lag
for the state-dependent lags used by the history functionh
. Defaults to()
. -
neutral
: If the DDE is neutral, i.e., if delays appear in derivative terms. -
order_discontinuity_t0
: The order of the discontinuity at the initial time point. Defaults to0
if an initial conditionu0
is provided. Otherwise, it is forced to be greater or equal than1
. -
kwargs
: The keyword arguments passed onto the solves.
#
SciMLBase.SDDEFunction
— Type
SDDEFunction{iip,F,G,TMM,Ta,Tt,TJ,JVP,VJP,JP,SP,TW,TWt,TPJ,GG,S,S2,S3,O,TCV} <: AbstractSDDEFunction{iip,specialize}
A representation of a SDDE function f
, defined by:
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
SDDEFunction{iip,specialize}(f,g;
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,
syms = __has_syms(f) ? f.syms : nothing,
indepsym= __has_indepsym(f) ? f.indepsym : nothing,
paramsyms = __has_paramsyms(f) ? f.paramsyms : nothing,
colorvec = __has_colorvec(f) ? f.colorvec : nothing
sys = __has_sys(f) ? f.sys : nothing)
Note that only the function f
itself is required. This function should be given as f!(du,u,h,p,t)
or du = f(u,h,p,t)
. See the section on iip
for more details on in-place vs out-of-place handling. The history function h
acts as an interpolator over time, i.e. h(t)
with options matching the solution interface, i.e. h(t; save_idxs = 2)
.
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 ODE function. Can be used to determine that the equation is actually a differential-algebraic equation (DAE) ifM
is singular. Note that in this case special solvers are required, see the DAE solver page for more details: https://docs.sciml.ai/DiffEqDocs/stable/solvers/dae_solve/. Must be an AbstractArray or an AbstractSciMLOperator. -
analytic(u0,p,t)
: used to pass an analytical solution function for the analytical solution of the ODE. Generally only used for testing and development of the solvers. -
tgrad(dT,u,h,p,t)
or dT=tgrad(u,p,t): returns -
jac(J,u,h,p,t)
orJ=jac(u,p,t)
: returns -
jvp(Jv,v,h,u,p,t)
orJv=jvp(v,u,p,t)
: returns the directional derivative$\frac{df}{du} v$ -
vjp(Jv,v,h,u,p,t)
orJv=vjp(v,u,p,t)
: 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,h,u,p,t)
: returns the parameter Jacobian . -
syms
: the symbol names for the elements of the equation. This should matchu0
in size. For example, ifu0 = [0.0,1.0]
andsyms = [:x, :y]
, this will apply a canonical naming to the values, allowingsol[:x]
in the solution and automatically naming values in plots. -
indepsym
: the canonical naming for the independent variable. Defaults to nothing, which internally usest
as the representation in any plots. -
paramsyms
: the symbol names for the parameters of the equation. This should matchp
in size. For example, ifp = [0.0, 1.0]
andparamsyms = [:a, :b]
, this will apply a canonical naming to the values, allowingsol[:a]
in the solution. -
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 DDEFunction type directly match the names of the inputs.
Solution Type
SDDEProblem
solutions return an RODESolution
. For more information, see the RODE problem definition page for the RODESolution
docstring.