CGillespie: R6 class implementing the Gillespie method susing cpp11 This...

CGillespieR Documentation

R6 class implementing the Gillespie method susing cpp11 This is a subclass of Simulator, implementing the Gillespie method to simulate a compartmental model using cpp11. This class is only available if the 'cpp11' package is installed.

Description

R6 class implementing the Gillespie method susing cpp11

This is a subclass of Simulator, implementing the Gillespie method to simulate a compartmental model using cpp11. This class is only available if the 'cpp11' package is installed.

R6 class implementing the Gillespie method susing cpp11

This is a subclass of Simulator, implementing the Gillespie method to simulate a compartmental model using cpp11. This class is only available if the 'cpp11' package is installed.

Super class

REpiSim::Simulator -> CGillespie

Methods

Public methods

Inherited methods

Method new()

constructor

Usage
CGillespie$new(model)
Arguments
model

an object of the 'Compartmental' class

Details

the CGillespie class is only available if the cpp11 package is installed. # an SIR model library(cpp11) # cpp11 is required to use CGillespie SIR = Compartmental$new(S, I, R, N=S+I+R, title="SIR") SIR$transition(S->I ~ beta*S*I/N, name="infection") SIR$transition(I->R ~ gamma*I, name="recovery") g = CGillespie$new(SIR) g$simulate(0:100, y0=c(S=1000, I=10, R=0), parms=c(beta=0.4,gamma=0.2))


Method finalize()

the destructor

Usage
CGillespie$finalize()
Details

The destructor unload the dynamic library loaded by cpp11 after compiling the C++ simulation code.


Method clone()

The objects of this class are cloneable with this method.

Usage
CGillespie$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

# an SIR model
SIR = Compartmental$new(S, I, R, title="SIR")
SIR$transition(S->I ~ beta*S*I/N, N=S+I+R, name="infection")
SIR$transition(I->R ~ gamma*I, name="recovery")
g = CGillespie$new(SIR)
g$simulate(0:100, y0=c(S=1000, I=10, R=0), parms=c(beta=0.4,gamma=0.2))

junlingm/REpiSim documentation built on Nov. 28, 2023, 2:35 a.m.