SDDE Problems

SciMLBase.SDDEProblemType

Defines a stochastic delay differential equation (SDDE) problem. Documentation Page: https://diffeq.sciml.ai/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 $f$, the diffusion function g, the initial condition $u_0$ at time point $t_0$, and the history function $h$ which together define a SDDE:

\[du = f(u,h,p,t)dt + g(u,h,p,t)dW_t \qquad (t \geq t_0)\]

\[u(t_0) = u_0,\]

\[u(t) = h(t) \qquad (t < t_0).\]

$f$ should be specified as f(u, h, p, t) (or in-place as f(du, u, h, p, t)) (and $g$ should match). $u_0$ should be an AbstractArray (or number) whose geometry matches the desired geometry of u, and $h$ 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 $u_0$; one is allowed to provide $u_0$ 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 the ith derivative
  • h(out, p, t, deriv::Type{Val{i}}): in-place calculation of the ith derivative
  • h(args...; idxs): calculation of h(args...) for indices idxs

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}(f,g[, u0], h, tspan[, p]; <keyword arguments>)

Parameter isinplace optionally sets whether the function is inplace or not. This is determined automatically, but not inferred.

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 value h(p, first(tspan)) of the history function evaluated at the initial time point.
  • h: The history function for the DDE before t0.
  • tspan: The timespan for the problem.
  • p: The parameters with which function f is called. Defaults to NullParameters.
  • constant_lags: A collection of constant lags used by the history function h. Defaults to ().
  • dependent_lags A tuple of functions (u, p, t) -> lag for the state-dependent lags used by the history function h. 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 to 0 if an initial condition u0 is provided. Otherwise it is forced to be greater or equal than 1.
  • kwargs: The keyword arguments passed onto the solves.
SciMLBase.SDDEFunctionType
SDDEFunction{iip,F,G,TMM,Ta,Tt,TJ,JVP,VJP,JP,SP,TW,TWt,TPJ,GG,S,O,TCV} <: AbstractSDDEFunction{iip}

A representation of a SDDE function f, defined by:

\[M du = f(u,h,p,t) dt + g(u,h,p,t) dW_t\]

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,recompile}(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,
                 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 histroy 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 matrix M represented in the ODE function. Can be used to determine that the equation is actually a differential-algebraic equation (DAE) if M is singular. Note that in this case special solvers are required, see the DAE solver page for more details: https://diffeq.sciml.ai/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 $\frac{\partial f(u,p,t)}{\partial t}$
  • jac(J,u,h,p,t) or J=jac(u,p,t): returns $\frac{df}{du}$
  • jvp(Jv,v,h,u,p,t) or Jv=jvp(v,u,p,t): returns the directional derivative$\frac{df}{du} v$
  • vjp(Jv,v,h,u,p,t) or Jv=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 sized Tridiagonal matrix can be used as the prototype and integrators will specialize on this structure where possible. Non-structured sparsity patterns should use a SparseMatrixCSC with a correct sparsity pattern for the Jacobian. The default is nothing, which means a dense Jacobian.
  • paramjac(pJ,h,u,p,t): returns the parameter Jacobian $\frac{df}{dp}$.
  • syms: the symbol names for the elements of the equation. This should match u0 in size. For example, if u0 = [0.0,1.0] and syms = [:x, :y], this will apply a canonical naming to the values, allowing sol[:x] in the solution and automatically naming values in plots.
  • indepsym: the canonical naming for the independent variable. Defaults to nothing, which internally uses t as the representation in any plots.
  • colorvec: a color vector according to the SparseDiffTools.jl definition for the sparsity pattern of the jac_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 to nothing, 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.

recompile: 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.