Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

323 Ode model with waning immunity and omicron parametrization #833

Closed
Closed
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
14 changes: 7 additions & 7 deletions cpp/benchmarks/flow_simulation_ode_secirvvs.h
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,9 @@ class Simulation : public Base
for (size_t i = 0; i < num_groups; ++i) {
double new_transmission =
(1 - share_new_variant) *
this->get_model().parameters.template get<osecirvvs::BaseInfectiousnessB117>()[(AgeGroup)i] +
this->get_model().parameters.template get<osecirvvs::BaseInfectiousness>()[(AgeGroup)i] +
HenrZu marked this conversation as resolved.
Show resolved Hide resolved
share_new_variant *
this->get_model().parameters.template get<osecirvvs::BaseInfectiousnessB161>()[(AgeGroup)i];
this->get_model().parameters.template get<osecirvvs::BaseInfectiousnessNewVariant>()[(AgeGroup)i];
this->get_model().parameters.template get<osecirvvs::TransmissionProbabilityOnContact>()[(AgeGroup)i] =
new_transmission;
}
Expand All @@ -457,13 +457,13 @@ class Simulation : public Base
double first_vacc;
double full_vacc;
if (t_idx == SimulationDay(0)) {
first_vacc = params.template get<osecirvvs::DailyFirstVaccination>()[{(AgeGroup)i, t_idx}];
first_vacc = params.template get<osecirvvs::DailyPartialVaccination>()[{(AgeGroup)i, t_idx}];
full_vacc = params.template get<osecirvvs::DailyFullVaccination>()[{(AgeGroup)i, t_idx}];
}
else {
first_vacc =
params.template get<osecirvvs::DailyFirstVaccination>()[{(AgeGroup)i, t_idx}] -
params.template get<osecirvvs::DailyFirstVaccination>()[{(AgeGroup)i, t_idx - SimulationDay(1)}];
params.template get<osecirvvs::DailyPartialVaccination>()[{(AgeGroup)i, t_idx}] -
params.template get<osecirvvs::DailyPartialVaccination>()[{(AgeGroup)i, t_idx - SimulationDay(1)}];
full_vacc =
params.template get<osecirvvs::DailyFullVaccination>()[{(AgeGroup)i, t_idx}] -
params.template get<osecirvvs::DailyFullVaccination>()[{(AgeGroup)i, t_idx - SimulationDay(1)}];
Expand Down Expand Up @@ -627,8 +627,8 @@ void setup_model(Model& model)

model.parameters.template get<osecirvvs::ICUCapacity>() = 100;
model.parameters.template get<osecirvvs::TestAndTraceCapacity>() = 0.0143;
model.parameters.template get<osecirvvs::DailyFirstVaccination>().resize(SimulationDay(size_t(1000)));
model.parameters.template get<osecirvvs::DailyFirstVaccination>().array().setConstant(5);
model.parameters.template get<osecirvvs::DailyPartialVaccination>().resize(SimulationDay(size_t(1000)));
model.parameters.template get<osecirvvs::DailyPartialVaccination>().array().setConstant(5);
model.parameters.template get<osecirvvs::DailyFullVaccination>().resize(SimulationDay(size_t(1000)));
model.parameters.template get<osecirvvs::DailyFullVaccination>().array().setConstant(3);

Expand Down
4 changes: 2 additions & 2 deletions cpp/benchmarks/graph_simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ mio::osecirvvs::Model create_model(size_t num_agegroups, const ScalarType tmax)
const size_t vacc_full = 5;
model.parameters.get<mio::osecirvvs::ICUCapacity>() = 100;
model.parameters.get<mio::osecirvvs::TestAndTraceCapacity>() = 0.0143;
model.parameters.get<mio::osecirvvs::DailyFirstVaccination>().resize(mio::SimulationDay(tmax));
model.parameters.get<mio::osecirvvs::DailyFirstVaccination>().array().setConstant(vacc_first);
model.parameters.get<mio::osecirvvs::DailyPartialVaccination>().resize(mio::SimulationDay(tmax));
model.parameters.get<mio::osecirvvs::DailyPartialVaccination>().array().setConstant(vacc_first);
model.parameters.get<mio::osecirvvs::DailyFullVaccination>().resize(mio::SimulationDay(tmax));
model.parameters.get<mio::osecirvvs::DailyFullVaccination>().array().setConstant(vacc_full);

Expand Down
4 changes: 2 additions & 2 deletions cpp/examples/ode_secirvvs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ int main()

model.parameters.get<mio::osecirvvs::ICUCapacity>() = 100;
model.parameters.get<mio::osecirvvs::TestAndTraceCapacity>() = 0.0143;
model.parameters.get<mio::osecirvvs::DailyFirstVaccination>().resize(mio::SimulationDay(size_t(1000)));
model.parameters.get<mio::osecirvvs::DailyFirstVaccination>().array().setConstant(5);
model.parameters.get<mio::osecirvvs::DailyPartialVaccination>().resize(mio::SimulationDay(size_t(1000)));
model.parameters.get<mio::osecirvvs::DailyPartialVaccination>().array().setConstant(5);
model.parameters.get<mio::osecirvvs::DailyFullVaccination>().resize(mio::SimulationDay(size_t(1000)));
model.parameters.get<mio::osecirvvs::DailyFullVaccination>().array().setConstant(3);

Expand Down
28 changes: 17 additions & 11 deletions cpp/memilio/io/epi_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,8 @@ class VaccinationDataEntry
public:
static const std::array<const char*, 6> age_group_names;

double num_vaccinations_completed;
double num_second_vaccinations_completed, num_first_vaccinations_completed, num_vaccinations_refreshed,
num_vaccinations_refreshed_2;
Date date;
AgeGroup age_group;
boost::optional<regions::StateId> state_id;
Expand All @@ -388,16 +389,20 @@ class VaccinationDataEntry
template <class IoContext>
static IOResult<VaccinationDataEntry> deserialize(IoContext& io)
{
auto obj = io.expect_object("VaccinationDataEntry");
auto num_vaccinations_completed = obj.expect_element("Vacc_completed", Tag<double>{});
auto date = obj.expect_element("Date", Tag<StringDate>{});
auto age_group_str = obj.expect_element("Age_RKI", Tag<std::string>{});
auto state_id = obj.expect_optional("ID_State", Tag<regions::StateId>{});
auto county_id = obj.expect_optional("ID_County", Tag<regions::CountyId>{});
auto district_id = obj.expect_optional("ID_District", Tag<regions::DistrictId>{});
auto obj = io.expect_object("VaccinationDataEntry");
auto num_second_vaccinations_completed = obj.expect_element("Vacc_completed", Tag<double>{});
auto num_first_vaccinations_completed = obj.expect_element("Vacc_partially", Tag<double>{});
auto num_vaccinations_refreshed = obj.expect_element("Vacc_refreshed", Tag<double>{});
auto num_vaccinations_refreshed_2 = obj.expect_element("Vacc_refreshed_2", Tag<double>{});
auto date = obj.expect_element("Date", Tag<StringDate>{});
auto age_group_str = obj.expect_element("Age_RKI", Tag<std::string>{});
auto state_id = obj.expect_optional("ID_County", Tag<regions::StateId>{});
auto county_id = obj.expect_optional("ID_County", Tag<regions::CountyId>{});
auto district_id = obj.expect_optional("ID_District", Tag<regions::DistrictId>{});
return mio::apply(
io,
[](auto nf, auto d, auto&& a_str, auto sid, auto cid, auto did) -> IOResult<VaccinationDataEntry> {
[](auto nf, auto np, auto n_refreshed_1, auto n_refreshed_2, auto d, auto&& a_str, auto sid, auto cid,
auto did) -> IOResult<VaccinationDataEntry> {
auto it = std::find(age_group_names.begin(), age_group_names.end(), a_str);
auto a = AgeGroup(0);
if (it != age_group_names.end()) {
Expand All @@ -406,9 +411,10 @@ class VaccinationDataEntry
else {
return failure(StatusCode::InvalidValue, "Invalid vaccination data age group.");
}
return success(VaccinationDataEntry{nf, d, a, sid, cid, did});
return success(VaccinationDataEntry{nf, np, n_refreshed_1, n_refreshed_2, d, a, sid, cid, did});
},
num_vaccinations_completed, date, age_group_str, state_id, county_id, district_id);
num_second_vaccinations_completed, num_first_vaccinations_completed, num_vaccinations_refreshed,
num_vaccinations_refreshed_2, date, age_group_str, state_id, county_id, district_id);
}
};

Expand Down
2 changes: 1 addition & 1 deletion cpp/models/ode_secirvvs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This model extends the basic SECIR model by adding vaccinations and allowing the implicit modeling of a newly arriving variant that takes hold.

Vaccinations are modeled by adding compartments for partially and fully vaccinated persons. `Partially and fully vaccinated` is to be understood in this context as the person having received a first and second vaccine shot as in 2021. These model lines can be reused by resetting parameters. Persons that have recovered from the disease are treated as fully vaccinated from that time forward. Vaccinated persons are added on every day of simulation, see parameters `DailyFirstVaccination` and `DailyFullVaccination`. All groups can get an infection or get reinfected. Vaccinated persons are less likely to develop symptoms. E.g., the probability to develop symptoms when carrying the virus is the base probability from the SECIR model multiplied with the `ReducInfectedSymptomsPartialImmunity` parameter.
Vaccinations are modeled by adding compartments for partially and fully vaccinated persons. `Partially and fully vaccinated` is to be understood in this context as the person having received a first and second vaccine shot as in 2021. These model lines can be reused by resetting parameters. Persons that have recovered from the disease are treated as fully vaccinated from that time forward. Vaccinated persons are added on every day of simulation, see parameters `DailyPartialVaccination` and `DailyFullVaccination`. All groups can get an infection or get reinfected. Vaccinated persons are less likely to develop symptoms. E.g., the probability to develop symptoms when carrying the virus is the base probability from the SECIR model multiplied with the `ReducInfectedSymptomsPartialImmunity` parameter.

The ratio of two variants can change over time, which affects the average transmissiblity of the disease. Infectiousness of different variants can be set in the parameters.

Expand Down
15 changes: 3 additions & 12 deletions cpp/models/ode_secirvvs/analyze_result.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ std::vector<Model> ensemble_params_percentile(const std::vector<std::vector<Mode
auto num_nodes = ensemble_params[0].size();
auto num_groups = (size_t)ensemble_params[0][0].parameters.get_num_groups();
auto num_days =
ensemble_params[0][0].parameters.template get<DailyFirstVaccination>().template size<mio::SimulationDay>();
ensemble_params[0][0].parameters.template get<DailyPartialVaccination>().template size<mio::SimulationDay>();

std::vector<double> single_element_ensemble(num_runs);

Expand All @@ -63,7 +63,7 @@ std::vector<Model> ensemble_params_percentile(const std::vector<std::vector<Mode
};

for (size_t node = 0; node < num_nodes; node++) {
percentile[node].parameters.template get<DailyFirstVaccination>().resize(num_days);
percentile[node].parameters.template get<DailyPartialVaccination>().resize(num_days);
percentile[node].parameters.template get<DailyFullVaccination>().resize(num_days);

for (auto i = AgeGroup(0); i < AgeGroup(num_groups); i++) {
Expand Down Expand Up @@ -155,22 +155,13 @@ std::vector<Model> ensemble_params_percentile(const std::vector<std::vector<Mode
for (auto day = SimulationDay(0); day < num_days; ++day) {
param_percentil(
node, [ i, day ](auto&& model) -> auto& {
return model.parameters.template get<DailyFirstVaccination>()[{i, day}];
return model.parameters.template get<DailyPartialVaccination>()[{i, day}];
});
param_percentil(
node, [ i, day ](auto&& model) -> auto& {
return model.parameters.template get<DailyFullVaccination>()[{i, day}];
});
}
//virus variants
param_percentil(
node, [i](auto&& model) -> auto& {
return model.parameters.template get<BaseInfectiousnessB161>()[i];
});
param_percentil(
node, [i](auto&& model) -> auto& {
return model.parameters.template get<BaseInfectiousnessB117>()[i];
});
}
// group independent params
param_percentil(
Expand Down
4 changes: 3 additions & 1 deletion cpp/models/ode_secirvvs/infection_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ enum class InfectionState
InfectedCriticalNaive,
InfectedCriticalPartialImmunity,
InfectedCriticalImprovedImmunity,
SusceptibleImprovedImmunity, //includes all with improved immunity, either through infection or at least two vaccinations
SusceptibleImprovedImmunity,
DeadNaive,
DeadPartialImmunity,
DeadImprovedImmunity,
TemporaryImmunity1,
TemporaryImmunity2,

Count
};
Expand Down
Loading
Loading