From 5077d4b8991e97346d01851b116baf0bd2a16c15 Mon Sep 17 00:00:00 2001 From: RJSheppard Date: Mon, 15 Apr 2024 13:33:36 +0100 Subject: [PATCH] Moved mortality to the end of processes to resolve order of competing hazards. --- R/processes.R | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/R/processes.R b/R/processes.R index 6109490f..cb6674e7 100644 --- a/R/processes.R +++ b/R/processes.R @@ -46,7 +46,7 @@ create_processes <- function( create_exponential_decay_process(variables$iva, parameters$rva), create_exponential_decay_process(variables$id, parameters$rid) ) - + if (parameters$individual_mosquitoes) { processes <- c( processes, @@ -59,7 +59,7 @@ create_processes <- function( ) ) } - + # ============================== # Biting and mortality processes # ============================== @@ -80,7 +80,6 @@ create_processes <- function( mixing, mixing_index ), - create_mortality_process(variables, events, renderer, parameters), create_asymptomatic_progression_process( variables$state, parameters$dd, @@ -112,7 +111,7 @@ create_processes <- function( 0 ) ) - + # =============== # ODE integration # =============== @@ -120,7 +119,7 @@ create_processes <- function( processes, create_solver_stepping_process(solvers, parameters) ) - + # ========= # RTS,S EPI # ========= @@ -137,7 +136,7 @@ create_processes <- function( ) ) } - + # ========= # PMC # ========= @@ -156,7 +155,7 @@ create_processes <- function( ) ) } - + # ========= # Rendering # ========= @@ -186,7 +185,7 @@ create_processes <- function( ), create_compartmental_rendering_process(renderer, solvers, parameters) ) - + if (parameters$individual_mosquitoes) { processes <- c( processes, @@ -208,11 +207,11 @@ create_processes <- function( ) ) } - + # ====================== # Intervention processes # ====================== - + if (parameters$bednets) { processes <- c( processes, @@ -225,14 +224,14 @@ create_processes <- function( net_usage_renderer(variables$net_time, renderer) ) } - + if (parameters$spraying) { processes <- c( processes, indoor_spraying(variables$spray_time, parameters, correlations) ) } - + # ====================== # Progress bar process # ====================== @@ -242,7 +241,12 @@ create_processes <- function( create_progress_process(timesteps) ) } - + + # Mortality step + processes <- c( + processes, + create_mortality_process(variables, events, renderer, parameters)) + processes } @@ -266,7 +270,7 @@ create_exponential_decay_process <- function(variable, rate) { #' @title Create and initialise lagged_infectivity object #' #' @param variables model variables for initialisation -#' @param parameters model parameters +#' @param parameters model parameters #' @noRd create_lagged_infectivity <- function(variables, parameters) { age <- get_age(variables$birth$get_values(), 0) @@ -283,7 +287,7 @@ create_lagged_infectivity <- function(variables, parameters) { #' #' @param variables model variables for initialisation #' @param solvers model differential equation solvers -#' @param parameters model parameters +#' @param parameters model parameters #' @noRd create_lagged_eir <- function(variables, solvers, parameters) { lapply(