Learn R Programming

SpaDES.core (version 2.0.5)

doEvent: Process a simulation event

Description

Internal function called from spades.

Usage

doEvent(
  sim,
  debug = FALSE,
  notOlderThan,
  useFuture = getOption("spades.futureEvents", FALSE),
  events = NULL,
  ...
)

Value

Returns the modified simList object.

Arguments

sim

Character string for the simList simulation object.

debug

Optional tools for invoking debugging. Supplying a list will invoke the more powerful logging package. See details. Default is to use the value in getOption("spades.debug").

notOlderThan

Date or time. Passed to reproducible::Cache to update the cache. Default is NULL, meaning don't update the cache. If Sys.time() is provided, then it will force a recache, i.e., remove old value and replace with new value. Ignored if cache is FALSE.

useFuture

Experimental use of future::future package. Not fully implemented.

events

A character vector or a named list of character vectors. If specified, the simulations will only do the events indicated here. If a named list, the names must correspond to the modules and the character vectors can be specific events within each of the named modules. With the list form, all unspecified modules will run all their events, including internal spades modules, e.g., save, that get invoked with the outputs argument in simInit. See example.

...

Any. Can be used to make a unique cache identity, such as "replicate = 1". This will be included in the Cache call, so will be unique and thus spades will not use a cached copy as long as anything passed in ... is unique, i.e., not cached previously.

Author

Alex Chubaty

Details

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

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.

References

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