Discrete Problems

SciMLBase.DiscreteProblemType

Defines a discrete dynamical system problem. Documentation Page: https://docs.sciml.ai/DiffEqDocs/stable/types/discrete_types/

Mathematical Specification of a Discrete Problem

To define a Discrete Problem, you simply need to give the function $f$ and the initial condition $u_0$ which define a function map:

\[u_{n+1} = f(u_{n},p,t_{n+1})\]

f should be specified as f(un,p,t) (or in-place as f(unp1,un,p,t)), and u_0 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. $u_{n+1}$ only depends on the previous iteration $u_{n}$ and $t_{n+1}$. The default $t_{n+1}$ of FunctionMap is $t_n = t_0 + n*dt$ (with dt=1 being the default). For continuous-time Markov chains, this is the time at which the change is occurring.

Note that if the discrete solver is set to have scale_by_time=true, then the problem is interpreted as the map:

\[u_{n+1} = u_n + dt f(u_{n},p,t_{n+1})\]

Problem Type

Constructors

  • DiscreteProblem(f::ODEFunction,u0,tspan,p=NullParameters();kwargs...) : Defines the discrete problem with the specified functions.
  • DiscreteProblem{isinplace,specialize}(f,u0,tspan,p=NullParameters();kwargs...) : Defines the discrete problem with the specified functions.
  • DiscreteProblem{isinplace,specialize}(u0,tspan,p=NullParameters();kwargs...) : Defines the discrete problem with the identity map.

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 function in the map.
  • u0: The initial condition.
  • tspan: The timespan for the problem.
  • p: The parameters for the problem. Defaults to NullParameters
  • kwargs: The keyword arguments passed onto the solves.

Note About Timing

Note that if no dt and not tstops is given, it's assumed that dt=1 and thus tspan=(0,n) will solve for n iterations. If in the solver dt is given, then the number of iterations will change. And if tstops is not empty, the solver will revert to the standard behavior of fixed timestep methods, which is "step to each tstop".

source
SciMLBase.DiscreteFunctionType
DiscreteFunction{iip,F,Ta,S,S2,S3,O} <: AbstractDiscreteFunction{iip,specialize}

A representation of a discrete dynamical system f, defined by:

\[u_{n+1} = f(u,p,t_{n+1})\]

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

DiscreteFunction{iip,specialize}(f;
                                analytic = __has_analytic(f) ? f.analytic : nothing,
                                syms = __has_syms(f) ? f.syms : nothing
                                indepsym = __has_indepsym(f) ? f.indepsym : nothing,
                                paramsyms = __has_paramsyms(f) ? f.paramsyms : nothing)

Note that only the function f itself is required. This function should be given as f!(du,u,p,t) or du = f(u,p,t). 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:

  • 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.
  • 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.
  • paramsyms: the symbol names for the parameters of the equation. This should match p in size. For example, if p = [0.0, 1.0] and paramsyms = [:a, :b], this will apply a canonical naming to the values, allowing sol[:a] in the solution.

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 DiscreteFunction type directly match the names of the inputs.

source

Solution Type

DiscreteProblem solutions return an ODESolution. For more information, see the ODE problem definition page for the ODESolution docstring.