simecol-package: Simulation of Ecological (and Other) Dynamic Systems

Description Details Author(s) References See Also Examples

Description

An object oriented framework to simulate ecological (and other) dynamic systems. It can be used for differential equations, individual-based (or agent-based) and other models as well. It supports structuring of simulation scenarios (to avoid copy and paste) and aims to improve readability and re-usability of code.

Details

The DESCRIPTION file: This package was not yet installed at build time.

The simecol package is intended to give users (scientists and students) an interactive environment to implement, distribute, simulate and document ecological and other dynamic models without the need to write long simulation programs. An object oriented framework using the S4 class system provides a consistent but still flexible approach to implement simulation models of different types:

Each simulation model is implemented as S4 object (superclass simObj) with the following slots:

simObj model objects should be defined and created using the common S4 mechanisms (new).

Normally, a simObj object can contain all data needed to run simulations simply by entering the model object via source() or data() and then to run and plot the model with 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, the main and sub-equations, an observer or an initfunc and 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 [email protected], but this is normally not recommended as there is no guarantee that this will work in a compatible way in future versions.

Models of different type are provided as data and some more in source code (see directory examples).

The examples can be used as a starting point to write 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.

Author(s)

Thomas Petzoldt

References

Petzoldt, T. and K. Rinke (2007) simecol: An Object-Oriented Framework for Ecological Modeling in R. Journal of Statistical Software, 22(9). doi: 10.18637/jss.v022.i09

See Also

CA, chemostat, conway, diffusion, lv, lv3, upca.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
## (1) Quick Start Examples ====================================================

data(lv)        # load basic Lotka-Volterra model

## Not run: 
require("tcltk")
lv <- editParms(lv)

## End(Not run)
parms(lv)
main(lv)
lv <- sim(lv)
plot(lv)
results <- out(lv)

## Not run: 
data(conway)    # Conway's game of life
init(conway) <- matrix(0, 10, 10)
times(conway) <-  1:100
conway <- editInit(conway) # enter some "1"
sim(conway, animate=TRUE, delay=100)

## End(Not run)

## (2) Define and run your own  simecol model ==========================

lv <- new("odeModel",
  main = function (time, init, parms) {
    with(as.list(c(init, parms)), {
      dn1 <-   k1 * N1 - k2 * N1 * N2
      dn2 <- - k3 * N2 + k2 * N1 * N2
      list(c(dn1, dn2))
    })
  },
  parms  = c(k1 = 0.2, k2 = 0.2, k3 = 0.2),
  times  = c(from = 0, to = 100, by = 0.5),
  init   = c(N1 = 0.5, N2 = 1),
  solver = "lsoda"
)

lv <- sim(lv)
plot(lv)

## (3) The same in matrix notation; this allows generalization      ====
##     to multi-species interaction models with > 2 species.        ====

LVPP <- new("odeModel",
  main = function(t, n, parms) {
    with(parms, {
      dn <- r * n  + n * (A %*% n)
      list(c(dn))
    })
  },
  parms = list(
    # growth/death rates
    r = c(k1 = 0.2, k3 = -0.2),
    # interaction matrix
    A = matrix(c(0.0, -0.2,
                 0.2,  0.0),
                 nrow = 2, ncol = 2, byrow=TRUE)
  ),
  times  = c(from = 0, to = 100, by = 0.5),
  init   = c(N1 = 0.5, N2 = 1),
  solver = "lsoda"
)

plot(sim(LVPP))


## (4) Additional resources ============================================

## Not run: 
## open the directory with source code of demo
browseURL(paste(system.file(package="simecol"), "/demo", sep=""))

## run demo
demo(jss)

## open the directory with R sourcecode examples
browseURL(paste(system.file(package="simecol"), "/doc/examples", sep=""))

## show package vignette with introductory article
vignette("a-simecol-introduction")
vignette("b-simecol-howtos")
## edit a vignette
# edit(vignette("a-simecol-introduction"))
# edit(vignette("b-simecol-howtos"))

## Open Project Homepage
browseURL("http://www.simecol.de")

## End(Not run)

## How to cite package simecol in publications
citation("simecol")

simecol documentation built on June 3, 2018, 5:07 p.m.