Contains the minimum components of a SpaDES simulation. Various slot accessor methods (i.e., get and set functions) are provided (see 'Accessor Methods' below).

Details

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).

Slots

modules

List of character names specifying which modules to load.

params

Named list of potentially other lists specifying simulation parameters.

events

The list of scheduled events (i.e., event queue), as a data.table. See 'Event Lists' for more information.

current

The current event, as a data.table. See 'Event Lists' for more information..

completed

The list of completed events, as a list. See 'Event Lists' for more information. It is kept as a list of individual events for speed. The completed method converts it to a sorted data.table.

depends

A .simDeps list of .moduleDeps objects containing module object dependency information.

simtimes

List of numerical values describing the simulation start and end times; as well as the current simulation time.

inputs

a data.frame or data.table of files and metadata

outputs

a data.frame or data.table of files and metadata

paths

Named list of modulePath, inputPath, and outputPath paths. Partial matching is performed.

.xData

Environment 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.

.envir

Deprecated. Please do not use any more.

Note

The simList class extends the environment, by adding several slots that provide information about the metadata for a discrete event simulation. The environment slot, if accessed directly is .xData and this is where input and output objects from modules are placed. The simList_ class is similar, but it extends the list class. All other slots are the same. Thus, simList is identical to simList_, except that the former uses an environment for objects and the latter uses a list. The class simList_ is only used internally.

Accessor Methods

Several slot (and sub-slot) accessor methods are provided for use, and categorized into separate help pages:

simList-accessors-envirSimulation environment.
simList-accessors-eventsScheduled and completed events.
simList-accessors-inoutPassing data in to / out of simulations.
simList-accessors-modulesModules loaded and used; module dependencies.
simList-accessors-objectsAccessing objects used in the simulation.
simList-accessors-paramsGlobal and module-specific parameters.
simList-accessors-pathsFile paths for modules, inputs, and outputs.
simList-accessors-timesSimulation times.
simList-accessors-envir

Event Lists

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:

eventTimeThe time the event is to occur.
moduleNameThe module from which the event is taken.
eventTypeA character string for the programmer-defined event type.
eventPriorityThe priority given to the event.
eventTime

References

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