The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
This version of the Lotka predator-prey model is given by
dY1/dt = c1*Y1 - c2*Y1*Y2
dY2/dt = c2*Y1*Y2 - c3*Y2
consisting of the three reaction channels,
Y1 --c1--> Y1 + Y1
Y1 + Y2 --c2--> Y2 + Y2
Y1 --c3--> 0
Load package
library(GillespieSSA)
Define parameters
<- c(c1 = 10, c2 = .01, c3 = 10)
parms <- 2 # Final time
tf <- "Lotka predator-prey model" # Name simName
Define initial state vector
<- c(Y1=1000, Y2=1000) x0
Define state-change matrix
<- matrix(c(+1, -1, 0, 0, 1, -1), nrow = 2, byrow = TRUE) nu
Define propensity functions
<- c("c1*Y1", "c2*Y1*Y2","c3*Y2") a
Run simulations with the Direct method
set.seed(1)
<- ssa(
out x0 = x0,
a = a,
nu = nu,
parms = parms,
tf = tf,
method = ssa.d(),
simName = simName,
verbose = FALSE,
consoleInterval = 1
) ssa.plot(out, show.title = TRUE, show.legend = FALSE)
Run simulations with the Explict tau-leap method
set.seed(1)
<- ssa(
out x0 = x0,
a = a,
nu = nu,
parms = parms,
tf = tf,
method = ssa.etl(tau = .002),
simName = simName,
verbose = FALSE,
consoleInterval = 1
) ssa.plot(out, show.title = TRUE, show.legend = FALSE)
Run simulations with the Binomial tau-leap method
set.seed(1)
<- ssa(
out x0 = x0,
a = a,
nu = nu,
parms = parms,
tf = tf,
method = ssa.btl(f = 100),
simName = simName,
verbose = FALSE,
consoleInterval = 1
) ssa.plot(out, show.title = TRUE, show.legend = FALSE)
Run simulations with the Optimized tau-leap method
set.seed(1)
<- ssa(
out x0 = x0,
a = a,
nu = nu,
parms = parms,
tf = tf,
method = ssa.otl(epsilon = .1),
simName = simName,
verbose = FALSE,
consoleInterval = 1
) ssa.plot(out, show.title = TRUE, show.legend = FALSE)
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.