Skip to content

Commit d439941

Browse files
HenrZulenaploetzke
andauthored
882 Parameters describing the multiplicative factor used for the TestAndTraceCapacity (#1059)
- Add a parameter for the maximal impact of the test and trace capacity parameter - The old values are now the default values of the parameters Co-authored-by: lenaploetzke <70579874+lenaploetzke@users.noreply.github.com>
1 parent b131549 commit d439941

File tree

6 files changed

+241
-77
lines changed

6 files changed

+241
-77
lines changed

cpp/models/ode_secir/model.h

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ class Model : public FlowModel<FP, InfectionState, Populations<FP, AgeGroup, Inf
116116
//symptomatic are less well quarantined when testing and tracing is overwhelmed so they infect more people
117117
auto riskFromInfectedSymptomatic =
118118
smoother_cosine(test_and_trace_required, params.template get<TestAndTraceCapacity<FP>>(),
119-
params.template get<TestAndTraceCapacity<FP>>() * 5,
119+
params.template get<TestAndTraceCapacity<FP>>() *
120+
params.template get<TestAndTraceCapacityMaxRisk<FP>>(),
120121
params.template get<RiskOfInfectionFromSymptomatic<FP>>()[j],
121122
params.template get<MaxRiskOfInfectionFromSymptomatic<FP>>()[j]);
122123

@@ -454,15 +455,16 @@ IOResult<FP> get_reproduction_number(size_t t_idx, const Simulation<FP, Base>& s
454455
}
455456
divN[(size_t)k] = 1 / temp;
456457

457-
riskFromInfectedSymptomatic[(size_t)k] =
458-
smoother_cosine(test_and_trace_required, params.template get<TestAndTraceCapacity<FP>>(),
459-
(params.template get<TestAndTraceCapacity<FP>>()) * 5,
460-
params.template get<RiskOfInfectionFromSymptomatic<FP>>()[k],
461-
params.template get<MaxRiskOfInfectionFromSymptomatic<FP>>()[k]);
458+
riskFromInfectedSymptomatic[(size_t)k] = smoother_cosine(
459+
test_and_trace_required, params.template get<TestAndTraceCapacity<FP>>(),
460+
(params.template get<TestAndTraceCapacity<FP>>()) * params.template get<TestAndTraceCapacityMaxRisk<FP>>(),
461+
params.template get<RiskOfInfectionFromSymptomatic<FP>>()[k],
462+
params.template get<MaxRiskOfInfectionFromSymptomatic<FP>>()[k]);
462463

463464
for (mio::AgeGroup l = 0; l < (mio::AgeGroup)num_groups; l++) {
464465
if (test_and_trace_required < params.template get<TestAndTraceCapacity<FP>>() ||
465-
test_and_trace_required > 5 * params.template get<TestAndTraceCapacity<FP>>()) {
466+
test_and_trace_required > params.template get<TestAndTraceCapacityMaxRisk<FP>>() *
467+
params.template get<TestAndTraceCapacity<FP>>()) {
466468
riskFromInfectedSymptomatic_derivatives((size_t)k, (size_t)l) = 0;
467469
}
468470
else {
@@ -661,9 +663,11 @@ auto get_migration_factors(const Simulation<Base>& sim, FP /*t*/, const Eigen::R
661663
auto test_and_trace_required =
662664
((1 - p_asymp) / params.template get<TimeInfectedNoSymptoms<FP>>().array().template cast<FP>() * y_INS.array())
663665
.sum();
664-
auto test_and_trace_capacity = double(params.template get<TestAndTraceCapacity<FP>>());
665-
auto riskFromInfectedSymptomatic = smoother_cosine(test_and_trace_required, test_and_trace_capacity,
666-
test_and_trace_capacity * 5, p_inf.matrix(), p_inf_max.matrix());
666+
auto test_and_trace_capacity = double(params.template get<TestAndTraceCapacity<FP>>());
667+
auto test_and_trace_capacity_max_risk = double(params.template get<TestAndTraceCapacityMaxRisk<FP>>());
668+
auto riskFromInfectedSymptomatic =
669+
smoother_cosine(test_and_trace_required, test_and_trace_capacity,
670+
test_and_trace_capacity * test_and_trace_capacity_max_risk, p_inf.matrix(), p_inf_max.matrix());
667671

668672
//set factor for infected
669673
auto factors = Eigen::VectorXd::Ones(y.rows()).eval();

cpp/models/ode_secir/parameters.h

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -348,14 +348,29 @@ struct TestAndTraceCapacity {
348348
}
349349
};
350350

351+
/**
352+
* @brief Multiplier for the test and trace capacity to determine when it is considered overloaded.
353+
*/
354+
template <typename FP = double>
355+
struct TestAndTraceCapacityMaxRisk {
356+
using Type = UncertainValue<FP>;
357+
static Type get_default(AgeGroup)
358+
{
359+
return Type(5.0);
360+
}
361+
static std::string name()
362+
{
363+
return "TestAndTraceCapacityMaxRisk";
364+
}
365+
};
366+
351367
template <typename FP = double>
352-
using ParametersBase =
353-
ParameterSet<StartDay, Seasonality<FP>, ICUCapacity<FP>, TestAndTraceCapacity<FP>, ContactPatterns<FP>,
354-
DynamicNPIsInfectedSymptoms<FP>, TimeExposed<FP>, TimeInfectedNoSymptoms<FP>, TimeInfectedSymptoms<FP>,
355-
TimeInfectedSevere<FP>, TimeInfectedCritical<FP>, TransmissionProbabilityOnContact<FP>,
356-
RelativeTransmissionNoSymptoms<FP>, RecoveredPerInfectedNoSymptoms<FP>,
357-
RiskOfInfectionFromSymptomatic<FP>, MaxRiskOfInfectionFromSymptomatic<FP>,
358-
SeverePerInfectedSymptoms<FP>, CriticalPerSevere<FP>, DeathsPerCritical<FP>>;
368+
using ParametersBase = ParameterSet<
369+
StartDay, Seasonality<FP>, ICUCapacity<FP>, TestAndTraceCapacity<FP>, TestAndTraceCapacityMaxRisk<FP>,
370+
ContactPatterns<FP>, DynamicNPIsInfectedSymptoms<FP>, TimeExposed<FP>, TimeInfectedNoSymptoms<FP>,
371+
TimeInfectedSymptoms<FP>, TimeInfectedSevere<FP>, TimeInfectedCritical<FP>, TransmissionProbabilityOnContact<FP>,
372+
RelativeTransmissionNoSymptoms<FP>, RecoveredPerInfectedNoSymptoms<FP>, RiskOfInfectionFromSymptomatic<FP>,
373+
MaxRiskOfInfectionFromSymptomatic<FP>, SeverePerInfectedSymptoms<FP>, CriticalPerSevere<FP>, DeathsPerCritical<FP>>;
359374

360375
/**
361376
* @brief Parameters of an age-resolved SECIR/SECIHURD model.
@@ -445,6 +460,20 @@ class Parameters : public ParametersBase<FP>
445460
corrected = true;
446461
}
447462

463+
if (this->template get<TestAndTraceCapacity<FP>>() < 0.0) {
464+
log_warning("Constraint check: Parameter TestAndTraceCapacity changed from {:0.4f} to {:d}",
465+
this->template get<TestAndTraceCapacity<FP>>(), 0);
466+
this->template get<TestAndTraceCapacity<FP>>() = 0;
467+
corrected = true;
468+
}
469+
470+
if (this->template get<TestAndTraceCapacityMaxRisk<FP>>() < 0.0) {
471+
log_warning("Constraint check: Parameter TestAndTraceCapacityMaxRisk changed from {:0.4f} to {:d}",
472+
this->template get<TestAndTraceCapacityMaxRisk<FP>>(), 0);
473+
this->template get<TestAndTraceCapacityMaxRisk<FP>>() = 0;
474+
corrected = true;
475+
}
476+
448477
for (auto i = AgeGroup(0); i < AgeGroup(m_num_groups); ++i) {
449478
if (this->template get<TimeExposed<FP>>()[i] < tol_times) {
450479
log_warning("Constraint check: Parameter TimeExposed changed from {:.4f} to {:.4f}. Please "
@@ -567,6 +596,16 @@ class Parameters : public ParametersBase<FP>
567596
return true;
568597
}
569598

599+
if (this->template get<TestAndTraceCapacity<FP>>() < 0.0) {
600+
log_error("Constraint check: Parameter TestAndTraceCapacity smaller {:d}", 0);
601+
return true;
602+
}
603+
604+
if (this->template get<TestAndTraceCapacityMaxRisk<FP>>() < 0.0) {
605+
log_error("Constraint check: Parameter TestAndTraceCapacityMaxRisk smaller {:d}", 0);
606+
return true;
607+
}
608+
570609
const double tol_times = 1e-1; // accepted tolerance for compartment stays
571610

572611
for (auto i = AgeGroup(0); i < AgeGroup(m_num_groups); ++i) {

cpp/models/ode_secirvvs/model.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,15 @@ class Model
183183
//symptomatic are less well quarantined when testing and tracing is overwhelmed so they infect more people
184184
auto riskFromInfectedSymptomatic =
185185
smoother_cosine(test_and_trace_required, params.template get<TestAndTraceCapacity<FP>>(),
186-
params.template get<TestAndTraceCapacity<FP>>() * 15,
186+
params.template get<TestAndTraceCapacity<FP>>() *
187+
params.template get<TestAndTraceCapacityMaxRiskSymptoms<FP>>(),
187188
params.template get<RiskOfInfectionFromSymptomatic<FP>>()[i],
188189
params.template get<MaxRiskOfInfectionFromSymptomatic<FP>>()[i]);
189190

190191
auto riskFromInfectedNoSymptoms =
191192
smoother_cosine(test_and_trace_required, params.template get<TestAndTraceCapacity<FP>>(),
192-
params.template get<TestAndTraceCapacity<FP>>() * 2,
193+
params.template get<TestAndTraceCapacity<FP>>() *
194+
params.template get<TestAndTraceCapacityMaxRiskNoSymptoms<FP>>(),
193195
params.template get<RelativeTransmissionNoSymptoms<FP>>()[i], 1.0);
194196

195197
for (auto j = AgeGroup(0); j < n_agegroups; j++) {
@@ -835,7 +837,9 @@ auto get_migration_factors(const Simulation<Base>& sim, FP /*t*/, const Eigen::R
835837
.sum();
836838
auto riskFromInfectedSymptomatic =
837839
smoother_cosine(test_and_trace_required, double(params.template get<TestAndTraceCapacity<FP>>()),
838-
params.template get<TestAndTraceCapacity<FP>>() * 5, p_inf.matrix(), p_inf_max.matrix());
840+
params.template get<TestAndTraceCapacity<FP>>() *
841+
params.template get<TestAndTraceCapacityMaxRiskSymptoms<FP>>(),
842+
p_inf.matrix(), p_inf_max.matrix());
839843

840844
//set factor for infected
841845
auto factors = Eigen::VectorXd::Ones(y.rows()).eval();

cpp/models/ode_secirvvs/parameters.h

Lines changed: 83 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,38 @@ struct TestAndTraceCapacity {
119119
}
120120
};
121121

122+
/**
123+
* @brief Multiplier for the test and trace capacity to determine when it is considered overloaded from cases without symptoms.
124+
*/
125+
template <typename FP = double>
126+
struct TestAndTraceCapacityMaxRiskNoSymptoms {
127+
using Type = UncertainValue<FP>;
128+
static Type get_default(AgeGroup)
129+
{
130+
return Type(2.0);
131+
}
132+
static std::string name()
133+
{
134+
return "TestAndTraceCapacityMaxRiskNoSymptoms";
135+
}
136+
};
137+
138+
/**
139+
* @brief Multiplier for the test and trace capacity to determine when it is considered overloaded by symptomatic cases.
140+
*/
141+
template <typename FP = double>
142+
struct TestAndTraceCapacityMaxRiskSymptoms {
143+
using Type = UncertainValue<FP>;
144+
static Type get_default(AgeGroup)
145+
{
146+
return Type(15.0);
147+
}
148+
static std::string name()
149+
{
150+
return "TestAndTraceCapacityMaxRiskSymptoms";
151+
}
152+
};
153+
122154
/**
123155
* @brief the contact patterns within the society are modelled using an UncertainContactMatrix
124156
*/
@@ -573,19 +605,18 @@ struct InfectiousnessNewVariant {
573605
};
574606

575607
template <typename FP = double>
576-
using ParametersBase =
577-
ParameterSet<StartDay, Seasonality<FP>, ICUCapacity<FP>, TestAndTraceCapacity<FP>, ContactPatterns<FP>,
578-
DynamicNPIsInfectedSymptoms<FP>, TimeExposed<FP>, TimeInfectedNoSymptoms<FP>, TimeInfectedSymptoms<FP>,
579-
TimeInfectedSevere<FP>, TimeInfectedCritical<FP>, TransmissionProbabilityOnContact<FP>,
580-
RelativeTransmissionNoSymptoms<FP>, RecoveredPerInfectedNoSymptoms<FP>,
581-
RiskOfInfectionFromSymptomatic<FP>, MaxRiskOfInfectionFromSymptomatic<FP>,
582-
SeverePerInfectedSymptoms<FP>, CriticalPerSevere<FP>, DeathsPerCritical<FP>, VaccinationGap<FP>,
583-
DaysUntilEffectivePartialImmunity<FP>, DaysUntilEffectiveImprovedImmunity<FP>,
584-
DailyFullVaccination<FP>, DailyFirstVaccination<FP>, ReducExposedPartialImmunity<FP>,
585-
ReducExposedImprovedImmunity<FP>, ReducInfectedSymptomsPartialImmunity<FP>,
586-
ReducInfectedSymptomsImprovedImmunity<FP>, ReducInfectedSevereCriticalDeadPartialImmunity<FP>,
587-
ReducInfectedSevereCriticalDeadImprovedImmunity<FP>, ReducTimeInfectedMild<FP>,
588-
InfectiousnessNewVariant<FP>, StartDayNewVariant>;
608+
using ParametersBase = ParameterSet<
609+
StartDay, Seasonality<FP>, ICUCapacity<FP>, TestAndTraceCapacity<FP>, TestAndTraceCapacityMaxRiskNoSymptoms<FP>,
610+
TestAndTraceCapacityMaxRiskSymptoms<FP>, ContactPatterns<FP>, DynamicNPIsInfectedSymptoms<FP>, TimeExposed<FP>,
611+
TimeInfectedNoSymptoms<FP>, TimeInfectedSymptoms<FP>, TimeInfectedSevere<FP>, TimeInfectedCritical<FP>,
612+
TransmissionProbabilityOnContact<FP>, RelativeTransmissionNoSymptoms<FP>, RecoveredPerInfectedNoSymptoms<FP>,
613+
RiskOfInfectionFromSymptomatic<FP>, MaxRiskOfInfectionFromSymptomatic<FP>, SeverePerInfectedSymptoms<FP>,
614+
CriticalPerSevere<FP>, DeathsPerCritical<FP>, VaccinationGap<FP>, DaysUntilEffectivePartialImmunity<FP>,
615+
DaysUntilEffectiveImprovedImmunity<FP>, DailyFullVaccination<FP>, DailyFirstVaccination<FP>,
616+
ReducExposedPartialImmunity<FP>, ReducExposedImprovedImmunity<FP>, ReducInfectedSymptomsPartialImmunity<FP>,
617+
ReducInfectedSymptomsImprovedImmunity<FP>, ReducInfectedSevereCriticalDeadPartialImmunity<FP>,
618+
ReducInfectedSevereCriticalDeadImprovedImmunity<FP>, ReducTimeInfectedMild<FP>, InfectiousnessNewVariant<FP>,
619+
StartDayNewVariant>;
589620

590621
/**
591622
* @brief Parameters of an age-resolved SECIR/SECIHURD model with paths for partial and improved immunity through vaccination.
@@ -685,6 +716,27 @@ class Parameters : public ParametersBase<FP>
685716
corrected = true;
686717
}
687718

719+
if (this->template get<TestAndTraceCapacity<FP>>() < 0.0) {
720+
log_warning("Constraint check: Parameter TestAndTraceCapacity changed from {} to {}",
721+
this->template get<TestAndTraceCapacity<FP>>(), 0);
722+
this->template set<TestAndTraceCapacity<FP>>(0);
723+
corrected = true;
724+
}
725+
726+
if (this->template get<TestAndTraceCapacityMaxRiskSymptoms<FP>>() < 0.0) {
727+
log_warning("Constraint check: Parameter TestAndTraceCapacityMaxRiskSymptoms changed from {} to {}",
728+
this->template get<TestAndTraceCapacityMaxRiskSymptoms<FP>>(), 0);
729+
this->template set<TestAndTraceCapacityMaxRiskSymptoms<FP>>(0);
730+
corrected = true;
731+
}
732+
733+
if (this->template get<TestAndTraceCapacityMaxRiskNoSymptoms<FP>>() < 0.0) {
734+
log_warning("Constraint check: Parameter TestAndTraceCapacityMaxRiskNoSymptoms changed from {} to {}",
735+
this->template get<TestAndTraceCapacityMaxRiskNoSymptoms<FP>>(), 0);
736+
this->template set<TestAndTraceCapacityMaxRiskNoSymptoms<FP>>(0);
737+
corrected = true;
738+
}
739+
688740
const double tol_times = 1e-1; // accepted tolerance for compartment stays
689741

690742
for (auto i = AgeGroup(0); i < AgeGroup(m_num_groups); ++i) {
@@ -789,7 +841,7 @@ class Parameters : public ParametersBase<FP>
789841
}
790842

791843
if (this->template get<DaysUntilEffectivePartialImmunity<FP>>()[i] < 0.0) {
792-
log_warning("Constraint check: Parameter DeathsPerCritical changed from {} to {}",
844+
log_warning("Constraint check: Parameter DaysUntilEffectivePartialImmunity changed from {} to {}",
793845
this->template get<DaysUntilEffectivePartialImmunity<FP>>()[i], 0);
794846
this->template get<DaysUntilEffectivePartialImmunity<FP>>()[i] = 0;
795847
corrected = true;
@@ -877,12 +929,27 @@ class Parameters : public ParametersBase<FP>
877929
{
878930
const double tol_times = 1e-1; // accepted tolerance for compartment stays
879931
if (this->template get<Seasonality<FP>>() < 0.0 || this->template get<Seasonality<FP>>() > 0.5) {
880-
log_error("Constraint check: Parameter m_seasonality smaller {} or larger {}", 0, 0.5);
932+
log_error("Constraint check: Parameter Seasonality smaller {} or larger {}", 0, 0.5);
881933
return true;
882934
}
883935

884936
if (this->template get<ICUCapacity<FP>>() < 0.0) {
885-
log_error("Constraint check: Parameter m_icu_capacity smaller {}", 0);
937+
log_error("Constraint check: Parameter ICUCapacity smaller {}", 0);
938+
return true;
939+
}
940+
941+
if (this->template get<TestAndTraceCapacity<FP>>() < 0.0) {
942+
log_error("Constraint check: Parameter TestAndTraceCapacity smaller {}", 0);
943+
return true;
944+
}
945+
946+
if (this->template get<TestAndTraceCapacityMaxRiskSymptoms<FP>>() < 0.0) {
947+
log_error("Constraint check: Parameter TestAndTraceCapacityMaxRiskSymptoms smaller {}", 0);
948+
return true;
949+
}
950+
951+
if (this->template get<TestAndTraceCapacityMaxRiskNoSymptoms<FP>>() < 0.0) {
952+
log_error("Constraint check: Parameter TestAndTraceCapacityMaxRiskNoSymptoms smaller {}", 0);
886953
return true;
887954
}
888955

0 commit comments

Comments
 (0)