Skip to content

Commit 68cbd91

Browse files
authored
738 fix check constraints in parameters in IDE-SECIR (#739)
1 parent 172cfdd commit 68cbd91

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

cpp/models/ide_secir/model.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class Model
9797
"Initialization failed. Not enough time points for transitions given before start of simulation.");
9898
}
9999

100-
parameters.check_constraints(dt);
100+
parameters.check_constraints();
101101
}
102102

103103
/**

cpp/models/ide_secir/parameters.h

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,13 @@ class Parameters : public ParametersBase
171171
* @param dt Time step size which is used to get model specific StateAgeFunction%s support.
172172
* @return Returns true if one (or more) constraint(s) are not satisfied, otherwise false.
173173
*/
174-
bool check_constraints(ScalarType dt = 0.1) const
174+
bool check_constraints() const
175175
{
176-
size_t check_eval_min = 50; // parameter defining minimal window on x-axis
177-
for (size_t i = 0;
178-
i < std::min(check_eval_min, (size_t)this->get<TransmissionProbabilityOnContact>().get_support_max(dt));
179-
i++) {
176+
// For parameters potentially depending on the infectious age, values are checked
177+
// equidistantly on a realistic maximum window.
178+
// Please note that this is an incomplete check on correctness.
179+
size_t infectious_window_check = 50; // parameter defining minimal window on x-axis
180+
for (size_t i = 0; i < infectious_window_check; i++) {
180181
if (this->get<TransmissionProbabilityOnContact>().eval((ScalarType)i) < 0.0 ||
181182
this->get<TransmissionProbabilityOnContact>().eval((ScalarType)i) > 1.0) {
182183
log_error("Constraint check: TransmissionProbabilityOnContact smaller {:d} or larger {:d} at some "
@@ -186,9 +187,7 @@ class Parameters : public ParametersBase
186187
}
187188
}
188189

189-
for (size_t i = 0;
190-
i < std::min(check_eval_min, (size_t)this->get<RelativeTransmissionNoSymptoms>().get_support_max(dt));
191-
i++) {
190+
for (size_t i = 0; i < infectious_window_check; i++) {
192191
if (this->get<RelativeTransmissionNoSymptoms>().eval((ScalarType)i) < 0.0 ||
193192
this->get<RelativeTransmissionNoSymptoms>().eval((ScalarType)i) > 1.0) {
194193
log_error("Constraint check: RelativeTransmissionNoSymptoms smaller {:d} or larger {:d} at some "
@@ -198,9 +197,7 @@ class Parameters : public ParametersBase
198197
}
199198
}
200199

201-
for (size_t i = 0;
202-
i < std::min(check_eval_min, (size_t)this->get<RiskOfInfectionFromSymptomatic>().get_support_max(dt));
203-
i++) {
200+
for (size_t i = 0; i < infectious_window_check; i++) {
204201
if (this->get<RiskOfInfectionFromSymptomatic>().eval((ScalarType)i) < 0.0 ||
205202
this->get<RiskOfInfectionFromSymptomatic>().eval((ScalarType)i) > 1.0) {
206203
log_error("Constraint check: RiskOfInfectionFromSymptomatic smaller {:d} or larger {:d} at some "

0 commit comments

Comments
 (0)