Skip to contents

RegularJump(rate, c, numjumps) encodes numjumps jump processes for tau leaping, as in JumpProcesses.jl: rate(u, p, t) returns the vector of their rates and c(u, p, t, counts, mark) returns the change of the state when jump i fires counts[i] times. JumpProblem(prob, PureLeaping(), jumps), with prob a DiscreteProblem() and jumps a RegularJump or mass action jumps, builds a pure leaping problem.

Usage

RegularJump(rate, c, numjumps, mark_dist = NULL)

PureLeaping()

SimpleTauLeaping()

SimpleExplicitTauLeaping(epsilon = 0.05)

SimpleImplicitTauLeaping(epsilon = 0.05)

SimpleTrapezoidalLeaping(epsilon = 0.05)

SimpleAdaptiveTauLeaping(
  epsilon = 0.05,
  implicit_alg = SimpleImplicitTauLeaping(),
  eigenvalue_check = FALSE,
  stiffness_ratio_threshold = 10000,
  implicit_epsilon_factor = 10
)

TauLeaping()

CaoTauLeaping(epsilon = 0.03)

ImplicitTauLeaping()

ThetaTrapezoidalTauLeaping(theta = 0.5)

Arguments

rate

Function (u, p, t) returning the rates of all jumps.

c

Function (u, p, t, counts, mark) returning the state change.

numjumps

Number of jumps.

mark_dist

Not supported (as in JumpProcesses).

epsilon

Error control parameter of the step size selection.

implicit_alg

Algorithm of the implicit steps of SimpleAdaptiveTauLeaping().

eigenvalue_check

Judge stiffness from the eigenvalues of the drift Jacobian instead of the spread of the rates.

stiffness_ratio_threshold

Eigenvalue ratio above which the system counts as stiff.

implicit_epsilon_factor

Factor relaxing epsilon on implicit steps.

theta

Implicitness of ThetaTrapezoidalTauLeaping().

Value

A RegularJump, an aggregator or an algorithm object.

Details

Solvers:

  • SimpleTauLeaping(): fixed step tau leaping for a RegularJump; solve() needs dt.

  • SimpleExplicitTauLeaping(epsilon): adaptive explicit tau leaping for mass action jumps (or a RegularJump together with mass action jumps giving the stoichiometry), with the step size of Cao, Gillespie and Petzold (2006); a step that would make a population negative is halved.

  • SimpleImplicitTauLeaping(epsilon) and SimpleTrapezoidalLeaping(epsilon): the implicit (Rathinam et al. 2003) and trapezoidal tau leaping methods for stiff mass action systems.

  • SimpleAdaptiveTauLeaping(): switches between the explicit step and implicit_alg according to a stiffness test (Cao et al. 2007).

The tau leaping methods of StochasticDiffEq.jl take a RegularJump:

  • TauLeaping(): adaptive tau leaping; a step is accepted when the rates change by less than 50 reltol relative to their value (StochasticDiffEq's error estimate), otherwise it is retried with a shorter step whose counts are a binomial thinning of the rejected ones (the Poisson bridge).

  • CaoTauLeaping(): each step size is chosen a posteriori by the formula of Cao, Gillespie and Petzold (2006), with the net changes of the jumps read from c; steps are never rejected.

  • ImplicitTauLeaping() and ThetaTrapezoidalTauLeaping(theta): the implicit and theta trapezoidal methods (Rathinam et al. 2003; Hu, Li and Min 2011) with step dt: X1 = X0 + nu k + theta dt (drift(X1) - drift(X0)), drift(u) = c(u, p, t, rate(u, p, t), NULL).

solve() takes saveat, save_start, save_end, dtmin (default 1e-10), seed, and for the StochasticDiffEq methods dt, adaptive, reltol (default 1e-2), dtmax and gamma (default 0.9). Solutions are piecewise constant.

Examples

rj <- RegularJump(function(u, p, t) 0.1 * u[1],
                  function(u, p, t, counts, mark) -counts[1], 1)
jprob <- JumpProblem(DiscreteProblem(20, c(0, 2)), PureLeaping(), rj)
sol <- solve(jprob, SimpleTauLeaping(), dt = 0.1, seed = 1)
tail(sol$u, 1)
#> [[1]]
#> [1] 15
#> 
maj <- MassActionJump(c(1, 1), list(list(c(1, 1)), list(c(2, 1))),
                      list(list(c(1, -1), c(2, 1)), list(c(1, 1), c(2, -1))))
jp2 <- JumpProblem(DiscreteProblem(c(100, 100), c(0, 10)), PureLeaping(), maj)
tail(solve(jp2, SimpleImplicitTauLeaping(), seed = 1)$u, 1)
#> [[1]]
#> [1] 101  99
#>