Skip to content

Commit 0368ad2

Browse files
authored
enhancement of renaming abm (#874)
1 parent 08c1753 commit 0368ad2

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

cpp/examples/abm_history_object.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ int main()
6161
{
6262
// This is a minimal example with children and adults < 60y.
6363
// We divided them into 4 different age groups, which are defined as follows:
64-
size_t num_age_groups = 4;
64+
const size_t num_age_groups = 4;
6565
const auto age_group_0_to_4 = mio::AgeGroup(0);
6666
const auto age_group_5_to_14 = mio::AgeGroup(1);
6767
const auto age_group_15_to_34 = mio::AgeGroup(2);

cpp/models/abm/household.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class HouseholdMember
6868
*/
6969
void set_age_weight(mio::AgeGroup age_group, int weight)
7070
{
71-
assert((size_t)age_group.size < m_age_weights.numel());
71+
assert(age_group < m_age_weights.size<mio::AgeGroup>());
7272
m_age_weights[age_group] = weight;
7373
}
7474

cpp/models/abm/infection.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Infection::Infection(Person::RandomNumberGenerator& rng, VirusVariant virus, Age
3232
: m_virus_variant(virus)
3333
, m_detected(detected)
3434
{
35-
assert((size_t)age.size < (size_t)params.get_num_groups());
35+
assert(age.get() < params.get_num_groups());
3636
m_viral_load.start_date = draw_infection_course(rng, age, params, init_date, init_state, latest_exposure);
3737

3838
auto vl_params = params.get<ViralLoadDistributions>()[{virus, age}];
@@ -116,7 +116,7 @@ TimePoint Infection::draw_infection_course(Person::RandomNumberGenerator& rng, A
116116
TimePoint init_date, InfectionState init_state,
117117
std::pair<ExposureType, TimePoint> latest_protection)
118118
{
119-
assert((size_t)age.size < (size_t)params.get_num_groups());
119+
assert(age.get() < params.get_num_groups());
120120
TimePoint start_date = draw_infection_course_backward(rng, age, params, init_date, init_state);
121121
draw_infection_course_forward(rng, age, params, init_date, init_state, latest_protection);
122122
return start_date;
@@ -126,7 +126,7 @@ void Infection::draw_infection_course_forward(Person::RandomNumberGenerator& rng
126126
const Parameters& params, TimePoint init_date, InfectionState start_state,
127127
std::pair<ExposureType, TimePoint> latest_exposure)
128128
{
129-
assert((size_t)age.size < (size_t)params.get_num_groups());
129+
assert(age.get() < params.get_num_groups());
130130
auto t = init_date;
131131
TimeSpan time_period{}; // time period for current infection state
132132
InfectionState next_state{start_state}; // next state to enter
@@ -214,7 +214,7 @@ TimePoint Infection::draw_infection_course_backward(Person::RandomNumberGenerato
214214
const Parameters& params, TimePoint init_date,
215215
InfectionState init_state)
216216
{
217-
assert((size_t)age.size < (size_t)params.get_num_groups());
217+
assert(age.get() < params.get_num_groups());
218218
auto start_date = init_date;
219219
TimeSpan time_period{}; // time period for current infection state
220220
InfectionState previous_state{init_state}; // next state to enter

cpp/models/abm/location.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Location Location::copy_location_without_persons(size_t num_agegroups)
5858
ScalarType Location::transmission_contacts_per_day(uint32_t cell_index, VirusVariant virus, AgeGroup age_receiver,
5959
size_t num_agegroups) const
6060
{
61-
assert((size_t)age_receiver.size < num_agegroups);
61+
assert(age_receiver.get() < num_agegroups);
6262
ScalarType prob = 0;
6363
for (uint32_t age_transmitter = 0; age_transmitter != num_agegroups; ++age_transmitter) {
6464
prob += m_cells[cell_index].m_cached_exposure_rate_contacts[{virus, static_cast<AgeGroup>(age_transmitter)}] *

cpp/models/abm/world.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ LocationId World::add_location(LocationType type, uint32_t num_cells)
4545

4646
Person& World::add_person(const LocationId id, AgeGroup age)
4747
{
48-
assert((size_t)age.size < (size_t)parameters.get_num_groups());
48+
assert(age.get() < parameters.get_num_groups());
4949
uint32_t person_id = static_cast<uint32_t>(m_persons.size());
5050
m_persons.push_back(std::make_unique<Person>(m_rng, get_individualized_location(id), age, person_id));
5151
auto& person = *m_persons.back();

cpp/tests/abm_helpers.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ mio::abm::Person make_test_person(mio::abm::Location& location, mio::AgeGroup ag
2525
mio::abm::InfectionState infection_state, mio::abm::TimePoint t,
2626
mio::abm::Parameters params)
2727
{
28-
assert((size_t)age.size < (size_t)params.get_num_groups());
28+
assert(age.get() < params.get_num_groups());
2929
auto rng = mio::RandomNumberGenerator();
3030
mio::abm::Person p = mio::abm::Person(rng, location, age);
3131
if (infection_state != mio::abm::InfectionState::Susceptible) {
@@ -39,7 +39,7 @@ mio::abm::Person make_test_person(mio::abm::Location& location, mio::AgeGroup ag
3939
mio::abm::Person& add_test_person(mio::abm::World& world, mio::abm::LocationId loc_id, mio::AgeGroup age,
4040
mio::abm::InfectionState infection_state, mio::abm::TimePoint t)
4141
{
42-
assert((size_t)age.size < (size_t)world.parameters.get_num_groups());
42+
assert(age.get() < world.parameters.get_num_groups());
4343
mio::abm::Person& p = world.add_person(loc_id, age);
4444
if (infection_state != mio::abm::InfectionState::Susceptible) {
4545
auto rng_p = mio::abm::Person::RandomNumberGenerator(world.get_rng(), p);

0 commit comments

Comments
 (0)