vignettes/Modules_Thinking_in_a_modular_way.Rmd
Modules_Thinking_in_a_modular_way.Rmd
SpaDES
Spatial Discrete Event Simulator
SpaDES
is oriented around the construction of spatially explicit models and the use of spatial data.In Ecology, there are other generic DESs:
More specific DESs
Modules are a convenient way to group events that fit naturally together:
What is contained in one module is highly idiosyncratic .
SpaDES
is implemented in a way that facilitates modularity of code:
Thus, modules can be added, removed, or swapped out without needing to recode the rest of the model.
There are many types of modules that may be useful:
Once we see that a module is just a convenient way to group together events, anything can be a module. Can be a single line of code or as many as you want.
SpaDES
module… instead of just an R script or function?
allows things to be scheduled
allows modularity
can be published on the web
can estimate unknown parameters
and much more…
A module is an R script with 3 parts:
Metadata - a list of 15 things
doEvent - 2 types of things here
Anything else
SpaDES
Essentially 2 steps
simList
using simInit()
spades()
All the necessary information is contained within the simList
What might be needed for a DES to run…
simList
- start and stop times
- data
- paths
- which modules to use
- parameters
- a schedule of events
- outputs
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
downloadData("caribouMovementLcc", path = tempdir())
A module takes input data, changes them, and provides outputs
like a function, but with the addition of “time”
Some challenges …
Numerous challenges exist with data
SpaDES
doesn’t necessarily solve these issues, but in some cases it helps.