1 The parts

  1. Initializing a simulation using simInit() creates a simList object.

  2. Running a simulation via a spades() call returns a modified simList object.

2 How are simulations specified?

A simList object is simply a structured data type containing various elements of a simulation.

The main components of a simList are:

  1. A list of modules used;
  2. The event queue;
  3. A description of the data (object) dependencies.

3 How SpaDES works: simLists

We can examine the simList object structure in the usual R fashion by printing (showing) it, or by using str():

emptySim <- simInit()
emptySim  # same as show(emptySim)
str(emptySim)

NOTE: simLists are S4 objects, so we can use getSlots() and slotNames() to examine the object.

See also ?'.simList-class'

Exercises 03, numbers 2 & 3.

4 Accessing the parts of a simLists

slot accessor
.envir envir()
modules modules()
params params()
events events()
current current()
completed completed()
depends depends()
simtimes times()
inputs inputs()
outputs outputs()
paths paths()
other_accessors
packages()
globals()
start()
end()
timeunit()
timeunits()
objects()
paths()
cachePath()
inputPath()
outputPath()
modulePath()

5 How SpaDES works: spades()

5.1 Model specification

Simple examples (using demo modules) of simInit() and spades() calls.

Exercises 03, number 4, 5, & 6.

  • examine simList structure before and after the spades() call

6 Using pre-built modules

  1. Browse for modules in our SpaDES module repository:

    https://github.com/PredictiveEcology/SpaDES-modules

  2. Download a module and its data:

    module.path <- file.path(dirname(tempdir()), "modules")
    downloadModule('wolfAlps', module.path, data = FALSE)
    downloadData('wolfAlps', module.path)
  3. Open the module’s code file in your editor:

    openModules('wolfAlps', module.path)  # opens only the named module
    openModules(path = module.path)       # opens all modules in a directory

7 Customizing an existing module

  1. make a copy of the module you wish to modify

  2. edit away!

8 Next steps

Building SpaDES modules from scratch (slides).