| ssa.otl {GillespieSSA} | R Documentation |
Optimized tau-leap method implementation of the SSA as described by Cao et al. (2006). It is usually called from within ssa, but can be invoked directly.
ssa.otl(x = stop("missing state vector (x)"),
a = stop("missing propensity vector (a)"),
nu = stop("missing state-change matrix (nu)"),
hor = stop("missing highest order reaction vector (hot)"),
nc = stop("missing critical reactions threshold parameter (nc)"),
epsilon = stop("missing error control parameter"),
dtf = stop("missing direct method threshold factor (dtf)"),
nd = stop("missing OTL suspension duration parameter (nd)"))
x |
state vector. |
a |
vector of evaluated propensity functions. |
nu |
state-change matrix. |
hor |
highest order reaction vector (one entry per species in x) |
nc |
number of critical reactions threshold parameter. |
epsilon |
error control parameter. |
dtf |
Direct method threshold factor for temporarily suspending the OTL method. |
nd |
number of Direct method steps to perform during an OTL suspension. |
Performs one time step using the Explicit tau-leap method. Intended to be invoked by ssa.
A list with three elements, 1) the time leap (tau) and 2) the realized state change vector (nu_j), and 3) a boolean value (suspendedTauLeapMethod) indicating if the simulation should revert to the Direct method for nd time steps.
Third order-reactions (S_1 + S_2 + S_3 —> ...) are not supported currently since they are approximations to sets of coupled first- and second-order reactions). See Cao et al. (2006) for more details.
Cao et al. (2006)
a = function(parms,x){
b <- parms[1]
d <- parms[2]
K <- parms[3]
N <- x[1]
return(c(b*N , N*b + (b-d)*N/K))
}
parms <- c(2,1,1000,500)
x <- 500
nu <- matrix(c(+1, -1),ncol=2)
t <- 0
for (i in seq(100)) {
out <- ssa.otl(x,a(parms,x),nu,hor=1,nc=10,epsilon=0.03,dtf=10,nd=100)
x <- x + out$nu_j
t <- t + 1
cat("t:",t,", x:",x,"\n")
}