simList classContains the minimum components of a SpaDES simulation.
Various slot accessor methods (i.e., get and set functions) are provided
(see 'Accessor Methods' below).
modulesList of character names specifying which modules to load.
paramsNamed list of potentially other lists specifying simulation parameters.
eventsThe list of scheduled events (i.e., event queue), which can
be converted to a sorted data.table with events(sim).
See 'Event Lists' for more information.
currentThe current event, as a data.table.
See 'Event Lists' for more information..
completedAn environment consisting of completed events, with
each object named a character representation of the order
of events. This was converted from a previous version which
was a list. This was changed because the list became
slow as number of events increased.
See 'Event Lists' for more information. It is kept
as an environment of individual events for speed. The completed
method converts it to a sorted data.table.
dependsA .simDeps list of .moduleDeps() objects
containing module object dependency information.
simtimesList of numerical values describing the simulation start and end times; as well as the current simulation time.
inputsa data.frame or data.table of files and
metadata
outputsa data.frame or data.table of files and
metadata
pathsNamed list of paths. See ?.paths. Partial matching is performed.
.xDataEnvironment referencing the objects used in the simulation.
Several "shortcuts" to accessing objects referenced by this
environment are provided, and can be used on the
simList object directly instead of specifying the
.xData slot: $, [[, ls,
ls.str, objs. See examples.
.envirDeprecated. Please do not use any more.
Several slot (and sub-slot) accessor methods are provided for use, and categorized into separate help pages:
simList-accessors-envir() | Simulation environment. |
simList-accessors-events() | Scheduled and completed events. |
simList-accessors-inout() | Passing data in to / out of simulations. |
simList-accessors-modules() | Modules loaded and used; module dependencies. |
simList-accessors-objects() | Accessing objects used in the simulation. |
simList-accessors-params() | Global and module-specific parameters. |
simList-accessors-paths() | File paths for modules, inputs, and outputs. |
simList-accessors-times() | Simulation times. |
The main event list is a sorted data.table (keyed) on eventTime, and eventPriority.
The completed event list is an ordered list in the exact order that the events were executed.
Each event is represented by a data.table() row consisting of:
eventTime | The time the event is to occur. |
moduleName | The module from which the event is taken. |
eventType | A character string for the programmer-defined event type. |
eventPriority | The priority given to the event. |
Alex Chubaty and Eliot McIntire
Based on code from chapter 7.8.3 of Matloff (2011): "Discrete event simulation".
Here, we implement a discrete event simulation in a more modular fashion so
it's easier to add simulation components (i.e., "simulation modules").
We use S4 classes and methods, and use data.table() instead of
data.frame() to implement the event queue (because it is much
more efficient).
Matloff, N. (2011). The Art of R Programming (ch. 7.8.3). San Francisco, CA: No Starch Press, Inc.. Retrieved from https://nostarch.com/artofr.htm