| simecol-package {simecol} | R Documentation |
The simecol package is intended to give users
(scientists and students) and interactive environment to implement,
distribute, simulate and document ecological and other dynamic models without the
need to write long simulation programs. For this purpose, an object
oriented approach on the S4 class system
is proposed, which should provide a consistent but still
flexible and extensible way to implement simulation models of different
types, namely
odeModel),
gridModel), and
rwalkModel).
Each simulation model is implemented as S4 object (superclass simObj)
with the following slots:
main = function(time, init, parms, ...): a function holding the
main equations of the model,
equations: an optional non-nested list holding arbitrary
sub-equations (submodels, utility functions) of the
model. Sub-equations can be interdependent and can be called
directly from within main or initialize.
parms: currently a list (for gridModels) or vector (all
other pre-definded classes) with constant model parameters,
times: vector of time steps or a vector with three
named values from, to, by specifying the
simulation time steps. The from-to-by form can be edited with
fixParms.
init: initial values (start values) of the
simulation. This is typically a named vector (state variables in
odeModels) or matrix (e.g. initial grid of
gridModels).
inputs: time dependend or spatially resolved external
inputs can be specified as data frame or matrix (more efficient). It
is up to the user to evaluate the corresponding values within the
main function. A performance optimized version of
approx, approxTime is available.
solver: charachter string specifying the solver
used. Currently "lsoda" (from package odesolve),
"rk4" and "iterator" are supported. It is possible
to write own solvers. Please have a look at the environment
manipulatiion code at the beginning of "rk4" or
"iterator".
out: this slot holds the simulation results after a
simulation run as data frame or list (of matrices).
simObj model objects can be defined and created using the
common S4 mechanisms (new) or respective generating
functions (e.g. odeModel).
In this way, a simObj object may contain all data, which are
needed to run simulations simply by entering the model object
via source() or data() and then to run and plot the
model for example via plot(sim(obj)).
Accessor functions (with names identical to the slot names) are
provided to get or set model parameters,
time steps, initial values, inputs, the solver or the main and
sub-equations or to extract the model outputs. It is also possible to
modify the components of the simecol objects directly, e.g. the model
equations of a model lv with lv@main.
Models of different type are provided as data
and in source code (directory examples). The examples are intended as
a starting point to write your own
simObj objects and to distribute them to whomever you wish.
The package is supplemented with several utility functions
(e.g. seedfill or neighbours), which can
be used independently from
simObj objects.
The following are sources of information on simecol:
| Home page | u <- "http://hhbio.wasser.tu-dresden.de/projects/simecol/"; browseURL(u) |
| News | file.show(system.file("NEWS", package = "simecol")) |
| Wish List | file.show(system.file("WISHLIST", package = "simecol")) |
| Acknowledgements | file.show(system.file("THANKS", package = "simecol")) |
| This File | package?simecol |
| Help files as PDF | u <- "http://hhbio.wasser.tu-dresden.de/projects/simecol/simecol.pdf"; browseURL(u) |
Thomas Petzoldt petzoldt@rcs.urz.tu-dresden.de
data(lv) # load basic Lotka-Volterra model
## Not run: fixParms(lv)
parms(lv)
main(lv)
lv <- sim(lv)
plot(lv)
results <- out(lv)
data(conway) # Conway's game of life
init(conway) <- matrix(0, 10, 10)
## Not run: fixInit(conway) # enter some "1"
sim(conway, animate=TRUE, delay=10)