# NOT RUN {
## Create an 'SIR' model with 6 nodes and initialize
## it to run over 10 days.
u0 <- data.frame(S = 100:105, I = 1:6, R = rep(0, 6))
model <- SIR(u0 = u0, tspan = 1:10, beta = 0.16, gamma = 0.077)
## An example with a sparse U result matrix, which can save a lot
## of memory if the model contains many nodes and time-points, but
## where only a few of the data points are of interest. First
## create a sparse matrix with non-zero entries at the locations
## in U where the number of individuals should be written. Then
## run the model with the sparse matrix as a template for U where
## to write data.
m <- Matrix::sparseMatrix(1:18, rep(5:10, each = 3))
U(model) <- m
result <- run(model, threads = 1, seed = 22)
## Extract the number of individuals in each compartment at the
## time-points in tspan.
U(result)
# }
Run the code above in your browser using DataLab