Skip to contents

Jumps of a jump process, as in JumpProcesses.jl, for use in a System() (jumps = list(...)) or JumpSystem(). ConstantRateJump(rate, affect) has a rate that changes only when a jump fires; VariableRateJump(rate, affect) a rate that may depend on time or on unknowns that change continuously. affect is a list of equations giving the new values, such as list(S ~ Pre(S) - 1, I ~ Pre(I) + 1); inside it, Pre(x) (or plain x) is the value just before the jump.

Usage

ConstantRateJump(rate, affect, bounds = NULL)

VariableRateJump(
  rate,
  affect,
  lrate = NULL,
  urate = NULL,
  rateinterval = NULL,
  rootfind = TRUE,
  save_positions = c(FALSE, TRUE),
  interp_points = 10L,
  abstol = 1e-12,
  reltol = 0
)

MassActionJump(rate, reactant_stoch, net_stoch, scale_rates = TRUE)

SymbolicMassActionJump(rate, reactant_stoch, net_stoch, scale_rates = FALSE)

Arguments

rate

The rate: a symbolic expression, or for problems without a system an R function rate(u, p, t).

affect

A list of equations, or an R function affect(integ) changing integ$u.

bounds

For RSSA() and RSSACR() with problems without a system: a function bounds(ulow, uhigh, u, p, t) returning c(lrate, urate), bounds of the rate while each population stays in [ulow, uhigh]. By default the rate is evaluated at ulow and uhigh, which assumes it is monotone in the state.

lrate, urate, rateinterval

Rate bounds of a bounded variable rate jump (R functions of (u, p, t)): for s in [t, t + rateinterval(u, p, t)] the rate lies in [lrate(u, p, t), urate(u, p, t)]. Coevolve() simulates bounded jumps of problems without a system by thinning, also in pure jump problems. ModelingToolkit drops these bounds for symbolic jumps, and so does JumpProblem() for systems.

rootfind, interp_points, abstol, reltol

Options of the continuous callback that fires a variable rate jump coupled to an ODE or SDE; rootfind = TRUE locates the firing time (LeftRootFind). The root finder of the R driver has its own sampling and tolerances, so interp_points, abstol and reltol are kept for compatibility only.

save_positions

Save before and after the jump (a variable rate jump coupled to an ODE or SDE); the JumpProcesses default saves after it.

reactant_stoch, net_stoch

Reactant and net stoichiometries.

scale_rates

Divide the rate by the factorials of the reactant stoichiometries.

Value

A jump object.

Details

MassActionJump(rate, reactant_stoch, net_stoch) is a mass action reaction with propensity rate * prod(X * (X - 1) * ... ) over the reactants; stoichiometries are lists of formulas list(S ~ 1, I ~ 1) (or pairs, or named numeric vectors). As in ModelingToolkit the rate must be pre-scaled (k / factorial(n) for n X -> ...): SymbolicMassActionJump() and scale_rates = FALSE do this, while the JumpProcesses default scale_rates = TRUE is rejected by systems.

Examples

t <- t_nounits
variables("S(t)", "I(t)", "R(t)"); parameters("beta", "gamma")
j1 <- ConstantRateJump(beta * S * I, list(S ~ Pre(S) - 1, I ~ Pre(I) + 1))
j2 <- SymbolicMassActionJump(gamma, list(I ~ 1), list(I ~ -1, R ~ 1))
js <- JumpSystem(list(j1, j2), t, list(S, I, R), list(beta, gamma), name = "sir")
unknowns(js)
#> [[1]]
#> S(t)
#> 
#> [[2]]
#> I(t)
#> 
#> [[3]]
#> R(t)
#>