This is the main simulation module. It takes the sim_data
object prepared
by initialise
and runs simulation for a given number of time steps.
The initial (specified by the burn
parameter) time steps are skipped
and discarded from the output. Computations can be done in parallel if
the name of a cluster created by makeCluster
is provided.
Generally, at each time step, simulation consists of two phases: local
dynamics and dispersal.
Local dynamics (which connects habitat patches in time) is defined by
the function growth
. This parameter is specified while creating
the obj
using initialise
, but can be later modified by using
the update
function. Population growth can be either exponential
or density-dependent, and the regulation is implemented by the use of
Gompertz or Ricker models (with a possibility of providing any other,
user defined function). For every cell, the expected population density
during the next time step is calculated from the corresponding number
of individuals currently present in this cell, and the actual number
of individuals is set by drawing a random number from the Poisson
distribution using this expected value. This procedure introduces a realistic
randomness, however additional levels of random variability can be
incorporated by providing parameters of both demographic and environmental
stochasticity while specifying the sim_data
object using the initialise
function (parameters r_sd
and K_sd
, respectively).
To simulate dispersal (which connects habitat patches in space), for each
individual in a given cell, a dispersal distance is randomly drawn from
the dispersal kernel density function. Then, each individual is translocated
to a randomly chosen cell at this distance apart from the current location.
For more details, see the disp
function.