Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5a13346
munich graph sim
jubicker Oct 2, 2023
906761e
merge main
jubicker Oct 2, 2023
7bf0670
remove unused parameter
jubicker Oct 2, 2023
adbfdc8
remove unused variable
jubicker Oct 2, 2023
00c3d01
make export time series more efficient
jubicker Oct 5, 2023
2eb43fb
bug fix
jubicker Oct 25, 2023
7e3ab1b
simulation tuning
jubicker Nov 21, 2023
23a4780
Merge branch '721-graph-model-for-munich' of https://github.com/SciCo…
jubicker Nov 21, 2023
235e107
Merge branch '721-graph-model-for-munich' of https://github.com/SciCo…
jubicker Nov 21, 2023
82128f3
rework one age group functions
jubicker Nov 22, 2023
bdba9be
add tests
jubicker Nov 22, 2023
1cbba15
bug fix
jubicker Nov 22, 2023
c3cbb95
bug fix
jubicker Nov 22, 2023
3466b9a
include
jubicker Nov 22, 2023
b7a8125
merge
jubicker Nov 22, 2023
507442a
add if def
jubicker Nov 22, 2023
8b8efaf
Merge branch '721-graph-model-for-munich' of https://github.com/SciCo…
jubicker Nov 22, 2023
eebc9a6
comments
jubicker Nov 27, 2023
f57832e
Merge branch 'main' into 721-graph-model-for-munich
jubicker Dec 5, 2023
51df67f
review
jubicker Dec 6, 2023
6fe3d51
make confirmed age group names an input parameter
jubicker Dec 12, 2023
7509fca
CI
jubicker Dec 12, 2023
0d493ea
test read confirmed
jubicker Dec 13, 2023
f119896
cast int to size_t
jubicker Dec 13, 2023
3dd7321
redo static age groups names
jubicker Dec 15, 2023
49d7c61
fix Munich graph sim
jubicker Dec 15, 2023
eec2033
Update cpp/models/ode_secir/parameters_io.h
jubicker Dec 15, 2023
9b50e05
review
jubicker Dec 15, 2023
fa01149
Update cpp/models/ode_secir/parameters_io.h
jubicker Dec 21, 2023
f2ece21
review
jubicker Jan 3, 2024
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
13 changes: 6 additions & 7 deletions cpp/memilio/io/epi_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,18 @@
namespace mio
{

const std::array<const char*, 6> ConfirmedCasesDataEntry::age_group_names = {"A00-A04", "A05-A14", "A15-A34",
"A35-A59", "A60-A79", "A80+"};
std::vector<const char*> ConfirmedCasesDataEntry::age_group_names = {"A00-A04", "A05-A14", "A15-A34",
"A35-A59", "A60-A79", "A80+"};

const std::array<const char*, 11> PopulationDataEntry::age_group_names = {
std::vector<const char*> PopulationDataEntry::age_group_names = {
"<3 years", "3-5 years", "6-14 years", "15-17 years", "18-24 years", "25-29 years",
"30-39 years", "40-49 years", "50-64 years", "65-74 years", ">74 years"};

const std::array<const char*, 6> VaccinationDataEntry::age_group_names = {"0-4", "5-14", "15-34",
"35-59", "60-79", "80-99"};
std::vector<const char*> VaccinationDataEntry::age_group_names = {"0-4", "5-14", "15-34", "35-59", "60-79", "80-99"};

IOResult<std::vector<int>> get_node_ids(const std::string& path, bool is_node_for_county)
IOResult<std::vector<int>> get_node_ids(const std::string& path, bool is_node_for_county, bool rki_age_groups)
{
BOOST_OUTCOME_TRY(population_data, read_population_data(path));
BOOST_OUTCOME_TRY(population_data, read_population_data(path, rki_age_groups));
std::vector<int> id;
id.reserve(population_data.size());
for (auto&& entry : population_data) {
Expand Down
46 changes: 36 additions & 10 deletions cpp/memilio/io/epi_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class StringDate : public Date
class ConfirmedCasesDataEntry
{
public:
static const std::array<const char*, 6> age_group_names;
static std::vector<const char*> age_group_names;

double num_confirmed;
double num_recovered;
Expand Down Expand Up @@ -223,7 +223,7 @@ IOResult<std::vector<T>> unpack_all(const std::vector<IOResult<T>>& v)
class PopulationDataEntry
{
public:
static const std::array<const char*, 11> age_group_names;
static std::vector<const char*> age_group_names;

CustomIndexArray<double, AgeGroup> population;
boost::optional<regions::StateId> state_id;
Expand Down Expand Up @@ -260,8 +260,8 @@ inline void get_rki_age_interpolation_coefficients(const std::vector<double>& ag
std::vector<bool>& carry_over)
{
std::array<double, 6> param_ranges = {5., 10., 20., 25., 20., 20.};
static_assert(param_ranges.size() == ConfirmedCasesDataEntry::age_group_names.size(),
"Number of RKI age groups does not match number of age ranges.");
assert(param_ranges.size() == ConfirmedCasesDataEntry::age_group_names.size() &&
"Number of RKI age groups does not match number of age ranges.");

//counter for parameter age groups
size_t counter = 0;
Expand Down Expand Up @@ -342,12 +342,19 @@ interpolate_to_rki_age_groups(const std::vector<PopulationDataEntry>& population
* Deserialize population data from a JSON value.
* Age groups are interpolated to RKI age groups.
* @param jsvalue JSON value that contains the population data.
* @param rki_age_groups Specifies whether population data should be interpolated to rki age groups.
* @return list of population data.
*/
inline IOResult<std::vector<PopulationDataEntry>> deserialize_population_data(const Json::Value& jsvalue)
inline IOResult<std::vector<PopulationDataEntry>> deserialize_population_data(const Json::Value& jsvalue,
bool rki_age_groups = true)
{
BOOST_OUTCOME_TRY(population_data, deserialize_json(jsvalue, Tag<std::vector<PopulationDataEntry>>{}));
return success(details::interpolate_to_rki_age_groups(population_data));
if (rki_age_groups) {
return success(details::interpolate_to_rki_age_groups(population_data));
}
else {
return success(population_data);
}
}

/**
Expand All @@ -356,27 +363,46 @@ inline IOResult<std::vector<PopulationDataEntry>> deserialize_population_data(co
* @param filename JSON file that contains the population data.
* @return list of population data.
*/
inline IOResult<std::vector<PopulationDataEntry>> read_population_data(const std::string& filename)
inline IOResult<std::vector<PopulationDataEntry>> read_population_data(const std::string& filename,
bool rki_age_group = true)
{
BOOST_OUTCOME_TRY(jsvalue, read_json(filename));
return deserialize_population_data(jsvalue);
return deserialize_population_data(jsvalue, rki_age_group);
}

/**
* @brief Sets the age groups' names for the ConfirmedCasesDataEntry%s.
* @param[in] names age group names
*/
IOResult<void> set_confirmed_cases_age_group_names(std::vector<const char*> names);

/**
* @brief Sets the age groups' names for the PopulationDataEntry%s.
* @param[in] names age group names
*/
IOResult<void> set_population_data_age_group_names(std::vector<const char*> names);

/**
* @brief Sets the age groups' names for the VaccinationDataEntry%s.
* @param[in] names age group names
*/
IOResult<void> set_vaccination_data_age_group_names(std::vector<const char*> names);

/**
* @brief returns a vector with the ids of all nodes.
* @param[in] path directory to population data
* @param[in] is_node_for_county boolean specifying whether the nodes should be counties or districts
* @return list of node ids.
*/
IOResult<std::vector<int>> get_node_ids(const std::string& path, bool is_node_for_county);
IOResult<std::vector<int>> get_node_ids(const std::string& path, bool is_node_for_county, bool rki_age_groups = true);

/**
* Represents an entry in a vaccination data file.
*/
class VaccinationDataEntry
{
public:
static const std::array<const char*, 6> age_group_names;
static std::vector<const char*> age_group_names;

double num_vaccinations_completed;
Date date;
Expand Down
14 changes: 8 additions & 6 deletions cpp/memilio/mobility/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,16 +258,18 @@ class Graph
* @param[in] tnt_capacity_factor Factor for test and trace capacity.
* @param[in] num_days Number of days to be simulated; required to load data for vaccinations during the simulation.
* @param[in] export_time_series If true, reads data for each day of simulation and writes it in the same directory as the input files.
* @param[in] rki_age_groups Specifies whether rki-age_groups should be used.
*/
template <class TestAndTrace, class ContactPattern, class Model, class MigrationParams, class Parameters,
class ReadFunction, class NodeIdFunction>
IOResult<void>
set_nodes(const Parameters& params, Date start_date, Date end_date, const fs::path& data_dir,
const std::string& population_data_path, bool is_node_for_county, Graph<Model, MigrationParams>& params_graph,
ReadFunction&& read_func, NodeIdFunction&& node_func, const std::vector<double>& scaling_factor_inf,
double scaling_factor_icu, double tnt_capacity_factor, int num_days = 0, bool export_time_series = false)
IOResult<void> set_nodes(const Parameters& params, Date start_date, Date end_date, const fs::path& data_dir,
const std::string& population_data_path, bool is_node_for_county,
Graph<Model, MigrationParams>& params_graph, ReadFunction&& read_func,
NodeIdFunction&& node_func, const std::vector<double>& scaling_factor_inf,
double scaling_factor_icu, double tnt_capacity_factor, int num_days = 0,
bool export_time_series = false, bool rki_age_groups = true)
{
BOOST_OUTCOME_TRY(node_ids, node_func(population_data_path, is_node_for_county));
BOOST_OUTCOME_TRY(node_ids, node_func(population_data_path, is_node_for_county, rki_age_groups));
std::vector<Model> nodes(node_ids.size(), Model(int(size_t(params.get_num_groups()))));
for (auto& node : nodes) {
node.parameters = params;
Expand Down
Loading