Skip to content

Commit

Permalink
CM scaling that helps speed up some runs
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikunterwegs committed Oct 31, 2024
1 parent ad93975 commit 213fab3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions R/class_country.R
Original file line number Diff line number Diff line change
Expand Up @@ -429,15 +429,17 @@ prepare_parameters.daedalus_country <- function(x, ...) {

demography <- get_data(x, "demography")

# scale contacts by largest real eigenvalue
cm <- get_data(x, "contact_matrix")
# scale M[i, ] by demography[j]
cm_unscaled <- get_data(x, "contact_matrix")
cm <- cm_unscaled / demography
cmw <- get_data(x, "contacts_workplace")
cmcw <- get_data(x, "contacts_consumer_worker")
workers <- get_data(x, "workers")

list(
demography = demography,
contact_matrix = cm,
cm_unscaled = cm_unscaled, # for use in Rt calculations
contacts_workplace = cmw / workers, # scaled by workers
contacts_consumer_worker = cmcw
)
Expand Down
2 changes: 1 addition & 1 deletion R/ode.R
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ daedalus_rhs <- function(t, state, parameters) {

community_infectious <- community_infectious[i_AGE_GROUPS]

cm_inf <- beta * cm %*% (community_infectious / demography)
cm_inf <- beta * cm %*% (community_infectious)

# NOTE: `state` and `cm_inf` mult. assumes length(cm_inf) == nrows(state)
new_community_infections <- state_[, i_S, ]
Expand Down
2 changes: 1 addition & 1 deletion R/reff_calculation.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ r_eff <- function(state, parameters) {
demography <- parameters$demography

beta <- parameters$beta
cm <- parameters$contact_matrix
cm <- parameters$cm_unscaled
sigma <- parameters$sigma
p_sigma <- parameters$p_sigma
epsilon <- parameters$epsilon
Expand Down

0 comments on commit 213fab3

Please sign in to comment.