Library
PiecewiseDeterministicMarkovProcesses.PDMPProblem — TypePDMPProblem(F, R, Delta, nu, xc0, xd0, p, tspan)Create a PDMP problem to be simulated. To define a PDMP Problem, you first need to give the function F and the initial condition xc0 which define an ODE: dxc/dt = F(xc(t),xd(t),p,t). Jumps are defined as a Jump process which changes states at some rate R. Note, that in between jumps, xd is constant but xc is allowed to evolve.
Arguments
F: inplace functionF(du, u, p, t)representing the vector fieldR: the function to compute the transition rates. It should be specified in-place asR(rate::AbstractVector, xc, xd, p, t, issum::Bool)where it mutatesrate. Note that a booleanissumis provided and the behavior ofRshould be as follows- if
issum == true, we only requireRto return the total rate, e.g.sum(rate). We use this formalism because sometimes you can compute thesumwithout mutatingrate. - if
issum == false,Rmust populateratewith the updated rates
- if
We then need to provide the way the jumps affect the state variable. There are two possible ways here: 1. either give a transition matrix nu: it will only affect the discrete component xd and leave xc unaffected. 2. give a function to implement jumps Delta(xc, xd, parms, t, ind_reaction::Int64) where you can mutate xc,xd or parms. The argument ind_reaction is the index of the reaction at which the jump occurs. See examples/pdmp_example_eva.jl for an example.
Delta[Optional]: the function to effect the jumpsnu[Optional]: the transition matrixxc0: the initial condition of the continuous partxd0: the initial condition of the discrete partp: the parameters to be provided to the functionsF, R, Deltatspan: The timespan for the problem.
Constructors
PDMPProblem(F,R,Delta,nu,xc0,xd0,p,tspan)PDMPProblem(F,R,nu,xc0,xd0,p,tspan)when ones does not want to provide the functionDeltaPDMPProblem(F,R,Delta,reaction_number::Int64,xc0,xd0,p,tspan)when ones does not want to provide the transition matrixnu. The lengthreaction_numberof the rate vector must then be provided.
We also provide a wrapper to JumpProcesses.jl. This is quite similar to how a JumpProblem would be created.
PDMPProblem(prob, jumps...)whereprobcan be anODEProblem. For an example, please considerexample/examplediffeqjumpwrapper.jl.
Solvers
CommonSolve.solve — Functionsolve(problem::PDMPProblem, algo; verbose = false, n_jumps = Inf64, save_positions = (false, true), reltol = 1e-7, abstol = 1e-9, save_rate = false, finalizer = finalize_dummy, kwargs...)Simulate the PDMP problem using the CHV algorithm.
Arguments
problem::PDMPProblemalgcan beCHV(ode)(for the CHV algorithm),Rejection(ode)for the Rejection algorithm andRejectionExact()for the rejection algorithm in case the flow in between jumps is known analytically. In this latter case,prob.Fis used for the specification of the Flow. The ODE solverodecan be any solver of DifferentialEquations.jl likeTsit5()for example or anyone of the list[:cvode, :lsoda, :adams, :BDF, :euler]. Indeed, the package implement an iterator interface which does not work yet withode = LSODA(). In order to have access to the ODE solverLSODA(), one should useode = :lsoda.verbosedisplay information during simulationn_jumpsmaximum number of jumps to be computedsave_positionswhich jump position to record, pre-jump (savepositions[1] = true) and/or post-jump (savepositions[2] = true).reltol: relative tolerance used in the ODE solverabstol: absolute tolerance used in the ODE solverind_save_c: which indices ofxcshould be savedind_save_d: which indices ofxdshould be savedsave_rate = true: requires the solver to save the total rate. Can be useful when estimating the rate bounds in order to use the Rejection algorithm as a second try.X_extended = zeros(Tc, 1 + 1): (advanced use) options used to provide the shape of the extended array in the CHV algorithm. Can be useful in order to useStaticArrays.jlfor example.finalizer = finalize_dummy: allows the user to pass a functionfinalizer(rate, xc, xd, p, t)which is called after each jump. Can be used to overload / add saving / plotting mechanisms.kwargskeyword arguments passed to the ODE solver (from DifferentialEquations.jl)
Same as the solve for CHV(::DiffEqBase.DEAlgorithm) but for CHV(::Symbol). This is an old implementation of the CHV algorithm which can be used with :lsoda. For all other solvers, use the the new solver.