Skip to contents

SplitCoupledJumpProblem(prob, prob_control, aggregator, coupling_map) simulates two jump problems with common random numbers, the split coupling of Anderson and Higham: each pair c(i, j) of coupling_map couples jump i of prob with jump j of prob_control (they fire together at the minimum of their rates), the other jumps fire alone. The state is c(u, u_control). Both problems are built from R functions with ConstantRateJump()s; their inner problems are discrete, ODE or SDE problems.

Usage

SplitCoupledJumpProblem(prob, prob_control, aggregator, coupling_map, ...)

JumpSet(...)

RateBounds(lrate = NULL, urate = NULL, rateinterval = Inf)

JumpDependencies(
  dep_graph = NULL,
  vartojumps_map = NULL,
  jumptovars_map = NULL
)

get_num_majumps(jumps)

needs_depgraph(agg)

needs_vartojumps_map(agg)

isolated_copy(jprob)

Arguments

prob, prob_control

Jump problems.

aggregator

A jump aggregator.

coupling_map

List of index pairs c(i, j).

...

Jumps, or for SplitCoupledJumpProblem() options of JumpProblem().

lrate, urate

Lower and upper rate bounds.

rateinterval

Time over which the bounds hold.

dep_graph, vartojumps_map, jumptovars_map

Dependency maps.

jumps

Mass action jumps.

agg

An aggregator.

jprob

A jump problem.

Value

A jump problem, a jump set, bounds, maps, a count or a flag.

Details

JumpSet(...) groups jumps; JumpProblem() takes it like a list. RateBounds(lrate, urate, rateinterval) is a bound of a rate over an interval of states or time (the return value of the bounds function of a ConstantRateJump() for RSSA()). JumpDependencies() holds the dependency maps passed to JumpProblem(dependencies = ). get_num_majumps() counts mass action reactions; needs_depgraph() and needs_vartojumps_map() tell which maps an aggregator uses. isolated_copy(jprob) returns a problem whose solves share no state with jprob; R problems are values, so this is jprob itself.

Examples

birth <- ConstantRateJump(function(u, p, t) 10, function(integ) integ$u[1] <- integ$u[1] + 1)
death <- ConstantRateJump(function(u, p, t) u[1], function(integ) integ$u[1] <- integ$u[1] - 1)
death2 <- ConstantRateJump(function(u, p, t) 1.1 * u[1],
  function(integ) integ$u[1] <- integ$u[1] - 1)
j1 <- JumpProblem(DiscreteProblem(0, c(0, 5)), Direct(), birth, death)
j2 <- JumpProblem(DiscreteProblem(0, c(0, 5)), Direct(), birth, death2)
cp <- SplitCoupledJumpProblem(j1, j2, Direct(), list(c(1, 1), c(2, 2)))
tail(solve(cp, SSAStepper(), seed = 1)$u, 1)
#> [[1]]
#> [1] 13 12
#>