Quick links: Author +++ R-Forge Project page +++ CRAN
simecol (simulation of ecological systems) is a lightweight R package that employs an object oriented paradigm for the implementation of dynamic simulation models.
The 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. An object oriented approach is used to provide a consistent but still flexible and extensible way to implement simulation models of different types:
A simulation model is implemented as simecol object (simObj) with components main, holding the main model equations, rules or arbitrary program code, equations (optional, a list of possibly nested sub-models or sub-equations ), 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.
The packages can be installed directly from the internet within R or Rstudio via the menu or the R command line:
Stable Version:
install.packages("simecol")
Development versions:
install.packages("simecol", repos="http://R-Forge.R-project.org")
install.packages("simecolModels", repos="http://R-Forge.R-project.org")
Subversion (svn) access:
Anonymous SVN access (read only):
svn checkout svn://svn.r-forge.r-project.org/svnroot/simecol
library("simecol")
data(lv, package="simecol")
plot(sim(lv))
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)
The following example shows that the structure of a model object is just a template.
library("simecol")
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"
)
plot(sim(conway))
simecol, like R, is free open source software licensed under the GNU Public License (GPL 2.0 or above). The software is provided as is and comes WITHOUT WARRANTY.