Learn R Programming

simecol (version 0.5-2)

iteration: Discrete Simulation

Description

Solver function to simulate discrete ecological (or other) dynamic models. It is normally called indirectly from sim.

Usage

iteration(y, times=FALSE, func=FALSE, parms=FALSE, animate = FALSE, ...)

Arguments

y
The simObj object to be iterated.
times
Placeholder for compatibility with the odesolve package.
func
Placeholder for compatibility with the odesolve package.
parms
Placeholder for compatibility with the odesolve package.
animate
Animation during the simulation (if available for the specified class.
...
Optional arguments passed to the plot function if animate=TRUE.

Value

  • A list of the model outputs (states ...) for each timestep.

Details

The solver method iteration is used to simulate discrete event models. It creates a local environment in a way that parameters, inputs and equations are visible within the main function of the simObj. In contrast to the ODE solvers, the main function of the model must not return the first derivative but instead of this the new state at the specified times explicitly. The actual value of time is available in the main function as time and the current increment as parms$DELTAT or parms["DELTAT"] depending on the data type of parms. Normally, this function is run indirectly from sim.

See Also

sim, parms, lsoda, rk4, euler.

Examples

Run this code
data(conway)
    ## plot after simulation:
    plot(sim(conway), delay=100)

    ## plot during simulation
    sim(conway, animate=TRUE, delay=100)

Run the code above in your browser using DataLab