Skip to content

Commit

Permalink
enhancement of renaming abm (#874)
Browse files Browse the repository at this point in the history
  • Loading branch information
xsaschako authored Dec 20, 2023
1 parent 08c1753 commit 0368ad2
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cpp/examples/abm_history_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ int main()
{
// This is a minimal example with children and adults < 60y.
// We divided them into 4 different age groups, which are defined as follows:
size_t num_age_groups = 4;
const size_t num_age_groups = 4;
const auto age_group_0_to_4 = mio::AgeGroup(0);
const auto age_group_5_to_14 = mio::AgeGroup(1);
const auto age_group_15_to_34 = mio::AgeGroup(2);
Expand Down
2 changes: 1 addition & 1 deletion cpp/models/abm/household.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class HouseholdMember
*/
void set_age_weight(mio::AgeGroup age_group, int weight)
{
assert((size_t)age_group.size < m_age_weights.numel());
assert(age_group < m_age_weights.size<mio::AgeGroup>());
m_age_weights[age_group] = weight;
}

Expand Down
8 changes: 4 additions & 4 deletions cpp/models/abm/infection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Infection::Infection(Person::RandomNumberGenerator& rng, VirusVariant virus, Age
: m_virus_variant(virus)
, m_detected(detected)
{
assert((size_t)age.size < (size_t)params.get_num_groups());
assert(age.get() < params.get_num_groups());
m_viral_load.start_date = draw_infection_course(rng, age, params, init_date, init_state, latest_exposure);

auto vl_params = params.get<ViralLoadDistributions>()[{virus, age}];
Expand Down Expand Up @@ -116,7 +116,7 @@ TimePoint Infection::draw_infection_course(Person::RandomNumberGenerator& rng, A
TimePoint init_date, InfectionState init_state,
std::pair<ExposureType, TimePoint> latest_protection)
{
assert((size_t)age.size < (size_t)params.get_num_groups());
assert(age.get() < params.get_num_groups());
TimePoint start_date = draw_infection_course_backward(rng, age, params, init_date, init_state);
draw_infection_course_forward(rng, age, params, init_date, init_state, latest_protection);
return start_date;
Expand All @@ -126,7 +126,7 @@ void Infection::draw_infection_course_forward(Person::RandomNumberGenerator& rng
const Parameters& params, TimePoint init_date, InfectionState start_state,
std::pair<ExposureType, TimePoint> latest_exposure)
{
assert((size_t)age.size < (size_t)params.get_num_groups());
assert(age.get() < params.get_num_groups());
auto t = init_date;
TimeSpan time_period{}; // time period for current infection state
InfectionState next_state{start_state}; // next state to enter
Expand Down Expand Up @@ -214,7 +214,7 @@ TimePoint Infection::draw_infection_course_backward(Person::RandomNumberGenerato
const Parameters& params, TimePoint init_date,
InfectionState init_state)
{
assert((size_t)age.size < (size_t)params.get_num_groups());
assert(age.get() < params.get_num_groups());
auto start_date = init_date;
TimeSpan time_period{}; // time period for current infection state
InfectionState previous_state{init_state}; // next state to enter
Expand Down
2 changes: 1 addition & 1 deletion cpp/models/abm/location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Location Location::copy_location_without_persons(size_t num_agegroups)
ScalarType Location::transmission_contacts_per_day(uint32_t cell_index, VirusVariant virus, AgeGroup age_receiver,
size_t num_agegroups) const
{
assert((size_t)age_receiver.size < num_agegroups);
assert(age_receiver.get() < num_agegroups);
ScalarType prob = 0;
for (uint32_t age_transmitter = 0; age_transmitter != num_agegroups; ++age_transmitter) {
prob += m_cells[cell_index].m_cached_exposure_rate_contacts[{virus, static_cast<AgeGroup>(age_transmitter)}] *
Expand Down
2 changes: 1 addition & 1 deletion cpp/models/abm/world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ LocationId World::add_location(LocationType type, uint32_t num_cells)

Person& World::add_person(const LocationId id, AgeGroup age)
{
assert((size_t)age.size < (size_t)parameters.get_num_groups());
assert(age.get() < parameters.get_num_groups());
uint32_t person_id = static_cast<uint32_t>(m_persons.size());
m_persons.push_back(std::make_unique<Person>(m_rng, get_individualized_location(id), age, person_id));
auto& person = *m_persons.back();
Expand Down
4 changes: 2 additions & 2 deletions cpp/tests/abm_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ mio::abm::Person make_test_person(mio::abm::Location& location, mio::AgeGroup ag
mio::abm::InfectionState infection_state, mio::abm::TimePoint t,
mio::abm::Parameters params)
{
assert((size_t)age.size < (size_t)params.get_num_groups());
assert(age.get() < params.get_num_groups());
auto rng = mio::RandomNumberGenerator();
mio::abm::Person p = mio::abm::Person(rng, location, age);
if (infection_state != mio::abm::InfectionState::Susceptible) {
Expand All @@ -39,7 +39,7 @@ mio::abm::Person make_test_person(mio::abm::Location& location, mio::AgeGroup ag
mio::abm::Person& add_test_person(mio::abm::World& world, mio::abm::LocationId loc_id, mio::AgeGroup age,
mio::abm::InfectionState infection_state, mio::abm::TimePoint t)
{
assert((size_t)age.size < (size_t)world.parameters.get_num_groups());
assert(age.get() < world.parameters.get_num_groups());
mio::abm::Person& p = world.add_person(loc_id, age);
if (infection_state != mio::abm::InfectionState::Susceptible) {
auto rng_p = mio::abm::Person::RandomNumberGenerator(world.get_rng(), p);
Expand Down

0 comments on commit 0368ad2

Please sign in to comment.