compileRcpp: Compiles 'SimBIID_model' object

View source: R/compileRcpp.R

compileRcppR Documentation

Compiles SimBIID_model object

Description

Compiles an object of class SimBIID_model into an XPtr object for use in Rcpp functions, or an object of class function for calling directly from R.

Usage

compileRcpp(model)

Arguments

model

An object of class SimBIID_model.

Value

An object of class XPtr that points to the compiled function, or an R function object for calling directly from R.

See Also

mparseRcpp

Examples


## set up SIR simulationmodel
transitions <- c(
    "S -> beta * S * I -> I", 
    "I -> gamma * I -> R"
)
compartments <- c("S", "I", "R")
pars <- c("beta", "gamma")
model <- mparseRcpp(
    transitions = transitions, 
    compartments = compartments,
    pars = pars
)

## compile model to be run directly
model <- compileRcpp(model)
model

## set initial states (1 initial infection 
## in population of 120)
iniStates <- c(S = 119, I = 1, R = 0)

## set parameters
pars <- c(beta = 0.001, gamma = 0.1)

## run compiled model
model(pars, 0, 100, iniStates)



tjmckinley/SimBIID documentation built on Sept. 11, 2022, 11:58 a.m.