Skip to content
Merged
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
16 changes: 13 additions & 3 deletions cpp/models/abm/infection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@ void Infection::draw_infection_course_forward(PersonalRandomNumberGenerator& rng
case InfectionState::InfectedSevere:
// roll out next infection step
v = uniform_dist(rng);
if (v < 0.5) { // TODO: subject to change
if (v < 0.25) { // TODO: subject to change
time_period = days(params.get<SevereToDead>()[{m_virus_variant, age}]); // TODO: subject to change
next_state = InfectionState::Dead;
} else if (v < 0.5) { // TODO: subject to change
time_period = days(params.get<SevereToCritical>()[{m_virus_variant, age}]); // TODO: subject to change
next_state = InfectionState::InfectedCritical;
}
Expand Down Expand Up @@ -271,8 +274,15 @@ TimePoint Infection::draw_infection_course_backward(PersonalRandomNumberGenerato
break;

case InfectionState::Dead:
time_period = days(params.get<CriticalToDead>()[{m_virus_variant, age}]); // TODO: subject to change
previous_state = InfectionState::InfectedCritical;
v = uniform_dist(rng);
if (v < 0.5) {
time_period = days(params.get<SevereToDead>()[{m_virus_variant, age}]); // TODO: subject to change
previous_state = InfectionState::InfectedSevere;
}
else {
time_period = days(params.get<CriticalToDead>()[{m_virus_variant, age}]); // TODO: subject to change
previous_state = InfectionState::InfectedCritical;
}
break;

default:
Expand Down
21 changes: 17 additions & 4 deletions cpp/models/abm/infection.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,33 +141,46 @@ class Infection
Infection() = default;

/**
* @brief Determine ViralLoad course and Infection course based on init_state.
* @brief Determine Infection course based on #InfectionState init_state.
* Calls draw_infection_course_backward for all #InfectionState%s prior and draw_infection_course_forward for all
* subsequent #InfectionState%s.
* @param[inout] rng PersonalRandomNumberGenerator of the Person.
* @param[in] age AgeGroup of the Person.
* @param[in] params Parameters of the Model.
* @param[in] init_date Date of initializing the Infection.
* @param[in] init_state #InfectionState at time of initializing the Infection.
* @param[in] latest_protection Latest protection against Infection, has an influence on transition probabilities.
* @return The starting date of the Infection.
*/
TimePoint draw_infection_course(PersonalRandomNumberGenerator& rng, AgeGroup age, const Parameters& params,
TimePoint init_date, InfectionState start_state, ProtectionEvent latest_protection);

/**
* @brief Determine ViralLoad course and Infection course prior to the given start_state.
* @brief Determine Infection course subsequent to the given #InfectionState start_state.
* From the start_state, a random path through the #InfectionState tree is chosen, that is
* Susceptible -> InfectedNoSymptoms,
* InfectedNoSymptoms -> InfectedSymptoms or InfectedNoSymptoms -> Recovered,
* InfectedSymptoms -> Infected_Severe or InfectedSymptoms -> Recovered,
* InfectedSevere -> InfectedCritical or InfectedSevere -> Recovered or InfectedSevere -> Dead,
* InfectedCritical -> Recovered or InfectedCritical -> Dead,
* with artifical, hardcoded probabilites, until either Recoverd or Dead is reached.
* This is subject to change when parameter distributions for these transitions are implemented.
* The duration in each #InfectionState is taken from the respective parameter.
* @param[inout] rng PersonalRandomNumberGenerator of the Person.
* @param[in] age AgeGroup of the Person.
* @param[in] params Parameters of the Model.
* @param[in] init_date Date of initializing the Infection.
* @param[in] init_state #InfectionState at time of initializing the Infection.
* @param[in] latest_protection Latest protection against Infection, has an influence on transition probabilities.
*/
void draw_infection_course_forward(PersonalRandomNumberGenerator& rng, AgeGroup age, const Parameters& params,
TimePoint init_date, InfectionState start_state,
TimePoint init_date, InfectionState init_state,
ProtectionEvent latest_protection);

/**
* @brief Determine ViralLoad course and Infection course subsequent to the given start_state.
* @brief Determine Infection course prior to the given #InfectionState start_state.
* From the start_state, a random path through the #InfectionState tree is chosen backwards, until Susceptible is reached.
* For more detailed information, refer to draw_infection_course_forward.
* @param[inout] rng PersonalRandomNumberGenerator of the Person.
* @param[in] age AgeGroup of the person.
* @param[in] params Parameters of the Model.
Expand Down
20 changes: 19 additions & 1 deletion cpp/models/abm/parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,18 @@ struct SevereToRecovered {
}
};

struct SevereToDead {
using Type = CustomIndexArray<UncertainValue<>, VirusVariant, AgeGroup>;
static Type get_default(AgeGroup size)
{
return Type({VirusVariant::Count, size}, 1.);
}
static std::string name()
{
return "SevereToDead";
}
};

struct CriticalToRecovered {
using Type = CustomIndexArray<UncertainValue<>, VirusVariant, AgeGroup>;
static Type get_default(AgeGroup size)
Expand Down Expand Up @@ -551,7 +563,7 @@ struct AgeGroupGotoWork {

using ParametersBase =
ParameterSet<IncubationPeriod, InfectedNoSymptomsToSymptoms, InfectedNoSymptomsToRecovered,
InfectedSymptomsToRecovered, InfectedSymptomsToSevere, SevereToCritical, SevereToRecovered,
InfectedSymptomsToRecovered, InfectedSymptomsToSevere, SevereToCritical, SevereToRecovered, SevereToDead,
CriticalToDead, CriticalToRecovered, RecoveredToSusceptible, ViralLoadDistributions,
InfectivityDistributions, DetectInfection, MaskProtection, AerosolTransmissionRates, LockdownDate,
QuarantineDuration, SocialEventRate, BasicShoppingRate, WorkRatio, SchoolRatio, GotoWorkTimeMinimum,
Expand Down Expand Up @@ -692,6 +704,12 @@ class Parameters : public ParametersBase
return true;
}

if (this->get<SevereToDead>()[{VirusVariant::Wildtype, age_group}] < 0.0) {
log_error("Constraint check: Parameter SevereToDead of age group {:.0f} smaller than {:d}",
(size_t)age_group, 0);
return true;
}

if (this->get<CriticalToDead>()[{virus_variant, age_group}] < 0.0) {
log_error("Constraint check: Parameter CriticalToDead of age group {:.0f} smaller than {:d}",
(size_t)age_group, 0);
Expand Down
12 changes: 12 additions & 0 deletions cpp/simulations/abm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ void set_parameters(mio::abm::Parameters params)
params.get<mio::abm::InfectedSymptomsToSevere>()[{mio::abm::VirusVariant::Wildtype, age_group_0_to_4}] = 0.001;
params.get<mio::abm::SevereToRecovered>()[{mio::abm::VirusVariant::Wildtype, age_group_0_to_4}] = 0.186;
params.get<mio::abm::SevereToCritical>()[{mio::abm::VirusVariant::Wildtype, age_group_0_to_4}] = 0.015;
params.get<mio::abm::SevereToDead>()[{mio::abm::VirusVariant::Wildtype, age_group_0_to_4}] = 0.001;
params.get<mio::abm::CriticalToRecovered>()[{mio::abm::VirusVariant::Wildtype, age_group_0_to_4}] = 0.143;
params.get<mio::abm::CriticalToDead>()[{mio::abm::VirusVariant::Wildtype, age_group_0_to_4}] = 0.001;

Expand All @@ -486,6 +487,7 @@ void set_parameters(mio::abm::Parameters params)
params.get<mio::abm::InfectedSymptomsToSevere>()[{mio::abm::VirusVariant::Wildtype, age_group_5_to_14}] = 0.001;
params.get<mio::abm::SevereToRecovered>()[{mio::abm::VirusVariant::Wildtype, age_group_5_to_14}] = 0.186;
params.get<mio::abm::SevereToCritical>()[{mio::abm::VirusVariant::Wildtype, age_group_5_to_14}] = 0.015;
params.get<mio::abm::SevereToDead>()[{mio::abm::VirusVariant::Wildtype, age_group_5_to_14}] = 0.001;
params.get<mio::abm::CriticalToRecovered>()[{mio::abm::VirusVariant::Wildtype, age_group_5_to_14}] = 0.143;
params.get<mio::abm::CriticalToDead>()[{mio::abm::VirusVariant::Wildtype, age_group_5_to_14}] = 0.001;
params.get<mio::abm::RecoveredToSusceptible>()[{mio::abm::VirusVariant::Wildtype, age_group_5_to_14}] = 0.;
Expand All @@ -499,6 +501,7 @@ void set_parameters(mio::abm::Parameters params)
params.get<mio::abm::InfectedSymptomsToSevere>()[{mio::abm::VirusVariant::Wildtype, age_group_15_to_34}] = 0.003;
params.get<mio::abm::SevereToRecovered>()[{mio::abm::VirusVariant::Wildtype, age_group_15_to_34}] = 0.157;
params.get<mio::abm::SevereToCritical>()[{mio::abm::VirusVariant::Wildtype, age_group_15_to_34}] = 0.013;
params.get<mio::abm::SevereToDead>()[{mio::abm::VirusVariant::Wildtype, age_group_15_to_34}] = 0.021;
params.get<mio::abm::CriticalToRecovered>()[{mio::abm::VirusVariant::Wildtype, age_group_15_to_34}] = 0.126;
params.get<mio::abm::CriticalToDead>()[{mio::abm::VirusVariant::Wildtype, age_group_15_to_34}] = 0.021;

Expand All @@ -511,6 +514,7 @@ void set_parameters(mio::abm::Parameters params)
params.get<mio::abm::InfectedSymptomsToSevere>()[{mio::abm::VirusVariant::Wildtype, age_group_35_to_59}] = 0.009;
params.get<mio::abm::SevereToRecovered>()[{mio::abm::VirusVariant::Wildtype, age_group_35_to_59}] = 0.113;
params.get<mio::abm::SevereToCritical>()[{mio::abm::VirusVariant::Wildtype, age_group_35_to_59}] = 0.02;
params.get<mio::abm::SevereToDead>()[{mio::abm::VirusVariant::Wildtype, age_group_35_to_59}] = 0.008;
params.get<mio::abm::CriticalToRecovered>()[{mio::abm::VirusVariant::Wildtype, age_group_35_to_59}] = 0.05;
params.get<mio::abm::CriticalToDead>()[{mio::abm::VirusVariant::Wildtype, age_group_35_to_59}] = 0.008;
params.get<mio::abm::RecoveredToSusceptible>()[{mio::abm::VirusVariant::Wildtype, age_group_35_to_59}] = 0.;
Expand All @@ -524,6 +528,7 @@ void set_parameters(mio::abm::Parameters params)
params.get<mio::abm::InfectedSymptomsToSevere>()[{mio::abm::VirusVariant::Wildtype, age_group_60_to_79}] = 0.024;
params.get<mio::abm::SevereToRecovered>()[{mio::abm::VirusVariant::Wildtype, age_group_60_to_79}] = 0.083;
params.get<mio::abm::SevereToCritical>()[{mio::abm::VirusVariant::Wildtype, age_group_60_to_79}] = 0.035;
params.get<mio::abm::SevereToDead>()[{mio::abm::VirusVariant::Wildtype, age_group_60_to_79}] = 0.023;
params.get<mio::abm::CriticalToRecovered>()[{mio::abm::VirusVariant::Wildtype, age_group_60_to_79}] = 0.035;
params.get<mio::abm::CriticalToDead>()[{mio::abm::VirusVariant::Wildtype, age_group_60_to_79}] = 0.023;
params.get<mio::abm::RecoveredToSusceptible>()[{mio::abm::VirusVariant::Wildtype, age_group_60_to_79}] = 0.;
Expand All @@ -536,6 +541,7 @@ void set_parameters(mio::abm::Parameters params)
params.get<mio::abm::InfectedSymptomsToSevere>()[{mio::abm::VirusVariant::Wildtype, age_group_80_plus}] = 0.033;
params.get<mio::abm::SevereToRecovered>()[{mio::abm::VirusVariant::Wildtype, age_group_80_plus}] = 0.055;
params.get<mio::abm::SevereToCritical>()[{mio::abm::VirusVariant::Wildtype, age_group_80_plus}] = 0.036;
params.get<mio::abm::SevereToDead>()[{mio::abm::VirusVariant::Wildtype, age_group_80_plus}] = 0.052;
params.get<mio::abm::CriticalToRecovered>()[{mio::abm::VirusVariant::Wildtype, age_group_80_plus}] = 0.035;
params.get<mio::abm::CriticalToDead>()[{mio::abm::VirusVariant::Wildtype, age_group_80_plus}] = 0.052;
params.get<mio::abm::RecoveredToSusceptible>()[{mio::abm::VirusVariant::Wildtype, age_group_80_plus}] = 0.;
Expand All @@ -550,6 +556,7 @@ void set_parameters(mio::abm::Parameters params)
params.get<mio::abm::InfectedSymptomsToSevere>()[{mio::abm::VirusVariant::Wildtype, age_group_0_to_4}] = 0.001;
params.get<mio::abm::SevereToRecovered>()[{mio::abm::VirusVariant::Wildtype, age_group_0_to_4}] = 0.186;
params.get<mio::abm::SevereToCritical>()[{mio::abm::VirusVariant::Wildtype, age_group_0_to_4}] = 0.015;
params.get<mio::abm::SevereToDead>()[{mio::abm::VirusVariant::Wildtype, age_group_0_to_4}] = 0.001;
params.get<mio::abm::CriticalToRecovered>()[{mio::abm::VirusVariant::Wildtype, age_group_0_to_4}] = 0.143;
params.get<mio::abm::CriticalToDead>()[{mio::abm::VirusVariant::Wildtype, age_group_0_to_4}] = 0.001;
params.get<mio::abm::RecoveredToSusceptible>()[{mio::abm::VirusVariant::Wildtype, age_group_0_to_4}] = 0.0;
Expand All @@ -562,6 +569,7 @@ void set_parameters(mio::abm::Parameters params)
params.get<mio::abm::InfectedSymptomsToSevere>()[{mio::abm::VirusVariant::Wildtype, age_group_5_to_14}] = 0.001;
params.get<mio::abm::SevereToRecovered>()[{mio::abm::VirusVariant::Wildtype, age_group_5_to_14}] = 0.186;
params.get<mio::abm::SevereToCritical>()[{mio::abm::VirusVariant::Wildtype, age_group_5_to_14}] = 0.015;
params.get<mio::abm::SevereToDead>()[{mio::abm::VirusVariant::Wildtype, age_group_5_to_14}] = 0.001;
params.get<mio::abm::CriticalToRecovered>()[{mio::abm::VirusVariant::Wildtype, age_group_5_to_14}] = 0.143;
params.get<mio::abm::CriticalToDead>()[{mio::abm::VirusVariant::Wildtype, age_group_5_to_14}] = 0.001;
params.get<mio::abm::RecoveredToSusceptible>()[{mio::abm::VirusVariant::Wildtype, age_group_5_to_14}] = 0.0;
Expand All @@ -575,6 +583,7 @@ void set_parameters(mio::abm::Parameters params)
params.get<mio::abm::InfectedSymptomsToSevere>()[{mio::abm::VirusVariant::Wildtype, age_group_15_to_34}] = 0.001;
params.get<mio::abm::SevereToRecovered>()[{mio::abm::VirusVariant::Wildtype, age_group_15_to_34}] = 0.157;
params.get<mio::abm::SevereToCritical>()[{mio::abm::VirusVariant::Wildtype, age_group_15_to_34}] = 0.013;
params.get<mio::abm::SevereToDead>()[{mio::abm::VirusVariant::Wildtype, age_group_15_to_34}] = 0.021;
params.get<mio::abm::CriticalToRecovered>()[{mio::abm::VirusVariant::Wildtype, age_group_15_to_34}] = 0.126;
params.get<mio::abm::CriticalToDead>()[{mio::abm::VirusVariant::Wildtype, age_group_15_to_34}] = 0.021;
params.get<mio::abm::RecoveredToSusceptible>()[{mio::abm::VirusVariant::Wildtype, age_group_15_to_34}] = 0.0;
Expand All @@ -588,6 +597,7 @@ void set_parameters(mio::abm::Parameters params)
params.get<mio::abm::InfectedSymptomsToSevere>()[{mio::abm::VirusVariant::Wildtype, age_group_35_to_59}] = 0.003;
params.get<mio::abm::SevereToRecovered>()[{mio::abm::VirusVariant::Wildtype, age_group_35_to_59}] = 0.113;
params.get<mio::abm::SevereToCritical>()[{mio::abm::VirusVariant::Wildtype, age_group_35_to_59}] = 0.02;
params.get<mio::abm::SevereToDead>()[{mio::abm::VirusVariant::Wildtype, age_group_35_to_59}] = 0.008;
params.get<mio::abm::CriticalToRecovered>()[{mio::abm::VirusVariant::Wildtype, age_group_35_to_59}] = 0.05;
params.get<mio::abm::CriticalToDead>()[{mio::abm::VirusVariant::Wildtype, age_group_35_to_59}] = 0.008;
params.get<mio::abm::RecoveredToSusceptible>()[{mio::abm::VirusVariant::Wildtype, age_group_35_to_59}] = 0.0;
Expand All @@ -601,6 +611,7 @@ void set_parameters(mio::abm::Parameters params)
params.get<mio::abm::InfectedSymptomsToSevere>()[{mio::abm::VirusVariant::Wildtype, age_group_60_to_79}] = 0.009;
params.get<mio::abm::SevereToRecovered>()[{mio::abm::VirusVariant::Wildtype, age_group_60_to_79}] = 0.083;
params.get<mio::abm::SevereToCritical>()[{mio::abm::VirusVariant::Wildtype, age_group_60_to_79}] = 0.035;
params.get<mio::abm::SevereToDead>()[{mio::abm::VirusVariant::Wildtype, age_group_60_to_79}] = 0.023;
params.get<mio::abm::CriticalToRecovered>()[{mio::abm::VirusVariant::Wildtype, age_group_60_to_79}] = 0.035;
params.get<mio::abm::CriticalToDead>()[{mio::abm::VirusVariant::Wildtype, age_group_60_to_79}] = 0.023;
params.get<mio::abm::RecoveredToSusceptible>()[{mio::abm::VirusVariant::Wildtype, age_group_60_to_79}] = 0.0;
Expand All @@ -613,6 +624,7 @@ void set_parameters(mio::abm::Parameters params)
params.get<mio::abm::InfectedSymptomsToSevere>()[{mio::abm::VirusVariant::Wildtype, age_group_80_plus}] = 0.012;
params.get<mio::abm::SevereToRecovered>()[{mio::abm::VirusVariant::Wildtype, age_group_80_plus}] = 0.055;
params.get<mio::abm::SevereToCritical>()[{mio::abm::VirusVariant::Wildtype, age_group_80_plus}] = 0.036;
params.get<mio::abm::SevereToDead>()[{mio::abm::VirusVariant::Wildtype, age_group_80_plus}] = 0.052;
params.get<mio::abm::CriticalToRecovered>()[{mio::abm::VirusVariant::Wildtype, age_group_80_plus}] = 0.035;
params.get<mio::abm::CriticalToDead>()[{mio::abm::VirusVariant::Wildtype, age_group_80_plus}] = 0.052;
params.get<mio::abm::RecoveredToSusceptible>()[{mio::abm::VirusVariant::Wildtype, age_group_80_plus}] = 0.0;
Expand Down
Loading