Function to run an EpiModel sim with the result of an swfcalib calibration
Source: R/swfcalib_helpers.R
netsim_swfcalib_output.RdThe simulations of a batch are run in parallel, one netsim call per
simulation (see netsim_path_wrapper), by default with
future::plan("multisession", workers = n_cores). Unlike the multicore
default of step_tmpl_netsim_swfcalib_output, this also runs in parallel
from RStudio and on Windows.
Using control$future.use.plan <- future::tweak(<your plan>) will bypass
this setting.
Usage
netsim_swfcalib_output(
path_to_x,
param,
init,
control,
calib_object,
n_rep,
n_cores,
output_dir,
libraries = NULL
)Arguments
- path_to_x
Path to a fitted network model or a restart point saved with
saveRDS(See thexargument to theEpiModel::netsimfunction), or to a restart pool directory (seemake_restart_pool).- param
Model parameters, as an object of class
param.net. Includes transmission probability (inf.prob), act rate (act.rate), recovery rate (rec.rate), and demographic rates for models with vital dynamics. Custom parameters for extended models may also be passed throughparam.net.- init
Initial conditions, as an object of class
init.net. Specifies the initial number of infected nodes (i.num) and, for SIR models, recovered nodes (r.num). For two-group models, the corresponding.g2parameters are also required.- control
Control settings, as an object of class
control.net. Key settings includetype(disease model:"SI","SIR", or"SIS"),nsteps(number of time steps),nsims(number of simulations),tergmLite(lightweight mode for performance), andresimulate.network(required for models with vital dynamics). For extended models, custom module functions are also passed here.- calib_object
a formatted calibration object
- n_rep
The number of replication to be run for each scenario.
- n_cores
The number of CPUs on which the simulations will be run.
- output_dir
The folder where the simulation files are to be stored.
- libraries
A character vector containing the name of the libraries required for the model to run. (e.g. EpiModelHIV or EpiModelCOVID)
Checkpointing
This function takes care of editing .checkpoint.dir to create unique sub
directories for each scenario, batch and simulation:
"<.checkpoint.dir>/sim__EpiModel::control.net way of setting up checkpoints can be used
transparently. Unless .checkpoint.keep is TRUE, the batch directory is
removed once the batch file is saved.
Step Template
Step Templates are helper functions to be used within add_workflow_step.
Some basic ones are provided by the slurmworkflow package. They instruct
the workflow to run either a bash script, a set of bash lines given as a
character vector or an R script.
Additional Step Templates can be created to simplify specific tasks. The
easiest way to do so is as wrappers around existing templates.