SpaDES (version 1.3.1)

doEvent: Process a simulation event

Description

Internal function called from spades.

Usage

doEvent(sim, debug)

# S4 method for simList,ANY doEvent(sim, debug)

# S4 method for simList,missing doEvent(sim)

Arguments

sim

Character string for the simList simulation object.

debug

Optional. Either Logical or character. If logical, entire simList will be printed at each event. If a character string, then it can be one of the many simList accessors, such as events, params. It can also be any R expression that will be evaluated with access to the sim object. If "current" is used, then it will be a compact list of the events as they go by.

Value

Returns the modified simList object.

Details

Calls the module corresponding to the event call, and executes the event.

Based on code from chapter 7.8.3 of Matloff (2011): "Discrete event simulation". Here, we implement a simulation in a more modular fashion so it's easier to add submodules to the simulation. We use S4 classes and methods, and use `data.table` instead of `data.frame` to implement the event queue (because it is much faster).

References

Matloff, N. (2011). The Art of R Programming (ch. 7.8.3). San Fransisco, CA: No Starch Press, Inc.. Retrieved from https://www.nostarch.com/artofr.htm