## (1) Quick Start Examples ====================================================
data(lv) # load basic Lotka-Volterra model
require("tcltk")
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)
times(conway) <- 1:100
fixInit(conway) # enter some "1"
sim(conway, animate=TRUE, delay=100)
## (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 ============================================
## 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")
## How to cite package simecol in publications
citation("simecol")
Run the code above in your browser using DataLab