JumpProblem(sys, op, tspan) builds a jump problem from a complete system
with jumps. Without equations and variable rate jumps the inner problem
jprob$prob is a DiscreteProblem, simulated exactly by SSAStepper();
otherwise it is an ODEProblem (or an SDEProblem for systems with
noise). As in JumpProcesses, the mass action and constant rate jumps are
handled by the aggregator (see jump_aggregators; NullAggregator()
chooses one), which stops the ODE or SDE solver at each of their jump
times, and every variable rate jump fires when its integrated rate crosses
an exponential threshold. Events of the system reset the aggregator after
their affects.
Usage
JumpProblem(
sys,
...,
aggregator = NullAggregator(),
save_positions = NULL,
dependencies = NULL,
use_vrj_bounds = TRUE,
hopping_constants = NULL,
spatial_system = NULL,
vr_aggregator = VR_FRM()
)
# S3 method for class 'JumpProblem'
solve(a, b = NULL, ...)Arguments
- sys
A complete
Systemwith jumps, or a problem.- ...
For systems:
opandtspan, then options stored with the problem (andbracket_data, seeBracketData()). For problems: the aggregator and the jumps.- aggregator
A jump aggregator.
- save_positions
Save the state before and after each jump of the aggregator; by default both for systems and coupled problems, and after the jump for
DiscreteProblems.- dependencies
For problems without a system: a list with the dependency graph
dep_graph,vartojumps_mapandjumptovars_map(lists of integer vectors) when the aggregator needs them.- use_vrj_bounds
Let an aggregator that supports them (
Coevolve()) handle bounded variable rate jumps.- hopping_constants, spatial_system
For spatial problems with
NSM()orDirectCRDirect(), see spatial_jumps.- vr_aggregator
How general variable rate jumps are simulated, see variable_rate_aggregators.
- a
A
JumpProblem.- b
A solver:
SSAStepper()for pure jump problems, an ODE or SDE algorithm otherwise.
Details
JumpProblem(prob, aggregator, jump1, jump2, ...) couples jumps with R
function rates and affects to an existing problem (prob a
DiscreteProblem for pure jump processes).
solve(jprob) uses SSAStepper() for pure jump problems, Tsit5() for
jumps coupled to ODEs and SOSRI() for jumps coupled to SDEs. Options are
those of the underlying solver, plus seed. SSAStepper() takes
saveat, save_start, save_end, tstops and discrete callbacks
(checked after every jump and at every stop), and saves the state after a
jump when any of save_positions is TRUE. For jumps coupled to ODEs
and SDEs, save_positions controls the saves around each jump as for
callbacks in DiffEqBase, also when saveat is given.
Examples
t <- t_nounits
variables("X(t)"); parameters("lam = 10", "mu = 1")
birth <- SymbolicMassActionJump(lam, list(), list(X ~ 1))
death <- SymbolicMassActionJump(mu, list(X ~ 1), list(X ~ -1))
js <- complete(JumpSystem(list(birth, death), t, list(X), list(lam, mu), name = "bd"))
jprob <- JumpProblem(js, list(X ~ 0), c(0, 5), aggregator = RSSA())
sol <- solve(jprob, SSAStepper(), seed = 1)
tail(sol[X], 1)
#> [1] 7