simecol allows to implement ecological models (ODEs, IBMs, ...) using a templatelike objectoriented stucture. It helps to organize scenarios and may also be useful for other areas.
simecol (simulation of ecological systems) is an R package which is based on an object oriented paradigm for the implementation of dynamic simulation models.
The simecol
package is
intended to give users (students and scientists) an interactive
environment to implement, distribute, simulate and document basic and
advanced ecological models without the need to write long simulation
programs. For this purpose, an object oriented approach is developed,
which should provide a consistent but still flexible and extensible way
to implement simulation models of different types, namely
Each simulation model is implemented as simecol
simulation model object with components main
, holding the main model equations, rules or arbitrary
program code equations (optional, a list of possibly nested submodels or
subequations ), parms
with model parameters, init with
the initial state, inputs (optional) for external input data and times
to define the simulation time and the time steps used.
simecolModels is a simulation model collection, together with additional classes, demos and experimental code.
simecol

simecolModels

The packages can be installed directly from the internet within R either via the menu (on Windows) or via the R command line:
>install.packages("simecol") 
>install.packages("simecol", repos="http://RForge.Rproject.org") >install.packages("simecolModels", repos="http://RForge.Rproject.org") 
A basic LotkaVolterra model 
library("simecol") data(lv, package="simecol") plot(sim(lv)) 
The classical Conway's Game of Life 
library("simecol") data(conway, package="simecol") plot(sim(conway)) m < matrix(0, 40, 40) m[5:35,19:21] <1 init(conway) < m sim(conway, animate=TRUE, delay=100, col=c("white", "green"), axes=FALSE) 
Object oriented (S4 based) representation of a simulation model object (simecol object).

library("simecol") # load the package first!
conway < new("gridModel", main = function(time, init, parms) { x < init srv < parms$srv gen < parms$gen n < nrow(x) m < ncol(x) nb < eightneighbours(x) ## survival rule xsrv < ifelse(x > 0 & (nb %in% srv), 1, 0) ## generation rule xgen < ifelse(x == 0 & (nb %in% gen), 1, 0) x < as.numeric((xgen + xsrv)>0) dim(x) < c(n,m) x }, parms = list(srv=c(2, 3), gen=3), times = c(from=1, to=10, by=1), init = matrix(round(runif(40*40)), nrow=40, ncol=40), solver = "iteration" ) ## and to run this example: plot(sim(conway)) 