Description Usage Arguments Details Value Examples
Run cellular automata simulation.
1 2 3 4 |
x |
A landscape object. |
model |
A valid object of class 'ca_model'. Defaults to musselbed. Valid
values are: |
parms |
A list of parameters with one or several parameters containing a
vector of parameter values. Those will be combined full-factorially using
|
t_max |
Maximal number of timesteps. Model will be terminated even if still in transient dynamics (i.e. model did not reach steady state) |
saveeach |
Timespan between timesteps at which a full snapshot of the landscape is saved into the output of the simulation. |
stopifsteady |
Binary parameter, defaults to FALSE. If TRUE, the
function provided in parameter |
steady |
A function returning TRUE or FALSE, taking exactly the
parameters |
steadyparms |
a list of parameters that are required by the function
provided in |
plotting |
A binary variable. If TRUE, simulation is plotted into an animated gif. |
filename |
A character string. Filename of animated gif (defaults to "modelrun.gif") which will be placed in current working directory. If not provided global seeds of R apply. |
seed |
An integer number serving as seed for random number generation. |
... |
Parameters handed over to update function in |
t_eval |
Timespan of moving window that is evaluated for the end of transient dynamics. |
Runs iterations of the update function model$update()
on the
initial landscape x
until a t_max
is reached. The function
saves the full timeseries, i.e. a value for each timestep, of the global
cover of each state as well as the average local cover of each state. The
full landscape object of each timestep is stored in a list
result$landscapes
of the output object, but frequency of these
snapshots can be altered by increasing the parameter saveeach
.
The output is returned as a list object of class ca_result
,
containing a full timeseries of global and local cover as well as snapshots
of the landscape.
$model
The entire model object
used to generate this simulation run, including the parameters at
$model$parms
$time
Vector of timesteps.
$issteady
Binary vector reporting for each timestep if the criterion for steady state was fulfilled. The criterion can be customized by adjusting parameter steady
.
$cover
A list of cover timeseries for each state of the model.
$local
A list of local cover timeseries for each state of the model.
$snaps
A vector of indices of saved snapshots.
$landscapes
A list of landscape objects at each
point in $snaps
$issteady
A binary vector of the
returned values of function steady
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # 1. run simulation and save a snapshot each 50 timesteps. plot timeseries and snapshots.
l <- init_landscape(c("+","0","-"), c(0.6,0.2,0.2), width = 100)
p <- list(r = 0.4, d = 0.9, delta = 0.01) # set parameters
r <- ca(l, model = musselbed, parms = p, t_max = 200) # run simulation
plot(r)
par(mfrow= c(2,3))
sapply(c(0,25,50,100,150,200)+1, function(i) plot(r$landscapes[[i]]) )
# 2. run simulation and save full landsape at each timestep. create animated gif.
l <- init_landscape(c("1","0"), c(0.6,0.4), 100)
r <- ca(l, model = life, t_max = 400)
animate(r, "life01.gif")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.