sim_trajectory_CSV_decoupled {MGDrivE2} | R Documentation |
Simulate Trajectory From a SPN Model
Description
This function provides a unified interface to the various simulation algorithms for SPN, returning output sampled at a lattice of time points to the user, and handling various exogenous events that may occur during the simulation (such as release of adult mosquitoes). This function is used in decoupled sampling, where the mosquito and human states are separated. This is used primarily when using the Imperial model of malaria transmission.
Usage
sim_trajectory_CSV_decoupled(
x0,
h0,
inf_labels,
tmax,
dt = 1,
dt_stoch = 0.1,
folders = "./",
S,
hazards,
SPN_P,
theta,
Sout = NULL,
sampler = "tau",
method = "lsoda",
events = NULL,
batch = NULL,
verbose = TRUE,
human_ode = "Imperial",
cube = cube,
...
)
Arguments
x0 |
the initial marking of the SPN (initial state, M0) |
h0 |
the initial human state distribution |
inf_labels |
labels corresponding to female mosquito infection hazard |
tmax |
the final time to end simulation |
dt |
the time-step at which to return output (not the time-step of the sampling algorithm) |
dt_stoch |
time-step used for approximation of hazards |
folders |
vector of folders to write output |
S |
a stoichiometry |
hazards |
list of hazard functions |
SPN_P |
stochastic petri net places |
theta |
parameters |
Sout |
an optional matrix to track event firings |
sampler |
determines sampling algorithm, one of; "ode", "tau", "cle", or "dm" |
method |
if |
events |
a |
batch |
a |
verbose |
print a progress bar? |
human_ode |
human ode function |
cube |
inheritance cube |
... |
further named arguments passed to the step function |
Details
dt_stoch
is used by the Poisson Time-Step (step_PTS
) and
Chemical Langevin (step_CLE
) methods to approximate the hazards.
A smaller dt_stoch
provides a better approximation, but will take longer
to run.
The stoichiometry matrix (S
) is generated in spn_S
.
The list of hazards (hazards
) come from spn_hazards
.
Several samplers are provided. The default is a Poisson Time-Step
(step_PTS
) method. Other options are Gillespie's Direct Method
(step_DM
) and a Chemical Langevin sampler (step_CLE
).
Additionally, for convenience, an ODE "sampler" (step_ODE
) is
provided for compatibility with other samplers. This function uses methods from
deSolve
.
If using the ode
sampler, several methods
are provided in the deSolve
package, see ode
. For inhomogeneous systems, consider
using the "rk4" method to avoid excessive integration times.
Additionally, events
objects must follow the format required by
deSolve
. This was done for consistency, see events
for more information.
This function writes all output to .csv files. Each simulation is written to
a folder
element - the number of repetitions is the number of folders
provided. For now, only adult mosquito states, human states, clinical incidence, and pathogen prevalence are
written to CSVs.
This function tracks state variables specified by argument stage
by default; an optional argument Sout
can be provided to track number of event firings each time step (for discrete stochastic simulations),
or cumulative intensity (for continuous stochastic simulations), or the rate function of
particular events for ODE simulation. The matrix must have number of columns equal to
number of events in the system (the number of hazard functions), and a row for each tracking
variable. If Sout
is provided, it outputs an additional csv, "Tracking.csv".
The function track_hinf
is provided, which builds a matrix to track
human infection events.
To return simulations to R for further processing, see sim_trajectory_R
.
Value
NULL - prints output to .csv files