Skip to contents

DDEProblem(sys, op, tspan) builds a delay differential equation problem from a compiled system whose equations contain delayed unknowns EvalAt(t - tau)(x). The values of unknowns in op (or their defaults) form the history: they may be expressions of the independent variable, giving h(p, t) for t <= t0, and the initial state is h(p, t0). Constant lags are detected from the equations; constant_lags adds more. Lags that depend on the state or on time (as in EvalAt(t - 1 - x)(x)) become dependent lags lag(u, p, t), whose propagated discontinuities are located during the integration. DDEFunction(sys) builds f(u, h, p, t).

Usage

DDEFunction(sys, ...)

DDEProblem(
  sys,
  ...,
  constant_lags = NULL,
  dependent_lags = NULL,
  neutral = FALSE,
  order_discontinuity_t0 = 0L
)

SDDEProblem(
  sys,
  ...,
  constant_lags = NULL,
  dependent_lags = NULL,
  neutral = FALSE,
  order_discontinuity_t0 = 0L
)

Arguments

sys

A compiled System, or the function f.

...

For systems: op, tspan, then options stored with the problem. For functions: u0, h, tspan, p (SDDE: g, u0, h, tspan, p), then options.

constant_lags

Constant lags: discontinuities propagate from the initial time by these lags and become stopping times.

dependent_lags

A list of functions lag(u, p, t) of state dependent lags (the delayed time is t - lag(u, p, t)).

neutral

Whether the equation is neutral (delays in derivative terms): discontinuities then keep their order when they propagate.

order_discontinuity_t0

Order of the discontinuity at the initial time (0: the history and the solution need not even agree).

Value

A DDEProblem, SDDEProblem or DDEFunction.

Details

SDDEProblem(sys, op, tspan) does the same for systems with brownians.

Without a system, DDEProblem(f, u0, h, tspan, p) takes an R function f(u, h, p, t) and a history h(p, t) returning the state vector; SDDEProblem(f, g, u0, h, tspan, p) adds the diffusion g(u, h, p, t).

Solve with solve(prob, MethodOfSteps(Tsit5())) (the default), any ODE algorithm inside MethodOfSteps(), or MethodOfSteps(EM()) with dt for SDDEs.

Examples

t <- t_nounits; D <- D_nounits
variables("y(t)")
sys <- mtkcompile(System(list(D(y) ~ -EvalAt(t - 1)(y)), t, name = "dde"))
prob <- DDEProblem(sys, list(y ~ 1), c(0, 2))
sol <- solve(prob, MethodOfSteps(Tsit5()), reltol = 1e-8, abstol = 1e-10)
tail(sol[y], 1)
#> [1] -0.5