Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cpp/benchmarks/abm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ mio::abm::Simulation<> make_simulation(size_t num_persons, std::initializer_list
//some % of people are infected, large enough to have some infection activity without everyone dying
auto pct_infected = 0.05;
if (mio::UniformDistribution<ScalarType>::get_instance()(prng, 0.0, 1.0) < pct_infected) {
auto state = mio::abm::InfectionState(
mio::UniformIntDistribution<int>::get_instance()(prng, 1, int(mio::abm::InfectionState::Count) - 1));
auto state = mio::abm::SymptomState(
mio::UniformIntDistribution<int>::get_instance()(prng, 1, int(mio::abm::SymptomState::Count) - 1));
auto infection = mio::abm::Infection(prng, mio::abm::VirusVariant::Wildtype, person.get_age(),
model.parameters, mio::abm::TimePoint(0), state);
person.add_new_infection(std::move(infection));
Expand Down Expand Up @@ -107,7 +107,7 @@ mio::abm::Simulation<> make_simulation(size_t num_persons, std::initializer_list
});
auto random_criteria = [&]() {
auto random_ages = sample(ages, 2);
auto random_states = std::vector<mio::abm::InfectionState>(0);
auto random_states = std::vector<mio::abm::SymptomState>(0);
return mio::abm::TestingCriteria(random_ages, random_states);
};

Expand Down
10 changes: 5 additions & 5 deletions cpp/examples/abm_history_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ int main()
auto model = mio::abm::Model(num_age_groups);
mio::ParameterDistributionLogNormal log_norm(4., 1.);
// Set same infection parameter for all age groups. For example, the incubation period is log normally distributed with parameters 4 and 1.
model.parameters.get<mio::abm::TimeExposedToNoSymptoms>() = mio::ParameterDistributionLogNormal(4., 1.);
model.parameters.get<mio::abm::TimeInfectedNoSymptomsToModerate>() = mio::ParameterDistributionLogNormal(4., 1.);

// Set the age group the can go to school is AgeGroup(1) (i.e. 5-14)
model.parameters.get<mio::abm::AgeGroupGotoSchool>()[age_group_5_to_14] = true;
Expand Down Expand Up @@ -144,11 +144,11 @@ int main()
auto persons = model.get_persons();
for (auto& person : persons) {
auto rng = mio::abm::PersonalRandomNumberGenerator(model.get_rng(), person);
mio::abm::InfectionState infection_state =
(mio::abm::InfectionState)(rand() % ((uint32_t)mio::abm::InfectionState::Count - 1));
if (infection_state != mio::abm::InfectionState::Susceptible)
mio::abm::SymptomState symptom_state =
(mio::abm::SymptomState)(rand() % ((uint32_t)mio::abm::SymptomState::Count));
if (symptom_state != mio::abm::SymptomState::Count)
person.add_new_infection(mio::abm::Infection(rng, mio::abm::VirusVariant::Wildtype, person.get_age(),
model.parameters, start_date, infection_state));
model.parameters, start_date, symptom_state));
}

// Assign locations to the people
Expand Down
2 changes: 1 addition & 1 deletion cpp/examples/graph_abm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "abm/household.h"
#include "abm/model.h"
#include "abm/infection_state.h"
#include "abm/symptom_state.h"
#include "abm/location_type.h"
#include "abm/time.h"
#include "abm/person_id.h"
Expand Down
2 changes: 1 addition & 1 deletion cpp/models/abm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ add_library(abm
lockdown_rules.h
infection.cpp
infection.h
infection_state.h
symptom_state.h
virus_variant.h
protection_event.h
mask.h
Expand Down
29 changes: 14 additions & 15 deletions cpp/models/abm/common_abm_loggers.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#ifndef ABM_COMMON_LOGGERS_H
#define ABM_COMMON_LOGGERS_H

#include "abm/infection_state.h"
#include "abm/symptom_state.h"
#include "abm/person_id.h"
#include "abm/simulation.h"
#include "memilio/io/history.h"
Expand All @@ -48,7 +48,7 @@ struct mobility_data {
mio::abm::TimePoint end_time;
mio::abm::TransportMode transport_mode;
mio::abm::ActivityType activity_type;
mio::abm::InfectionState infection_state;
mio::abm::SymptomState symptom_state;
};

constexpr mio::abm::ActivityType guess_activity_type(mio::abm::LocationType current_location)
Expand Down Expand Up @@ -138,7 +138,7 @@ struct LogPersonInformation : mio::LogOnce {
*/
struct LogDataForMobility : mio::LogAlways {
using Type = std::vector<std::tuple<mio::abm::PersonId, mio::abm::LocationId, mio::abm::TimePoint,
mio::abm::TransportMode, mio::abm::ActivityType, mio::abm::InfectionState>>;
mio::abm::TransportMode, mio::abm::ActivityType, mio::abm::SymptomState>>;
/**
* @brief Log the mobility data of the agents in the simulation.
* @param[in] sim The simulation of the ABM.
Expand All @@ -148,41 +148,40 @@ struct LogDataForMobility : mio::LogAlways {
* -# The time point.
* -# The transport mode.
* -# The activity type.
* -# The infection state.
* -# The symptom state.
*/
static Type log(const mio::abm::Simulation<>& sim)
{
Type mobility_data{};
for (Person p : sim.get_model().get_persons()) {
mobility_data.push_back(
std::make_tuple(p.get_id(), p.get_location(), sim.get_time(), p.get_last_transport_mode(),
guess_activity_type(p.get_location_type()), p.get_infection_state(sim.get_time())));
guess_activity_type(p.get_location_type()), p.get_symptom_state(sim.get_time())));
}
return mobility_data;
}
};

/**
* @brief Logger to log the TimeSeries of the number of Person%s in an #InfectionState.
* @brief Logger to log the TimeSeries of the number of Person%s in an #SymptomState.
*/
struct LogInfectionState : mio::LogAlways {
struct LogSymptomState : mio::LogAlways {
using Type = std::pair<mio::abm::TimePoint, Eigen::VectorX<ScalarType>>;
/**
* @brief Log the TimeSeries of the number of Person%s in an #InfectionState.
* @brief Log the TimeSeries of the number of Person%s in an #SymptomState.
* @param[in] sim The simulation of the abm.
* @return A pair of the TimePoint and the TimeSeries of the number of Person%s in an #InfectionState.
* @return A pair of the TimePoint and the TimeSeries of the number of Person%s in an #SymptomState.
*/
static Type log(const mio::abm::Simulation<>& sim)
{

Eigen::VectorX<ScalarType> sum =
Eigen::VectorX<ScalarType>::Zero(Eigen::Index(mio::abm::InfectionState::Count));
auto curr_time = sim.get_time();
Eigen::VectorX<ScalarType> sum = Eigen::VectorX<ScalarType>::Zero(Eigen::Index(mio::abm::SymptomState::Count));
auto curr_time = sim.get_time();
PRAGMA_OMP(for)
for (auto& location : sim.get_model().get_locations()) {
for (uint32_t inf_state = 0; inf_state < (int)mio::abm::InfectionState::Count; inf_state++) {
sum[inf_state] += sim.get_model().get_subpopulation(location.get_id(), curr_time,
mio::abm::InfectionState(inf_state));
for (uint32_t inf_state = 0; inf_state < (int)mio::abm::SymptomState::Count; inf_state++) {
sum[inf_state] +=
sim.get_model().get_subpopulation(location.get_id(), curr_time, mio::abm::SymptomState(inf_state));
}
}
return std::make_pair(curr_time, sum);
Expand Down
Loading
Loading