Learn R Programming

SimInf (version 5.1.0)

V<-: Set a template for where to write the V result matrix

Description

Set a template for where to write the V result matrix

Usage

V(model) <- value

# S4 method for SimInf_model V(model) <- value

Arguments

model

The model to set a template for the result matrix V.

value

Write the real-valued continuous state at tspan to the non-zero elements in value, where value is a sparse matrix, dgCMatrix, with dimension \(N_n\)dim(ldata)[1] \(\times\) length(tspan). Default is NULL i.e. to write the real-valued continuous state to a dense matrix.

Examples

Run this code
# NOT RUN {
## Create an 'SISe' model with 6 nodes and initialize
## it to run over 10 days.
u0 <- data.frame(S = 100:105, I = 1:6)
model <- SISe(u0 = u0, tspan = 1:10, phi = rep(0, 6),
    upsilon = 0.02, gamma = 0.1, alpha = 1, epsilon = 1.1e-5,
    beta_t1 = 0.15, beta_t2 = 0.15, beta_t3 = 0.15, beta_t4 = 0.15,
    end_t1 = 91, end_t2 = 182, end_t3 = 273, end_t4 = 365)

## An example with a sparse V 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 V where the continuous state variables should be written. Then
## run the model with the sparse matrix as a template for V where
## to write data.
m <- Matrix::sparseMatrix(1:6, 5:10)
V(model) <- m
result <- run(model, threads = 1, seed = 7)

## Extract the continuous state variables at the time-points in tspan.
V(result)
# }

Run the code above in your browser using DataLab