Skip to content

Commit

Permalink
Merge branch 'yearly-gilles' of https://github.com/BioDynaMo/hiv_malawi
Browse files Browse the repository at this point in the history
… into yearly
  • Loading branch information
GillesCattani committed Apr 8, 2024
2 parents b5f2acd + ad2692a commit 11c4b99
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 35 deletions.
6 changes: 5 additions & 1 deletion bdm.json
Original file line number Diff line number Diff line change
@@ -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
}
}
53 changes: 53 additions & 0 deletions src/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
14 changes: 14 additions & 0 deletions src/analyze.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,20 @@ void DefineAndRegisterCollectors() {
};
ts->AddCollector("acute_agents", new Counter<double>(acute), get_year);

// Infected for location1
auto acute1 = [](Agent* a) {
auto* person = bdm_static_cast<Person*>(a);
return person->IsAcute() && person-> Isloc1();
};
ts->AddCollector("acute_agents loc1", new Counter<double>(acute1), get_year);

// Infected for location2
auto acute2 = [](Agent* a) {
auto* person = bdm_static_cast<Person*>(a);
return person->IsAcute() && person-> Isloc2();
};
ts->AddCollector("acute_agents loc2", new Counter<double>(acute2), get_year);

// AM: Define how to count the infected acute male individuals
auto acute_male_agents = [](Agent* a) {
auto* person = bdm_static_cast<Person*>(a);
Expand Down
2 changes: 1 addition & 1 deletion src/hiv-ops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 32 additions & 0 deletions src/person-behavior.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,15 @@ 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))) {
person->state_ = GemsState::kAcute;
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
Expand All @@ -180,13 +182,15 @@ 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))) {
person->state_ = GemsState::kAcute;
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
Expand All @@ -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))) {
Expand All @@ -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))) {
Expand All @@ -226,26 +232,31 @@ 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))) {
mate->state_ = GemsState::kAcute;
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))) {
mate->state_ = GemsState::kAcute;
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))) {
Expand All @@ -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))) {
Expand Down Expand Up @@ -345,36 +357,44 @@ 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());
}
// Scenario healthy male has intercourse with infected chronic female
// 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());
}
// Scenario healthy male has intercourse with infected treated female
// 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
Expand All @@ -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
Expand All @@ -397,43 +419,53 @@ 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_;
} // Scenario infected failing treatment male has intercourse with
// 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_;
Expand Down
8 changes: 7 additions & 1 deletion src/person.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/population-initialization.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
Loading

0 comments on commit 11c4b99

Please sign in to comment.