From ed8b70f1749a91934ab3bc9cb770bcab11e684a5 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Tue, 9 Aug 2022 16:32:28 +0100 Subject: [PATCH 01/11] ITN and IRS survive rebirth --- R/mortality_processes.R | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/R/mortality_processes.R b/R/mortality_processes.R index 5884c928..9cf4885b 100644 --- a/R/mortality_processes.R +++ b/R/mortality_processes.R @@ -78,7 +78,6 @@ reset_target <- function(variables, events, target, state, timestep) { if (target$size() > 0) { # clear events to_clear <- c( - 'throw_away_net', 'rtss_mass_doses', 'rtss_mass_booster', 'rtss_epi_doses', @@ -114,9 +113,6 @@ reset_target <- function(variables, events, target, state, timestep) { # onwards infectiousness variables$infectivity$queue_update(0, target) - # vector control - variables$net_time$queue_update(-1, target) - variables$spray_time$queue_update(-1, target) - # zeta and zeta group survive rebirth + # zeta and zeta group and vector controls survive rebirth } } From eb9f3e95378ec8e33d8b7d352bbf694acf2b6c0a Mon Sep 17 00:00:00 2001 From: Giovanni Date: Tue, 9 Aug 2022 16:47:13 +0100 Subject: [PATCH 02/11] Clear ITN disposal schedule before setting it --- R/vector_control.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/vector_control.R b/R/vector_control.R index 3272b7f8..29c92d35 100644 --- a/R/vector_control.R +++ b/R/vector_control.R @@ -141,6 +141,7 @@ distribute_nets <- function(variables, throw_away_net, parameters, correlations) correlations )) variables$net_time$queue_update(timestep, target) + throw_away_net$clear_schedule(target) throw_away_net$schedule( target, log_uniform(length(target), parameters$bednet_retention) From 2c5aeb168d19fbd7c9e4c9d4484563b0f40dfb56 Mon Sep 17 00:00:00 2001 From: Giovanni Charles Date: Tue, 9 Aug 2022 17:05:34 +0100 Subject: [PATCH 03/11] Add tests for new ITN behaviour --- tests/testthat/test-mortality-integration.R | 6 ++++++ tests/testthat/test-vector-control.R | 1 + 2 files changed, 7 insertions(+) diff --git a/tests/testthat/test-mortality-integration.R b/tests/testthat/test-mortality-integration.R index 2e1fd64e..6ea850e7 100644 --- a/tests/testthat/test-mortality-integration.R +++ b/tests/testthat/test-mortality-integration.R @@ -26,6 +26,8 @@ test_that('mortality_process resets humans correctly', { variables$ivm <- mock_double(c(1, 2, 3, 4)) variables$ica <- mock_double(c(1, 2, 3, 4)) variables$iva <- mock_double(c(1, 2, 3, 4)) + variables$net_time <- mock_integer(c(1, 2, 3, 4)) + variables$spray_time <- mock_integer(c(1, 2, 3, 4)) renderer <- individual::Render$new(timestep) mortality_process <- create_mortality_process( @@ -44,6 +46,10 @@ test_that('mortality_process resets humans correctly', { mortality_process(timestep) expect_bitset_update(variables$state$queue_update_mock(), 'S', c(2, 4)) + + # vector controls are not touched + mockery::expect_called(variables$net_time$queue_update_mock(), 0) + mockery::expect_called(variables$spray_time$queue_update_mock(), 0) }) test_that('mortality_process samples deaths from a custom demography', { diff --git a/tests/testthat/test-vector-control.R b/tests/testthat/test-vector-control.R index 47a89d9d..8735c7ea 100644 --- a/tests/testthat/test-vector-control.R +++ b/tests/testthat/test-vector-control.R @@ -122,6 +122,7 @@ test_that('distribute_bednets process sets net_time correctly', { 50, c(3, 4) ) + mockery::expect_called(events$throw_away_net$clear_schedule, 1) mockery::expect_args( events$throw_away_net$schedule, 1, From 810e38eeabd274291b8b821697a9827229327cc1 Mon Sep 17 00:00:00 2001 From: Peter Winskill Date: Tue, 16 Aug 2022 08:52:02 +0100 Subject: [PATCH 04/11] Record MDA and SMC n treated before drug efficacy draw --- R/human_infection.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/human_infection.R b/R/human_infection.R index a7474382..853934d0 100644 --- a/R/human_infection.R +++ b/R/human_infection.R @@ -78,7 +78,6 @@ simulate_infection <- function( renderer ) - renderer$render('n_treated', treated$size(), timestep) renderer$render('n_infections', infected_humans$size(), timestep) schedule_infections( @@ -276,6 +275,9 @@ calculate_treated <- function( renderer$render('ft', ft, timestep) seek_treatment <- sample_bitset(clinical_infections, ft) n_treat <- seek_treatment$size() + + renderer$render('n_treated', n_treat, timestep) + drugs <- as.numeric(parameters$clinical_treatment_drugs[ sample.int( length(parameters$clinical_treatment_drugs), From c16228455121b2cec39c57120d4609589cf43451 Mon Sep 17 00:00:00 2001 From: Peter Winskill Date: Tue, 16 Aug 2022 08:52:24 +0100 Subject: [PATCH 05/11] Record MDA and SMC and treatment n treated before drug efficacy draw --- R/mda_processes.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/mda_processes.R b/R/mda_processes.R index 348e224b..58ef6d31 100644 --- a/R/mda_processes.R +++ b/R/mda_processes.R @@ -33,6 +33,8 @@ create_mda_listeners <- function( in_age <- which((age > min_ages[[time_index]]) & (age < max_ages[[time_index]])) target <- in_age[sample_intervention(in_age, int_name, coverage, correlations)] + renderer$render(paste0('n_', int_name, '_treated'), length(target), timestep) + successful_treatments <- bernoulli( length(target), parameters$drug_efficacy[[drug]] @@ -40,8 +42,6 @@ create_mda_listeners <- function( to_move <- individual::Bitset$new(parameters$human_population) to_move$insert(target[successful_treatments]) - renderer$render('n_mda_treated', to_move$size(), timestep) - if (to_move$size() > 0) { # Move Diseased diseased <- variables$state$get_index_of(c('D', 'A'))$and(to_move) From 130b349e68716fc6c9b72ac20b3d93638e0c02e7 Mon Sep 17 00:00:00 2001 From: Peter Winskill Date: Tue, 16 Aug 2022 08:53:35 +0100 Subject: [PATCH 06/11] Record pmc n treated before drug efficacy draw --- R/pmc.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/pmc.R b/R/pmc.R index d11cffb5..108aa6ec 100644 --- a/R/pmc.R +++ b/R/pmc.R @@ -37,13 +37,14 @@ create_pmc_process <- function( in_age <- which(age %in% parameters$pmc_ages) target <- in_age[sample_intervention(in_age, 'pmc', coverage, correlations)] + renderer$render('n_pmc_treated', length(target), timestep) + successful_treatments <- bernoulli( length(target), parameters$drug_efficacy[[drug]] ) to_move <- individual::Bitset$new(parameters$human_population) to_move$insert(target[successful_treatments]) - renderer$render('n_pmc_treated', to_move$size(), timestep) if (to_move$size() > 0) { # Move Diseased From 6f44599abf55ce6cf048ea89d6c7b79a4b7b7d15 Mon Sep 17 00:00:00 2001 From: Peter Winskill Date: Tue, 16 Aug 2022 11:20:20 +0100 Subject: [PATCH 07/11] Bump version --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 35ec20f4..64df8e89 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: malariasimulation Title: An individual based model for malaria -Version: 1.4.1 +Version: 1.4.2 Authors@R: c( person( given = "Giovanni", From 0136fa12130876d3391f05d4b6b6d7ed8af588cc Mon Sep 17 00:00:00 2001 From: Peter Winskill Date: Tue, 30 Aug 2022 16:58:10 +0100 Subject: [PATCH 08/11] Add MDA default render value --- R/mda_processes.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/mda_processes.R b/R/mda_processes.R index 58ef6d31..a127bdc3 100644 --- a/R/mda_processes.R +++ b/R/mda_processes.R @@ -25,6 +25,7 @@ create_mda_listeners <- function( parameters, renderer ) { + renderer$set_default(paste0('n_', int_name, '_treated'), 0) function(timestep) { time_index = which(timesteps == timestep) coverage <- coverages[[time_index]] From 78e6613852afccad4c75871fe8cc506f227b70f9 Mon Sep 17 00:00:00 2001 From: Peter Winskill Date: Mon, 26 Sep 2022 08:02:55 +0100 Subject: [PATCH 09/11] Set default PMC dose rendering to 0 --- R/pmc.R | 3 ++- tests/testthat/test-pmc.R | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/R/pmc.R b/R/pmc.R index 108aa6ec..429bf7d2 100644 --- a/R/pmc.R +++ b/R/pmc.R @@ -21,7 +21,8 @@ create_pmc_process <- function( coverages, timesteps, drug -) { +){ + renderer$set_default('n_pmc_treated', 0) function(timestep) { timestep_index <- match_timestep(ts = timesteps, t = timestep) if(timestep_index == 0){ diff --git a/tests/testthat/test-pmc.R b/tests/testthat/test-pmc.R index 3b9d8083..7388d4e0 100644 --- a/tests/testthat/test-pmc.R +++ b/tests/testthat/test-pmc.R @@ -72,7 +72,7 @@ test_that("pmc gives drugs to correct ages", { # Three treatments given expect_equal(renderer$to_dataframe(), data.frame(timestep = 1:10, - n_pmc_treated = c(rep(NA, 9), 3))) + n_pmc_treated = c(rep(0, 9), 3))) # Individuals 3 and 5, are correct age and in D or A states expect_bitset_update( From ff1304c5990b8073535a5372719c19511be9b7d9 Mon Sep 17 00:00:00 2001 From: Peter Winskill Date: Mon, 26 Sep 2022 08:05:34 +0100 Subject: [PATCH 10/11] Bump version --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 64df8e89..622756f5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: malariasimulation Title: An individual based model for malaria -Version: 1.4.2 +Version: 1.4.3 Authors@R: c( person( given = "Giovanni", From c8ac7b18e3aa98074f52266f46ce7397809868e6 Mon Sep 17 00:00:00 2001 From: Peter Winskill Date: Thu, 8 Dec 2022 08:52:19 +0000 Subject: [PATCH 11/11] Update news for 1.4 --- NEWS.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/NEWS.md b/NEWS.md index d617f7b3..71dcc998 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,10 @@ +# malariasimulation 1.4.0 + + * Treatment number rendering for all treatments not just effective + * Default rendering for drug-based interventions + * Bed nets and IRS continue post individual's death + * ITN scheduling does not overwrite on receipt of >1 net + # malariasimulation 1.3.0 * Custom demography