From 536fd8033f1a95d03b0eb05a12838f753cd05f3e Mon Sep 17 00:00:00 2001 From: Franscesco Di Lauro Date: Tue, 1 Oct 2024 13:58:26 +0100 Subject: [PATCH] fixed a bug with chips testing not correctly reset at the end of a run, causing crashes to the code --- src/constants.h | 12 ++++++------ src/hiv.c | 2 +- src/interventions.c | 5 +++-- src/memory.c | 5 +++++ 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/constants.h b/src/constants.h index cfc1f9d..79e9da5 100644 --- a/src/constants.h +++ b/src/constants.h @@ -107,9 +107,9 @@ #define WRITE_PARTNERSHIPS_AT_PC0 0 /* Generates Distr_n_lifetime_partners and Distr_n_partners_lastyear csv files. NEEDED FOR ReadAnnualOutputs-knitr.Rnw. */ -#define FOLLOW_INDIVIDUAL -1 //23727 // 30295 // 28101 // -1 // 1972 // 2727 // 267 // 4328 // if -1 then normal run, otherwise printing things and checking everything that happens to an individual with a certain ID +#define FOLLOW_INDIVIDUAL 0 //23727 // 30295 // 28101 // -1 // 1972 // 2727 // 267 // 4328 // if -1 then normal run, otherwise printing things and checking everything that happens to an individual with a certain ID -#define FOLLOW_PATCH 0 //1 +#define FOLLOW_PATCH 1 //1 #define WRITE_COST_EFFECTIVENESS_OUTPUT 0 /* Generates a new file cost_effectiveness_$.csv */ #define WRITE_TREATS_OUTPUT 0 // Generates output for aligning the model with that used in the TREATS clinical trial. @@ -139,11 +139,11 @@ gsl_rng * rng; #define MAX_N_YEARS 200 /* Maximum number of years the simulation will run for */ -#define T_ROLLOUT_CHIPS_EVERYWHERE 2050 /* When we want post-popart CHiPs to roll out in contaminating patches. */ +#define T_ROLLOUT_CHIPS_EVERYWHERE 2999 /* When we want post-popart CHiPs to roll out in contaminating patches. */ #define ROLL_OUT_CHIPS_INSIDE_PATCH 1 -#define T_STOP_ROLLOUT_CHIPS_INSIDE_PATCH 2018 /* When to stop roll out of CHiPs to inside patch */ +#define T_STOP_ROLLOUT_CHIPS_INSIDE_PATCH 2100 /* When to stop roll out of CHiPs to inside patch */ -#define ALLOW_COUNTERFACTUAL_ROLLOUT 0 /* Should post-PopART rollout of CHiPs be allowed in counterfactual simulations? Defaul is that it's switched off*/ +#define ALLOW_COUNTERFACTUAL_ROLLOUT 1 /* Should post-PopART rollout of CHiPs be allowed in counterfactual simulations? Defaul is that it's switched off*/ /************************************************************************/ /***************************** Settings ***************************/ @@ -311,7 +311,7 @@ extern const char RISK_GP_NAMES[N_RISK][5]; /* Decides if a cascade event (e.g. an HIV test) is from PopART or not. * If it is PopART then things happen faster (e.g. time to CD4 test is quicker), and * ART CD4 eligibility may be different. */ -#define NOTPOPART 0 +#define NOTPOPART990 #define POPART 1 #define NCHIPSROUNDS 3 /* Number of rounds of CHiPS visits. */ diff --git a/src/hiv.c b/src/hiv.c index 52a7e04..0108833 100644 --- a/src/hiv.c +++ b/src/hiv.c @@ -2271,7 +2271,7 @@ void draw_hiv_tests(parameters *param, age_list_struct *age_list, int year, // For each individual in that annual age group, schedule their first HIV test for(k = 0; k < age_list->age_list_by_gender[g]->number_per_age_group[aa]; k++){ // Only schedule tests for people who are not "HIV+ and aware of serostatus" or, after UTT implemented, for everyone including dropouts - if(age_list->age_list_by_gender[g]->age_group[aa][k]->ART_status == ARTNEG || (year<= param->COUNTRY_IMMEDIATE_ART_START && age_list->age_list_by_gender[g]->age_group[aa][k]->ART_status == ARTDROPOUT)){ + if(age_list->age_list_by_gender[g]->age_group[aa][k]->ART_status == ARTNEG || (year>= param->COUNTRY_IMMEDIATE_ART_START && age_list->age_list_by_gender[g]->age_group[aa][k]->ART_status == ARTDROPOUT)){ schedule_hiv_test_fixedtime(age_list->age_list_by_gender[g]->age_group[aa][k], param, year, cascade_events, n_cascade_events, size_cascade_events, diff --git a/src/interventions.c b/src/interventions.c index 9a23bdd..697b6cb 100644 --- a/src/interventions.c +++ b/src/interventions.c @@ -491,7 +491,6 @@ void carry_out_chips_visits_per_timestep(int t0, int t_step, patch_struct *patch } }else{ - /* Send the address (ie pointer) to this person. */ chips_visit_person(&(patch[p].individual_population[patch[p].chips_sample->list_ids_to_visit[g][ac][i]]), patch[p].cumulative_outputs, @@ -574,9 +573,11 @@ void chips_visit_person(individual *indiv, cumulative_outputs_struct *cumulative fflush(stdout); exit(1); } - if(indiv->cd4 == DUMMYVALUE){ printf("Trying to CHiPS visit a non-existent person %d %ld !!! Exiting\n", p, indiv->id); + + printf("at time t=%f\n",t); + printf("At chips round %d", chips_round); printf("LINE %d; FILE %s\n", __LINE__, __FILE__); fflush(stdout); exit(1); diff --git a/src/memory.c b/src/memory.c index 3586962..9733658 100644 --- a/src/memory.c +++ b/src/memory.c @@ -132,6 +132,11 @@ void reinitialize_arrays_to_default(int p, patch_struct *patch, all_partnerships output->NCHIPS_HIVAWARE[p][g][ac][chips_round] = 0; output->NCHIPS_ONART[p][g][ac][chips_round] = 0; output->NCHIPS_VS[p][g][ac][chips_round] = 0; + patch[p].chips_sample->number_to_visit[g][ac]=0; + int ti=0; + for (ti=0;tinumber_to_see_per_timestep[g][ac][ti]=0; + } } } }