1 SpaDES

Spatial Discrete Event Simulator

  • Discrete event simulators have a long history in computer science
  • SpaDES is oriented around the construction of spatially explicit models and the use of spatial data.
  • events describe changes in the state of a complex system at some time
  • time is not modeled in a continuous fashion (simple loops would do this); we can ‘skip ahead’ to the next event, speeding up model evaluation
  • events are scheduled (added to a queue) dynamically, and executed at their scheduled time

2 Other DESs

  • In Ecology, there are other generic DESs:

    • SELES (very generic)
    • HexSim
    • NetLogoR (Individual based models)
  • More specific DESs

    • LANDIS (forest dynamics)

3 Events

  • Spring thaw

  • Brainstorm events…

4 Modules

  • Modules are a convenient way to group events that fit naturally together:

    • E.g., fire ignition module
    • E.g., carbon accumulation module
    • E.g., data preparation module
  • What is contained in one module is highly idiosyncratic .

5 Modules → Modularity

SpaDES is implemented in a way that facilitates modularity of code:

  • different (ecological) processes can be grouped into logical units (modules)
  • a(n) (ecological) model consists of a collection of modules
  • each module is responsible for scheduling its own events
  • modules interact indirectly via shared data objects (e.g., a map); module ‘A’ doesn’t need to know what module ‘B’ is doing

Thus, modules can be added, removed, or swapped out without needing to recode the rest of the model.

6 Module types

  • There are many types of modules that may be useful

    • Agents
    • Events
    • Data preparation
    • Summaries of data
    • see list from SpaDES wiki
  • Once we see that a module is just a convenient way to group together events, anything can be a module
  • Can be 1 lines of code or as large as you want

7 Agent-based modules

8 Raster module

  • Vegetation change
  • Spatial clustering (e.g., to create polygons)
  • Aging
  • Class change (e.g., land cover class)
  • Biomass change
  • etc.

9 Data preparation module

  • cropReprojectLcc

10 Why use a SpaDES module

… instead of just an R script or function?

  • allows things to be scheduled
  • allows modularity

    • a module can be reused by someone else with little change
  • can be published on the web
  • can estimate unknown parameters
  • and much more…

11 Anatomy of a module

A module is an R script with 3 parts:

  1. Metadata - a list of 15 things

    • Name, Author, Description, other for human reader
    • parameters, input objects, output objects for R to “understand”
  2. doEvent - 2 types of things here

    • schedule events
    • run functions
  3. Anything else

    • custom functions
    • initial data preparation steps

12 Running SpaDES

Essentially 2 steps

  1. Create a simList using simInit()
  2. Run spades()

All the necessary information is contained within the simList

What might be needed for a DES to run…

13 What is in the simList

- start and stop times
- data
- paths
- which modules to use
- parameters
- a schedule of events
- outputs
  • Will be covered in detail next

14 Data

  • We are working with R, so we can use any data structure or file format that R can understand
  • SpaDES has some helpers for loading data, but in general, the module should be explicit

    • e.g., downloadData(“caribouMovement”, path = tempdir())
  • A module takes input data, changes them, and provides outputs
  • like a function, but with the addition of “time”

  • Some challenges …

15 Data challenges

Numerous challenges exist with data

  • messy
  • ownership
  • large
  • permissions
  • errors
  • other

SpaDES doesn’t necessarily solve these issues, but in some cases it helps.

16 Where to get help