From ad2692a40097c6ef798bc307f705ef0c7e8e2d1d Mon Sep 17 00:00:00 2001 From: Gilles Date: Mon, 8 Apr 2024 12:13:23 +0200 Subject: [PATCH] Changement bash: line 1: T: command not found bash: line 1: ^G: command not found bash: line 1: G: command not found bash: line 1: Execute: command not found --- bdm.json | 6 ++- src/.vscode/settings.json | 53 +++++++++++++++++++++++ src/analyze.cc | 14 ++++++ src/hiv-ops.cc | 2 +- src/person-behavior.h | 32 ++++++++++++++ src/person.h | 8 +++- src/population-initialization.cc | 1 + src/sim-param.h | 74 ++++++++++++++++++-------------- 8 files changed, 155 insertions(+), 35 deletions(-) create mode 100644 src/.vscode/settings.json diff --git a/bdm.json b/bdm.json index 59b1547..a72d76c 100644 --- a/bdm.json +++ b/bdm.json @@ -1,7 +1,11 @@ { "bdm::hiv_malawi::SimParam": { - "number_of_iterations": 3, + "number_of_iterations": 26, "initial_population_size": 530200, "initial_prevalence": 18e-4 + + }, + "bdm::Param": { + "random_seed" : 2003 } } diff --git a/src/.vscode/settings.json b/src/.vscode/settings.json new file mode 100644 index 0000000..cd7bc8a --- /dev/null +++ b/src/.vscode/settings.json @@ -0,0 +1,53 @@ +{ + "files.associations": { + "array": "cpp", + "atomic": "cpp", + "bit": "cpp", + "*.tcc": "cpp", + "cctype": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "compare": "cpp", + "concepts": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "deque": "cpp", + "string": "cpp", + "unordered_map": "cpp", + "vector": "cpp", + "exception": "cpp", + "algorithm": "cpp", + "functional": "cpp", + "iterator": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "numeric": "cpp", + "random": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "utility": "cpp", + "fstream": "cpp", + "initializer_list": "cpp", + "iomanip": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "limits": "cpp", + "new": "cpp", + "numbers": "cpp", + "ostream": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "cinttypes": "cpp", + "typeinfo": "cpp" + } +} \ No newline at end of file diff --git a/src/analyze.cc b/src/analyze.cc index 1f2273d..2c2021b 100644 --- a/src/analyze.cc +++ b/src/analyze.cc @@ -85,6 +85,20 @@ void DefineAndRegisterCollectors() { }; ts->AddCollector("acute_agents", new Counter(acute), get_year); + // Infected for location1 + auto acute1 = [](Agent* a) { + auto* person = bdm_static_cast(a); + return person->IsAcute() && person-> Isloc1(); + }; + ts->AddCollector("acute_agents loc1", new Counter(acute1), get_year); + +// Infected for location2 + auto acute2 = [](Agent* a) { + auto* person = bdm_static_cast(a); + return person->IsAcute() && person-> Isloc2(); + }; + ts->AddCollector("acute_agents loc2", new Counter(acute2), get_year); + // AM: Define how to count the infected acute male individuals auto acute_male_agents = [](Agent* a) { auto* person = bdm_static_cast(a); diff --git a/src/hiv-ops.cc b/src/hiv-ops.cc index 6c0bd28..00c3102 100644 --- a/src/hiv-ops.cc +++ b/src/hiv-ops.cc @@ -152,7 +152,7 @@ void GetOlderOperation::ProcessAgent(Agent* agent) { } } if(person->newly_infected==true){ - std::cout << "W"; + //std::cout << "W"; person->newly_infected=false; } // Possibly die - if not, just get older diff --git a/src/person-behavior.h b/src/person-behavior.h index 0f9d64b..a3a070f 100644 --- a/src/person-behavior.h +++ b/src/person-behavior.h @@ -165,6 +165,7 @@ struct MatingBehaviour : public Behavior { // Scenario healthy male has intercourse with infected acute female if (mate->state_ == GemsState::kAcute && person->state_ == GemsState::kHealthy && + mate->newly_infected == false && random->Uniform() < (1.0 - pow(1.0 - sparam->infection_probability_acute_fm, no_acts))) { @@ -172,6 +173,7 @@ struct MatingBehaviour : public Behavior { person->transmission_type_ = TransmissionType::kCasualPartner; person->infection_origin_state_ = mate->state_; person->infection_origin_sb_ = mate->social_behaviour_factor_; + //std::cout << "C"; // AM: Add MatingBehaviour only when male gets infected /*person->AddBehavior(new MatingBehaviour()); std::cout << "This should not currently happen: AddBehavior(new @@ -180,6 +182,7 @@ struct MatingBehaviour : public Behavior { // Scenario healthy male has intercourse with infected chronic female else if (mate->state_ == GemsState::kChronic && person->state_ == GemsState::kHealthy && + mate->newly_infected == false && random->Uniform() < (1.0 - pow(1.0 - sparam->infection_probability_chronic_fm, no_acts))) { @@ -187,6 +190,7 @@ struct MatingBehaviour : public Behavior { person->transmission_type_ = TransmissionType::kCasualPartner; person->infection_origin_state_ = mate->state_; person->infection_origin_sb_ = mate->social_behaviour_factor_; + //std::cout << "c"; // AM: Add MatingBehaviour only when male gets infected /*person->AddBehavior(new MatingBehaviour()); std::cout << "This should not currently happen: AddBehavior(new @@ -195,6 +199,7 @@ struct MatingBehaviour : public Behavior { // Scenario healthy male has intercourse with infected treated female else if (mate->state_ == GemsState::kTreated && person->state_ == GemsState::kHealthy && + mate->newly_infected == false && random->Uniform() < (1.0 - pow(1.0 - sparam->infection_probability_treated_fm, no_acts))) { @@ -211,6 +216,7 @@ struct MatingBehaviour : public Behavior { // female else if (mate->state_ == GemsState::kFailing && person->state_ == GemsState::kHealthy && + mate->newly_infected == false && random->Uniform() < (1.0 - pow(1.0 - sparam->infection_probability_failing_fm, no_acts))) { @@ -226,6 +232,7 @@ struct MatingBehaviour : public Behavior { // Scenario infected acute male has intercourse with healthy female else if (mate->state_ == GemsState::kHealthy && person->state_ == GemsState::kAcute && + person->newly_infected == false && random->Uniform() < (1.0 - pow(1.0 - sparam->infection_probability_acute_mf, no_acts))) { @@ -233,9 +240,11 @@ struct MatingBehaviour : public Behavior { mate->transmission_type_ = TransmissionType::kCasualPartner; mate->infection_origin_state_ = person->state_; mate->infection_origin_sb_ = person->social_behaviour_factor_; + //std::cout << "C"; } // Scenario infected chronic male has intercourse with healthy female else if (mate->state_ == GemsState::kHealthy && person->state_ == GemsState::kChronic && + person->newly_infected == false && random->Uniform() < (1.0 - pow(1.0 - sparam->infection_probability_chronic_mf, no_acts))) { @@ -243,9 +252,11 @@ struct MatingBehaviour : public Behavior { mate->transmission_type_ = TransmissionType::kCasualPartner; mate->infection_origin_state_ = person->state_; mate->infection_origin_sb_ = person->social_behaviour_factor_; + //std::cout << "c"; } // Scenario infected treated male has intercourse with healthy female else if (mate->state_ == GemsState::kHealthy && person->state_ == GemsState::kTreated && + person->newly_infected == false && random->Uniform() < (1.0 - pow(1.0 - sparam->infection_probability_treated_mf, no_acts))) { @@ -257,6 +268,7 @@ struct MatingBehaviour : public Behavior { // healthy female else if (mate->state_ == GemsState::kHealthy && person->state_ == GemsState::kFailing && + person->newly_infected == false && random->Uniform() < (1.0 - pow(1.0 - sparam->infection_probability_failing_mf, no_acts))) { @@ -345,12 +357,15 @@ struct RegularMatingBehaviour : public Behavior { // partner if (person->partner_->state_ == GemsState::kAcute && person->state_ == GemsState::kHealthy && + // person->partner_->newly_infected == false && random->Uniform() < (1.0 - pow(1.0 - sparam->infection_probability_acute_fm, sparam->no_regular_acts_mean[year_index]))) { person->state_ = GemsState::kAcute; + person->newly_infected = true; person->transmission_type_ = TransmissionType::kRegularPartner; person->infection_origin_state_ = person->partner_->state_; + //std::cout << "R"; // AM: Add MatingBehaviour only when infected // person->AddBehavior(new MatingBehaviour()); } @@ -358,12 +373,15 @@ struct RegularMatingBehaviour : public Behavior { // partner else if (person->partner_->state_ == GemsState::kChronic && person->state_ == GemsState::kHealthy && + //person->partner_->newly_infected == false && random->Uniform() < (1.0 - pow(1.0 - sparam->infection_probability_chronic_fm, sparam->no_regular_acts_mean[year_index]))) { person->state_ = GemsState::kAcute; + person->newly_infected = true; person->transmission_type_ = TransmissionType::kRegularPartner; person->infection_origin_state_ = person->partner_->state_; + //std::cout << "r"; // AM: Add MatingBehaviour only when infected // person->AddBehavior(new MatingBehaviour()); } @@ -371,10 +389,12 @@ struct RegularMatingBehaviour : public Behavior { // partner else if (person->partner_->state_ == GemsState::kTreated && person->state_ == GemsState::kHealthy && + //person->partner_->newly_infected == false && random->Uniform() < (1.0 - pow(1.0 - sparam->infection_probability_treated_fm, sparam->no_regular_acts_mean[year_index]))) { person->state_ = GemsState::kAcute; + person->newly_infected = true; person->transmission_type_ = TransmissionType::kRegularPartner; person->infection_origin_state_ = person->partner_->state_; // AM: Add MatingBehaviour only when infected @@ -384,10 +404,12 @@ struct RegularMatingBehaviour : public Behavior { // female partner else if (person->partner_->state_ == GemsState::kFailing && person->state_ == GemsState::kHealthy && + //person->partner_->newly_infected == false && random->Uniform() < (1.0 - pow(1.0 - sparam->infection_probability_failing_fm, sparam->no_regular_acts_mean[year_index]))) { person->state_ = GemsState::kAcute; + person->newly_infected = true; person->transmission_type_ = TransmissionType::kRegularPartner; person->infection_origin_state_ = person->partner_->state_; // AM: Add MatingBehaviour only when infected @@ -397,32 +419,40 @@ struct RegularMatingBehaviour : public Behavior { // partner else if (person->partner_->state_ == GemsState::kHealthy && person->state_ == GemsState::kAcute && + //person->newly_infected == false && random->Uniform() < (1.0 - pow(1.0 - sparam->infection_probability_acute_mf, sparam->no_regular_acts_mean[year_index]))) { person->partner_->state_ = GemsState::kAcute; + person->partner_->newly_infected = true; person->partner_->transmission_type_ = TransmissionType::kRegularPartner; person->partner_->infection_origin_state_ = person->state_; + //std::cout << "R"; } // Scenario infected chronic male has intercourse with healthy female // partner else if (person->partner_->state_ == GemsState::kHealthy && person->state_ == GemsState::kChronic && + //person->newly_infected == false && random->Uniform() < (1.0 - pow(1.0 - sparam->infection_probability_chronic_mf, sparam->no_regular_acts_mean[year_index]))) { person->partner_->state_ = GemsState::kAcute; + person->partner_->newly_infected = true; person->partner_->transmission_type_ = TransmissionType::kRegularPartner; person->partner_->infection_origin_state_ = person->state_; + //std::cout << "r"; } // Scenario infected treated male has intercourse with healthy female // partner else if (person->partner_->state_ == GemsState::kHealthy && person->state_ == GemsState::kTreated && + //person->newly_infected == false && random->Uniform() < (1.0 - pow(1.0 - sparam->infection_probability_treated_mf, sparam->no_regular_acts_mean[year_index]))) { person->partner_->state_ = GemsState::kAcute; + person->partner_->newly_infected = true; person->partner_->transmission_type_ = TransmissionType::kRegularPartner; person->partner_->infection_origin_state_ = person->state_; @@ -430,10 +460,12 @@ struct RegularMatingBehaviour : public Behavior { // healthy female partner else if (person->partner_->state_ == GemsState::kHealthy && person->state_ == GemsState::kFailing && + //person->newly_infected == false && random->Uniform() < (1.0 - pow(1.0 - sparam->infection_probability_failing_mf, sparam->no_regular_acts_mean[year_index]))) { person->partner_->state_ = GemsState::kAcute; + person->partner_->newly_infected = true; person->partner_->transmission_type_ = TransmissionType::kRegularPartner; person->partner_->infection_origin_state_ = person->state_; diff --git a/src/person.h b/src/person.h index 4e897fe..94490a4 100644 --- a/src/person.h +++ b/src/person.h @@ -82,7 +82,9 @@ class Person : public Agent { // for regular partnership are then indexed, select the compound category of // their partner, and are mapped to females corresponding to the selected // category - bool seek_regular_partnership_; + bool seek_regular_partnership_ = true; + // Prevent newly infected to move on to next state the same year of infection + bool newly_infected = false; // Number of casual partners int no_casual_partners_; // Tag to track if this person will be removed at the end of the iteration @@ -194,6 +196,10 @@ class Person : public Agent { bool IsMale() { return sex_ == Sex::kMale; } // Returns True if the agent is a female bool IsFemale() { return sex_ == Sex::kFemale; } + // Returns True if the agent is in location 1 + bool Isloc1() { return location_ == 1; } +// Returns True if the agent is in location 2 + bool Isloc2() { return location_ == 8; } // AM - Get Age Category from 0 to no_age_categories. 5-years interval // categories from min_age. diff --git a/src/population-initialization.cc b/src/population-initialization.cc index 903026a..44daf43 100644 --- a/src/population-initialization.cc +++ b/src/population-initialization.cc @@ -209,6 +209,7 @@ auto CreatePerson(Random* random_generator, const SimParam* sparam) { person->AddBehavior(new MatingBehaviour()); }*/ person->AddBehavior(new MatingBehaviour()); + //person->AddBehavior(new RegularPartnershipBehaviour()); person->AddBehavior(new RegularMatingBehaviour()); person->AddBehavior(new RegularPartnershipBehaviour()); } diff --git a/src/sim-param.h b/src/sim-param.h index 05cd518..40aeead 100644 --- a/src/sim-param.h +++ b/src/sim-param.h @@ -63,18 +63,18 @@ class SimParam : public ParamGroup { // Mortality rate by age. Size(mortality_rate_by_age) must be equal to // 1+size(mortality_rate_age_transition). std::vector mortality_rate_age_transition{15, 50, 90}; - std::vector mortality_rate_by_age{0.0, 0.0, 0.0, 0.0}; //0.01, 0.005, 0.05, 1.0}; + std::vector mortality_rate_by_age{0.01, 0.005, 0.05, 1.0}; // Test - No death // std::vector mortality_rate_by_age{0.0, 0.0, 0.0, 0.0}; // HIV-related mortality. For Healthy, Acute, Chronic, Treated, Failing states - //std::vector hiv_mortality_rate{0.0, 0.0, 0.05, 0.01, 0.1}; + std::vector hiv_mortality_rate{0.0, 0.0, 0.05, 0.01, 0.1}; // Test - No death - std::vector hiv_mortality_rate{0.0, 0.0, 0.0, 0.0, 0.0}; + //std::vector hiv_mortality_rate{0.0, 0.0, 0.0, 0.0, 0.0}; // AM: Probability to migrate // TO DO AM: Make this probability dependent on the origin location? - float migration_probability = 0.0; //0.01; // 0.0; // No Mogration //0.01; + float migration_probability = 0.01; // 0.0; // No Mogration // // AM: Migration year index const std::vector migration_year_transition{1960}; // AM: Migration Matrix. Year index x Location x Location @@ -96,11 +96,14 @@ class SimParam : public ParamGroup { // distribution. // Gaussian distribution defining the number of casual partners per year // depending on year (see no_mates_year_transition) and socio-behaviour - const std::vector> no_mates_mean /*{{40.0,80.0}, - {30.0,60.0}, - {20.0,40.0}};*/ - {{24, 95}, {22, 89}, {21, 83}, {20, 77}, {18, 71}, {16, 65}, {15, 59}, - {14, 53}, {12, 48}, {10, 42}, {9, 36}, {8, 30}, {6, 24}}; + const std::vector> no_mates_mean + // {0.0, 0.0}, {0.0, 0.0}, {0.0, 0.0}, {0.0, 0.0}, {0.0, 0.0}, + // {0.0, 0.0}, {0.0, 0.0}, {0.0, 0.0}, {0.0, 0.0}, {0.0, 0.0}, + // {0.0, 0.0}, {0.0, 0.0}, {0.0, 0.0}};/*{{40.0,80.0}, + // {30.0,60.0}, + // {20.0,40.0}};*/ + {{24, 24}, {24, 24}, {24, 24}, {24, 24}, {24, 24}, {24, 24}, {24, 24}, + {24, 24}, {24, 24}, {24, 24}, {24, 24}, {24, 24}, {24, 24}}; //{{20.0, 70.0}, {15.0, 53.0}, {10.0, 35.0}}; //{{2.0, 8.0}, {1.0, 4.0}, {1.0, 4.0}}; @@ -135,14 +138,14 @@ class SimParam : public ParamGroup { // Mean number of sexual acts with regular partner per year. // const float no_regular_acts_mean = 50.0; // 150; - const std::vector no_regular_acts_mean{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + const std::vector no_regular_acts_mean{48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48}; //50, 47, 44, 41, 38, 34, 31, // 28, 25, 22, 19, 16, 12}; //{90, 84, 79, 73, 68, 62, 56, 51, 45, 39, 34, 28, 22}; // AM: Probability of getting infected depends on // 1) disease state, 2) sex of partners Male-to-female - float coef_infection_probability = 0; + float coef_infection_probability = 2; float infection_probability_acute_mf = 9.3e-3 * coef_infection_probability; float infection_probability_chronic_mf = 1.9e-3 * coef_infection_probability; float infection_probability_treated_mf = 1.3e-4 * coef_infection_probability; @@ -173,12 +176,14 @@ class SimParam : public ParamGroup { }, { // sb=1 (high risk) + // {0.0, 1.0}, // sex=0 (kMale) + // {0.0, 1.0} // sex=1 (kFemale) {0.04, 0.96}, // sex=0 (kMale) {0.1, 0.9} // sex=1 (kFemale) }}; // Number of locations - int nb_locations = 1; //Location::kLocLast; // 1; //Location::kLocLast; + int nb_locations = Location::kLocLast; //1; // // AM: Location Mixing Matrix used for casual partner selection. // Location->Location @@ -218,20 +223,25 @@ class SimParam : public ParamGroup { // + p_Chronic(|HIV+) + p_Treated(|HIV+) + p_Failing(|HIV+) These probablities // involve 15-49 years old agents, located in seed districts. 1/5 of HIV // infected are in acute phase, others are chronic. - std::vector initial_infection_probability{0.2, 1.0, 1.0, 1.0}; + std::vector initial_infection_probability{1.0, 1.0, 1.0, 1.0}; // Initial probability to be healthy for 15-49 years old in seed districts float initial_healthy_probability; // Districts where HIV infected agents are initially located const std::vector seed_districts{ - true}; - // false, true, false, false, false, false, false, false, false, false, - // true, false, true, false, true, true, true, true, true, true, - // true, true, true, true, true, true, true, true, false}; + //true}; + // false, true, false, false, false, false, false, false, false, false, + // false, false, false, false, false, false, false, false, false, false, + // false, false, false, false, false, false, false, false, false}; + + + false, true, false, false, false, false, false, false, false, false, + true, false, true, false, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, false}; // One Location - /*const std::vector seed_districts{ - true, false};*/ + //const std::vector seed_districts{ + // true, false}; // Parameter 0.18 is chosen because our GiveBirth Behaviour is based on a // Bernoulli experiment. A binomial distribuition peaks at around 6 for 25 @@ -239,7 +249,7 @@ class SimParam : public ParamGroup { // typical birth rate in the region. We substracted 0.06 to account for child // motability and reach a realistic demographic development from 1960-2020. // Parameter 0.21 is used in Janne's R implementation. - float give_birth_probability = 0.0; //0.188; // 0.18 + float give_birth_probability = 0.188; // 0.18 // AM : Probability for agent to be infected at birth, if its mother is // infected and treated @@ -262,8 +272,8 @@ class SimParam : public ParamGroup { // depending on year (see sociobehavioural_risk_year_transition) and health // state (Healthy, Acute, Chronic, Treated, Failing) const std::vector> sociobehavioural_risk_probability{ - {0.0, 0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 0.0, 0.0}}; - //{0.05, 0.5, 0.5, 0.5, 0.5}, {0.05, 0.05, 0.05, 0.05, 0.05}}; + //{0.0, 0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 0.0, 0.0}}; + {0.05, 0.5, 0.5, 0.5, 0.5}, {0.05, 0.05, 0.05, 0.05, 0.05}}; float biomedical_risk_probability = 0.0; //0.05; @@ -272,22 +282,22 @@ class SimParam : public ParamGroup { // x2 (6-10). Usually, these vectors are given in probabilities p1, p2, p3, .. // Here: x1 = p1, x2 = p1+p2, x3 = p1+p2+p3, .. const std::vector male_age_distribution{ - 0.156, 0.312, 0.468, 0.541, 0.614, 0.687, 0.76, 0.833, 0.906, - 0.979, 0.982, 0.985, 0.988, 0.991, 0.994, 0.997, 1}; + 0.156, 0.312, 0.468, 0.544, 0.62, 0.696, 0.772, 0.848, 0.924, + 1, 1, 1, 1, 1, 1, 1, 1}; const std::vector female_age_distribution{ - 0.156, 0.312, 0.468, 0.54, 0.612, 0.684, 0.756, 0.828, 0.9, - 0.972, 0.976, 0.98, 0.984, 0.988, 0.992, 0.996, 1}; + 0.156, 0.312, 0.468, 0.544, 0.62, 0.696, 0.772, 0.848, 0.924, + 1, 1, 1, 1, 1, 1, 1, 1}; // Location distribution for population initialization, same logic as for age // distribution. const std::vector location_distribution{ - 1}; - // 0.012, 0.03, 0.031, 0.088, 0.104, 0.116, 0.175, 0.228, 0.273, 0.4, - // 0.431, 0.453, 0.498, 0.517, 0.54, 0.569, 0.645, 0.679, 0.701, 0.736, - // 0.794, 0.834, 0.842, 0.86, 0.903, 0.925, 0.995, 1, 1}; + //1}; + 0.012, 0.03, 0.031, 0.088, 0.104, 0.116, 0.175, 0.228, 0.273, 0.4, + 0.431, 0.453, 0.498, 0.517, 0.54, 0.569, 0.645, 0.679, 0.701, 0.736, + 0.794, 0.834, 0.842, 0.86, 0.903, 0.925, 0.995, 1, 1}; // One Location - /*const std::vector location_distribution{ - 1.0, 1.0};*/ + // const std::vector location_distribution{ + // 1.0, 1.0}; /////////////////////////////////////////////////////////////////////////// // Initalizer Functions