Skip to content

Commit

Permalink
fixed a bug with chips testing not correctly reset at the end of a ru…
Browse files Browse the repository at this point in the history
…n, causing crashes to the code
  • Loading branch information
Franscesco Di Lauro committed Oct 1, 2024
1 parent 076059c commit 536fd80
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 ***************************/
Expand Down Expand Up @@ -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. */
Expand Down
2 changes: 1 addition & 1 deletion src/hiv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions src/interventions.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;ti<MAX_N_TIMESTEPS_PER_CHIPS_ROUND;ti++){
patch[p].chips_sample->number_to_see_per_timestep[g][ac][ti]=0;
}
}
}
}
Expand Down

0 comments on commit 536fd80

Please sign in to comment.