CGillespie | R 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.
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.
REpiSim::Simulator
-> CGillespie
new()
constructor
CGillespie$new(model)
model
an object of the 'Compartmental' class
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))
finalize()
the destructor
CGillespie$finalize()
The destructor unload the dynamic library loaded by cpp11 after compiling the C++ simulation code.
clone()
The objects of this class are cloneable with this method.
CGillespie$clone(deep = FALSE)
deep
Whether to make a deep clone.
# 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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.