Line data Source code
1 : /*
2 : * Copyright (C) 2020-2024 MEmilio
3 : *
4 : * Authors: Wadim Koslow, Daniel Abele, Martin J. Kühn
5 : *
6 : * Contact: Martin J. Kuehn <Martin.Kuehn@DLR.de>
7 : *
8 : * Licensed under the Apache License, Version 2.0 (the "License");
9 : * you may not use this file except in compliance with the License.
10 : * You may obtain a copy of the License at
11 : *
12 : * http://www.apache.org/licenses/LICENSE-2.0
13 : *
14 : * Unless required by applicable law or agreed to in writing, software
15 : * distributed under the License is distributed on an "AS IS" BASIS,
16 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 : * See the License for the specific language governing permissions and
18 : * limitations under the License.
19 : */
20 : #ifndef ODESECIRVVS_PARAMETERS_H
21 : #define ODESECIRVVS_PARAMETERS_H
22 :
23 : #include "memilio/epidemiology/age_group.h"
24 : #include "memilio/epidemiology/dynamic_npis.h"
25 : #include "memilio/epidemiology/simulation_day.h"
26 : #include "memilio/epidemiology/uncertain_matrix.h"
27 : #include "memilio/utils/custom_index_array.h"
28 : #include "memilio/utils/parameter_set.h"
29 : #include "memilio/utils/uncertain_value.h"
30 :
31 : namespace mio
32 : {
33 : namespace osecirvvs
34 : {
35 :
36 : /**
37 : * @brief the start day in the SECIRVVS model
38 : * The start day defines in which season the simulation can be started
39 : * If the start day is 180 and simulation takes place from t0=0 to
40 : * tmax=100 the days 180 to 280 of the year are simulated
41 : */
42 : struct StartDay {
43 : using Type = double;
44 275 : static Type get_default(AgeGroup)
45 : {
46 275 : return 0.;
47 : }
48 2 : static std::string name()
49 : {
50 2 : return "StartDay";
51 : }
52 : };
53 :
54 : /**
55 : * @brief the start day of a new variant in the SECIRVVS model
56 : * The start day of the new variant defines in which day of the simulation the new variant is introduced.
57 : * Starting on this day, the new variant will impact the transmission probability depending on the
58 : * infectiousness of the new variant in the parameter InfectiousnessNewVariant.
59 : */
60 : struct StartDayNewVariant {
61 : using Type = double;
62 275 : static Type get_default(AgeGroup)
63 : {
64 275 : return std::numeric_limits<double>::max();
65 : }
66 2 : static std::string name()
67 : {
68 2 : return "StartDayNewVariant";
69 : }
70 : };
71 :
72 : /**
73 : * @brief the seasonality in the SECIR model
74 : * the seasonality is given as (1+k*sin()) where the sine
75 : * curve is below one in summer and above one in winter
76 : */
77 : template <typename FP = double>
78 : struct Seasonality {
79 : using Type = UncertainValue<FP>;
80 275 : static Type get_default(AgeGroup)
81 : {
82 275 : return Type(0.);
83 : }
84 2 : static std::string name()
85 : {
86 2 : return "Seasonality";
87 : }
88 : };
89 :
90 : /**
91 : * @brief the icu capacity in the SECIR model
92 : */
93 : template <typename FP = double>
94 : struct ICUCapacity {
95 : using Type = UncertainValue<FP>;
96 275 : static Type get_default(AgeGroup)
97 : {
98 275 : return Type(std::numeric_limits<FP>::max());
99 : }
100 2 : static std::string name()
101 : {
102 2 : return "ICUCapacity";
103 : }
104 : };
105 :
106 : /**
107 : * @brief capacity to test and trace contacts of infected for quarantine per day.
108 : */
109 : template <typename FP = double>
110 : struct TestAndTraceCapacity {
111 : using Type = UncertainValue<FP>;
112 275 : static Type get_default(AgeGroup)
113 : {
114 275 : return Type(std::numeric_limits<FP>::max());
115 : }
116 2 : static std::string name()
117 : {
118 2 : return "TestAndTraceCapacity";
119 : }
120 : };
121 :
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 275 : static Type get_default(AgeGroup)
129 : {
130 275 : return Type(2.0);
131 : }
132 2 : static std::string name()
133 : {
134 2 : 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 275 : static Type get_default(AgeGroup)
145 : {
146 275 : return Type(15.0);
147 : }
148 2 : static std::string name()
149 : {
150 2 : return "TestAndTraceCapacityMaxRiskSymptoms";
151 : }
152 : };
153 :
154 : /**
155 : * @brief the contact patterns within the society are modelled using an UncertainContactMatrix
156 : */
157 : template <typename FP = double>
158 : struct ContactPatterns {
159 : using Type = UncertainContactMatrix<FP>;
160 275 : static Type get_default(AgeGroup size)
161 : {
162 275 : return Type(1, static_cast<Eigen::Index>((size_t)size));
163 : }
164 2 : static std::string name()
165 : {
166 2 : return "ContactPatterns";
167 : }
168 : };
169 :
170 : /**
171 : * @brief the NPIs that are enforced if certain infection thresholds are exceeded.
172 : */
173 : template <typename FP = double>
174 : struct DynamicNPIsInfectedSymptoms {
175 : using Type = DynamicNPIs<FP>;
176 275 : static Type get_default(AgeGroup /*size*/)
177 : {
178 275 : return {};
179 : }
180 2 : static std::string name()
181 : {
182 2 : return "DynamicNPIsInfectedSymptoms";
183 : }
184 : };
185 :
186 : /**
187 : * @brief The delay with which DynamicNPIs are implemented and enforced after exceedance of threshold.
188 : */
189 : template <typename FP = double>
190 : struct DynamicNPIsImplementationDelay {
191 : using Type = UncertainValue<FP>;
192 275 : static Type get_default(AgeGroup /*size*/)
193 : {
194 275 : return 0.;
195 : }
196 2 : static std::string name()
197 : {
198 2 : return "DynamicNPIsImplementationDelay";
199 : }
200 : };
201 :
202 : /**
203 : * @brief the (mean) latent time in day unit
204 : */
205 : template <typename FP = double>
206 : struct TimeExposed {
207 : using Type = CustomIndexArray<UncertainValue<FP>, AgeGroup>;
208 275 : static Type get_default(AgeGroup size)
209 : {
210 550 : return Type(size, 1.);
211 : }
212 2 : static std::string name()
213 : {
214 2 : return "TimeExposed";
215 : }
216 : };
217 :
218 : /**
219 : * @brief the (mean) time in day unit for asymptomatic cases that are infected but
220 : * have not yet developed symptoms.
221 : */
222 : template <typename FP = double>
223 : struct TimeInfectedNoSymptoms {
224 : using Type = CustomIndexArray<UncertainValue<FP>, AgeGroup>;
225 275 : static Type get_default(AgeGroup size)
226 : {
227 550 : return Type(size, 1.);
228 : }
229 2 : static std::string name()
230 : {
231 2 : return "TimeInfectedNoSymptoms";
232 : }
233 : };
234 :
235 : /**
236 : * @brief the infectious time for symptomatic cases that are infected but
237 : * who do not need to be hsopitalized in the SECIR model in day unit
238 : */
239 : template <typename FP = double>
240 : struct TimeInfectedSymptoms {
241 : using Type = CustomIndexArray<UncertainValue<FP>, AgeGroup>;
242 275 : static Type get_default(AgeGroup size)
243 : {
244 550 : return Type(size, 1.);
245 : }
246 2 : static std::string name()
247 : {
248 2 : return "TimeInfectedSymptoms";
249 : }
250 : };
251 :
252 : /**
253 : * @brief the time people are 'simply' hospitalized before returning home in the SECIR model
254 : * in day unit
255 : */
256 : template <typename FP = double>
257 : struct TimeInfectedSevere {
258 : using Type = CustomIndexArray<UncertainValue<FP>, AgeGroup>;
259 275 : static Type get_default(AgeGroup size)
260 : {
261 550 : return Type(size, 1.);
262 : }
263 2 : static std::string name()
264 : {
265 2 : return "TimeInfectedSevere";
266 : }
267 : };
268 :
269 : /**
270 : * @brief the time people are treated by ICU before returning home in the SECIR model
271 : * in day unit
272 : */
273 : template <typename FP = double>
274 : struct TimeInfectedCritical {
275 : using Type = CustomIndexArray<UncertainValue<FP>, AgeGroup>;
276 275 : static Type get_default(AgeGroup size)
277 : {
278 550 : return Type(size, 1.);
279 : }
280 2 : static std::string name()
281 : {
282 2 : return "TimeInfectedCritical";
283 : }
284 : };
285 :
286 : /**
287 : * @brief probability of getting infected from a contact
288 : */
289 : template <typename FP = double>
290 : struct TransmissionProbabilityOnContact {
291 : using Type = CustomIndexArray<UncertainValue<FP>, AgeGroup>;
292 275 : static Type get_default(AgeGroup size)
293 : {
294 550 : return Type(size, 1.);
295 : }
296 2 : static std::string name()
297 : {
298 2 : return "TransmissionProbabilityOnContact";
299 : }
300 : };
301 :
302 : /**
303 : * @brief the relative InfectedNoSymptoms infectability
304 : */
305 : template <typename FP = double>
306 : struct RelativeTransmissionNoSymptoms {
307 : using Type = CustomIndexArray<UncertainValue<FP>, AgeGroup>;
308 275 : static Type get_default(AgeGroup size)
309 : {
310 550 : return Type(size, 1.);
311 : }
312 2 : static std::string name()
313 : {
314 2 : return "RelativeTransmissionNoSymptoms";
315 : }
316 : };
317 :
318 : /**
319 : * @brief the percentage of asymptomatic cases in the SECIR model
320 : */
321 : template <typename FP = double>
322 : struct RecoveredPerInfectedNoSymptoms {
323 : using Type = CustomIndexArray<UncertainValue<FP>, AgeGroup>;
324 275 : static Type get_default(AgeGroup size)
325 : {
326 550 : return Type(size, 0.);
327 : }
328 2 : static std::string name()
329 : {
330 2 : return "RecoveredPerInfectedNoSymptoms";
331 : }
332 : };
333 :
334 : /**
335 : * @brief the risk of infection from symptomatic cases in the SECIR model
336 : */
337 : template <typename FP = double>
338 : struct RiskOfInfectionFromSymptomatic {
339 : using Type = CustomIndexArray<UncertainValue<FP>, AgeGroup>;
340 275 : static Type get_default(AgeGroup size)
341 : {
342 550 : return Type(size, 1.);
343 : }
344 2 : static std::string name()
345 : {
346 2 : return "RiskOfInfectionFromSymptomatic";
347 : }
348 : };
349 :
350 : /**
351 : * @brief risk of infection from symptomatic cases increases as test and trace capacity is exceeded.
352 : */
353 : template <typename FP = double>
354 : struct MaxRiskOfInfectionFromSymptomatic {
355 : using Type = CustomIndexArray<UncertainValue<FP>, AgeGroup>;
356 275 : static Type get_default(AgeGroup size)
357 : {
358 550 : return Type(size, 0.);
359 : }
360 2 : static std::string name()
361 : {
362 2 : return "MaxRiskOfInfectionFromSymptomatic";
363 : }
364 : };
365 :
366 : /**
367 : * @brief the percentage of hospitalized patients per infected patients in the SECIR model
368 : */
369 : template <typename FP = double>
370 : struct SeverePerInfectedSymptoms {
371 : using Type = CustomIndexArray<UncertainValue<FP>, AgeGroup>;
372 275 : static Type get_default(AgeGroup size)
373 : {
374 550 : return Type(size, 0.);
375 : }
376 2 : static std::string name()
377 : {
378 2 : return "SeverePerInfectedSymptoms";
379 : }
380 : };
381 :
382 : /**
383 : * @brief the percentage of ICU patients per hospitalized patients in the SECIR model
384 : */
385 : template <typename FP = double>
386 : struct CriticalPerSevere {
387 : using Type = CustomIndexArray<UncertainValue<FP>, AgeGroup>;
388 275 : static Type get_default(AgeGroup size)
389 : {
390 550 : return Type(size, 0.);
391 : }
392 2 : static std::string name()
393 : {
394 2 : return "CriticalPerSevere";
395 : }
396 : };
397 :
398 : /**
399 : * @brief the percentage of dead patients per ICU patients in the SECIR model
400 : */
401 : template <typename FP = double>
402 : struct DeathsPerCritical {
403 : using Type = CustomIndexArray<UncertainValue<FP>, AgeGroup>;
404 275 : static Type get_default(AgeGroup size)
405 : {
406 550 : return Type(size, 0.);
407 : }
408 2 : static std::string name()
409 : {
410 2 : return "DeathsPerCritical";
411 : }
412 : };
413 :
414 : /**
415 : * @brief Time in days between first and second vaccine dose.
416 : */
417 : template <typename FP = double>
418 : struct VaccinationGap {
419 : using Type = CustomIndexArray<UncertainValue<FP>, AgeGroup>;
420 275 : static Type get_default(AgeGroup size)
421 : {
422 550 : return Type(size, 49.0);
423 : }
424 2 : static std::string name()
425 : {
426 2 : return "VaccinationGap";
427 : }
428 : };
429 :
430 : /**
431 : * @brief Time in days until first vaccine dose takes full effect.
432 : */
433 : template <typename FP = double>
434 : struct DaysUntilEffectivePartialImmunity {
435 : using Type = CustomIndexArray<UncertainValue<FP>, AgeGroup>;
436 275 : static Type get_default(AgeGroup size)
437 : {
438 550 : return Type(size, 14.0);
439 : }
440 2 : static std::string name()
441 : {
442 2 : return "DaysUntilEffectivePartialImmunity";
443 : }
444 : };
445 :
446 : /**
447 : * @brief Time in days until second vaccine dose takes full effect.
448 : */
449 : template <typename FP = double>
450 : struct DaysUntilEffectiveImprovedImmunity {
451 : using Type = CustomIndexArray<UncertainValue<FP>, AgeGroup>;
452 275 : static Type get_default(AgeGroup size)
453 : {
454 550 : return Type(size, 7.0);
455 : }
456 2 : static std::string name()
457 : {
458 2 : return "DaysUntilEffectiveImprovedImmunity";
459 : }
460 : };
461 :
462 : /**
463 : * @brief Total number of first vaccinations up to the given day.
464 : */
465 : template <typename FP = double>
466 : struct DailyFirstVaccination {
467 : using Type = CustomIndexArray<FP, AgeGroup, SimulationDay>;
468 275 : static Type get_default(AgeGroup size)
469 : {
470 275 : return Type({size, SimulationDay(0)});
471 : }
472 2 : static std::string name()
473 : {
474 2 : return "DailyFirstVaccination";
475 : }
476 : };
477 :
478 : /**
479 : * @brief Total number of full vaccinations up to the given day.
480 : */
481 : template <typename FP = double>
482 : struct DailyFullVaccination {
483 : using Type = CustomIndexArray<FP, AgeGroup, SimulationDay>;
484 275 : static Type get_default(AgeGroup size)
485 : {
486 275 : return Type({size, SimulationDay(0)});
487 : }
488 2 : static std::string name()
489 : {
490 2 : return "DailyFullVaccination";
491 : }
492 : };
493 :
494 : /**
495 : * @brief Factor to reduce infection risk for persons with partial immunity.
496 : */
497 : template <typename FP = double>
498 : struct ReducExposedPartialImmunity {
499 : using Type = CustomIndexArray<UncertainValue<FP>, AgeGroup>;
500 275 : static Type get_default(AgeGroup size)
501 : {
502 550 : return Type(size, 1.);
503 : }
504 2 : static std::string name()
505 : {
506 2 : return "ReducExposedPartialImmunity";
507 : }
508 : };
509 :
510 : /**
511 : * @brief Factor to reduce infection risk for persons with improved immunity.
512 : */
513 : template <typename FP = double>
514 : struct ReducExposedImprovedImmunity {
515 : using Type = CustomIndexArray<UncertainValue<FP>, AgeGroup>;
516 275 : static Type get_default(AgeGroup size)
517 : {
518 550 : return Type(size, 1.);
519 : }
520 2 : static std::string name()
521 : {
522 2 : return "ReducExposedImprovedImmunity";
523 : }
524 : };
525 :
526 : /**
527 : * @brief Factor to reduce risk of developing symptoms for persons with partial immunity.
528 : */
529 : template <typename FP = double>
530 : struct ReducInfectedSymptomsPartialImmunity {
531 : using Type = CustomIndexArray<UncertainValue<FP>, AgeGroup>;
532 275 : static Type get_default(AgeGroup size)
533 : {
534 550 : return Type(size, 1.);
535 : }
536 2 : static std::string name()
537 : {
538 2 : return "ReducInfectedSymptomsPartialImmunity";
539 : }
540 : };
541 :
542 : /**
543 : * @brief Factor to reduce risk of developing symptoms for persons with improved immunity.
544 : */
545 : template <typename FP = double>
546 : struct ReducInfectedSymptomsImprovedImmunity {
547 : using Type = CustomIndexArray<UncertainValue<FP>, AgeGroup>;
548 275 : static Type get_default(AgeGroup size)
549 : {
550 550 : return Type(size, 1.);
551 : }
552 2 : static std::string name()
553 : {
554 2 : return "ReducInfectedSymptomsImprovedImmunity";
555 : }
556 : };
557 :
558 : /**
559 : * @brief Factor to reduce risk of hospitalization for persons with partial immunity.
560 : * Also applies to ICU and Death risk.
561 : */
562 : template <typename FP = double>
563 : struct ReducInfectedSevereCriticalDeadPartialImmunity {
564 : using Type = CustomIndexArray<UncertainValue<FP>, AgeGroup>;
565 275 : static Type get_default(AgeGroup size)
566 : {
567 550 : return Type(size, 1.);
568 : }
569 2 : static std::string name()
570 : {
571 2 : return "ReducInfectedSevereCriticalDeadPartialImmunity";
572 : }
573 : };
574 :
575 : /**
576 : * @brief Factor to reduce risk of hospitalization for persons with improved immunity.
577 : */
578 : template <typename FP = double>
579 : struct ReducInfectedSevereCriticalDeadImprovedImmunity {
580 : using Type = CustomIndexArray<UncertainValue<FP>, AgeGroup>;
581 275 : static Type get_default(AgeGroup size)
582 : {
583 550 : return Type(size, 1.);
584 : }
585 2 : static std::string name()
586 : {
587 2 : return "ReducInfectedSevereCriticalDeadImprovedImmunity";
588 : }
589 : };
590 :
591 : /**
592 : * @brief Factor to reduce infectious time of persons with partial or improved immunity.
593 : */
594 : template <typename FP = double>
595 : struct ReducTimeInfectedMild {
596 : using Type = CustomIndexArray<UncertainValue<FP>, AgeGroup>;
597 275 : static Type get_default(AgeGroup size)
598 : {
599 550 : return Type(size, 0.5);
600 : }
601 2 : static std::string name()
602 : {
603 2 : return "ReducTimeInfectedMild";
604 : }
605 : };
606 :
607 : /**
608 : * @brief Represents the relative infectiousness of a new variant.
609 : */
610 : template <typename FP = double>
611 : struct InfectiousnessNewVariant {
612 : using Type = CustomIndexArray<FP, AgeGroup>;
613 275 : static Type get_default(AgeGroup size)
614 : {
615 550 : return Type(size, 1.0);
616 : }
617 2 : static std::string name()
618 : {
619 2 : return "InfectiousnessNewVariant";
620 : }
621 : };
622 :
623 : template <typename FP = double>
624 : using ParametersBase = ParameterSet<
625 : StartDay, Seasonality<FP>, ICUCapacity<FP>, TestAndTraceCapacity<FP>, TestAndTraceCapacityMaxRiskNoSymptoms<FP>,
626 : TestAndTraceCapacityMaxRiskSymptoms<FP>, ContactPatterns<FP>, DynamicNPIsImplementationDelay<FP>,
627 : DynamicNPIsInfectedSymptoms<FP>, TimeExposed<FP>, TimeInfectedNoSymptoms<FP>, TimeInfectedSymptoms<FP>,
628 : TimeInfectedSevere<FP>, TimeInfectedCritical<FP>, TransmissionProbabilityOnContact<FP>,
629 : RelativeTransmissionNoSymptoms<FP>, RecoveredPerInfectedNoSymptoms<FP>, RiskOfInfectionFromSymptomatic<FP>,
630 : MaxRiskOfInfectionFromSymptomatic<FP>, SeverePerInfectedSymptoms<FP>, CriticalPerSevere<FP>, DeathsPerCritical<FP>,
631 : VaccinationGap<FP>, DaysUntilEffectivePartialImmunity<FP>, DaysUntilEffectiveImprovedImmunity<FP>,
632 : DailyFullVaccination<FP>, DailyFirstVaccination<FP>, ReducExposedPartialImmunity<FP>,
633 : ReducExposedImprovedImmunity<FP>, ReducInfectedSymptomsPartialImmunity<FP>,
634 : ReducInfectedSymptomsImprovedImmunity<FP>, ReducInfectedSevereCriticalDeadPartialImmunity<FP>,
635 : ReducInfectedSevereCriticalDeadImprovedImmunity<FP>, ReducTimeInfectedMild<FP>, InfectiousnessNewVariant<FP>,
636 : StartDayNewVariant>;
637 :
638 : /**
639 : * @brief Parameters of an age-resolved SECIR/SECIHURD model with paths for partial and improved immunity through vaccination.
640 : */
641 : template <typename FP = double>
642 : class Parameters : public ParametersBase<FP>
643 : {
644 : public:
645 275 : Parameters(AgeGroup num_agegroups)
646 : : ParametersBase<FP>(num_agegroups)
647 275 : , m_num_groups{num_agegroups}
648 : {
649 275 : }
650 :
651 10646 : AgeGroup get_num_groups() const
652 : {
653 10646 : return m_num_groups;
654 : }
655 :
656 : /**
657 : * Percentage of infected commuters that are not detected.
658 : */
659 18 : double& get_commuter_nondetection()
660 : {
661 18 : return m_commuter_nondetection;
662 : }
663 : double get_commuter_nondetection() const
664 : {
665 : return m_commuter_nondetection;
666 : }
667 :
668 : /**
669 : * Time in simulation before which no infected commuters are detected.
670 : */
671 64 : double& get_start_commuter_detection()
672 : {
673 64 : return m_start_commuter_detection;
674 : }
675 :
676 : double get_start_commuter_detection() const
677 : {
678 : return m_start_commuter_detection;
679 : }
680 :
681 : /**
682 : * Time in simulation after which no infected commuters are detected.
683 : */
684 64 : double& get_end_commuter_detection()
685 : {
686 64 : return m_end_commuter_detection;
687 : }
688 :
689 : double get_end_commuter_detection() const
690 : {
691 : return m_end_commuter_detection;
692 : }
693 :
694 : /**
695 : * Time in simulation after which no dynamic NPIs are applied.
696 : */
697 233 : double& get_end_dynamic_npis()
698 : {
699 233 : return m_end_dynamic_npis;
700 : }
701 : double get_end_dynamic_npis() const
702 : {
703 : return m_end_dynamic_npis;
704 : }
705 :
706 : /**
707 : * @brief Checks whether all Parameters satisfy their corresponding constraints and applies them, if they do not.
708 : * Time spans cannot be negative and probabilities can only take values between [0,1].
709 : *
710 : * Attention: This function should be used with care. It is necessary for some test problems to run through quickly,
711 : * but in a manual execution of an example, check_constraints() may be preferred. Note that the apply_constraints()
712 : * function can and will not set Parameters to meaningful values in an epidemiological or virological context,
713 : * as all models are designed to be transferable to multiple diseases. Consequently, only acceptable
714 : * (like 0 or 1 for probabilities or small positive values for time spans) values are set here and a manual adaptation
715 : * may often be necessary to have set meaningful values.
716 : *
717 : * @return Returns true if one ore more constraint were corrected, false otherwise.
718 : */
719 567 : bool apply_constraints()
720 : {
721 567 : int corrected = false;
722 567 : if (this->template get<Seasonality<FP>>() < 0.0 || this->template get<Seasonality<FP>>() > 0.5) {
723 18 : log_warning("Constraint check: Parameter Seasonality changed from {} to {}",
724 18 : this->template get<Seasonality<FP>>(), 0);
725 9 : this->template set<Seasonality<FP>>(0);
726 9 : corrected = true;
727 : }
728 :
729 567 : if (this->template get<ICUCapacity<FP>>() < 0.0) {
730 18 : log_warning("Constraint check: Parameter ICUCapacity changed from {} to {}",
731 18 : this->template get<ICUCapacity<FP>>(), 0);
732 9 : this->template set<ICUCapacity<FP>>(0);
733 9 : corrected = true;
734 : }
735 :
736 567 : if (this->template get<TestAndTraceCapacity<FP>>() < 0.0) {
737 18 : log_warning("Constraint check: Parameter TestAndTraceCapacity changed from {} to {}",
738 18 : this->template get<TestAndTraceCapacity<FP>>(), 0);
739 9 : this->template set<TestAndTraceCapacity<FP>>(0);
740 9 : corrected = true;
741 : }
742 :
743 567 : if (this->template get<TestAndTraceCapacityMaxRiskSymptoms<FP>>() < 0.0) {
744 18 : log_warning("Constraint check: Parameter TestAndTraceCapacityMaxRiskSymptoms changed from {} to {}",
745 18 : this->template get<TestAndTraceCapacityMaxRiskSymptoms<FP>>(), 0);
746 9 : this->template set<TestAndTraceCapacityMaxRiskSymptoms<FP>>(0);
747 9 : corrected = true;
748 : }
749 :
750 567 : if (this->template get<TestAndTraceCapacityMaxRiskNoSymptoms<FP>>() < 0.0) {
751 18 : log_warning("Constraint check: Parameter TestAndTraceCapacityMaxRiskNoSymptoms changed from {} to {}",
752 18 : this->template get<TestAndTraceCapacityMaxRiskNoSymptoms<FP>>(), 0);
753 9 : this->template set<TestAndTraceCapacityMaxRiskNoSymptoms<FP>>(0);
754 9 : corrected = true;
755 : }
756 :
757 567 : if (this->template get<DynamicNPIsImplementationDelay<FP>>() < 0.0) {
758 18 : log_warning("Constraint check: Parameter DynamicNPIsImplementationDelay changed from {} to {}",
759 18 : this->template get<DynamicNPIsImplementationDelay<FP>>(), 0);
760 9 : this->template set<DynamicNPIsImplementationDelay<FP>>(0);
761 9 : corrected = true;
762 : }
763 :
764 567 : const double tol_times = 1e-1; // accepted tolerance for compartment stays
765 :
766 2259 : for (auto i = AgeGroup(0); i < AgeGroup(m_num_groups); ++i) {
767 1692 : if (this->template get<TimeExposed<FP>>()[i] < tol_times) {
768 18 : log_warning("Constraint check: Parameter TimeExposed changed from {:.4f} to {:.4f}. Please "
769 : "note that unreasonably small compartment stays lead to massively increased run time. "
770 : "Consider to cancel and reset parameters.",
771 9 : this->template get<TimeExposed<FP>>()[i], tol_times);
772 9 : this->template get<TimeExposed<FP>>()[i] = tol_times;
773 9 : corrected = true;
774 : }
775 :
776 1692 : if (this->template get<TimeInfectedNoSymptoms<FP>>()[i] < tol_times) {
777 18 : log_warning("Constraint check: Parameter TimeInfectedNoSymptoms changed from {:.4f} to {:.4f}. Please "
778 : "note that unreasonably small compartment stays lead to massively increased run time. "
779 : "Consider to cancel and reset parameters.",
780 9 : this->template get<TimeInfectedNoSymptoms<FP>>()[i], tol_times);
781 9 : this->template get<TimeInfectedNoSymptoms<FP>>()[i] = tol_times;
782 9 : corrected = true;
783 : }
784 :
785 1692 : if (this->template get<TimeInfectedSymptoms<FP>>()[i] < tol_times) {
786 18 : log_warning("Constraint check: Parameter TimeInfectedSymptoms changed from {} to {}. Please "
787 : "note that unreasonably small compartment stays lead to massively increased run time. "
788 : "Consider to cancel and reset parameters.",
789 9 : this->template get<TimeInfectedSymptoms<FP>>()[i], tol_times);
790 9 : this->template get<TimeInfectedSymptoms<FP>>()[i] = tol_times;
791 9 : corrected = true;
792 : }
793 :
794 1692 : if (this->template get<TimeInfectedSevere<FP>>()[i] < tol_times) {
795 18 : log_warning("Constraint check: Parameter TimeInfectedSevere changed from {} to {}. Please "
796 : "note that unreasonably small compartment stays lead to massively increased run time. "
797 : "Consider to cancel and reset parameters.",
798 9 : this->template get<TimeInfectedSevere<FP>>()[i], tol_times);
799 9 : this->template get<TimeInfectedSevere<FP>>()[i] = tol_times;
800 9 : corrected = true;
801 : }
802 :
803 1692 : if (this->template get<TimeInfectedCritical<FP>>()[i] < tol_times) {
804 18 : log_warning("Constraint check: Parameter TimeInfectedCritical changed from {} to {}. Please "
805 : "note that unreasonably small compartment stays lead to massively increased run time. "
806 : "Consider to cancel and reset parameters.",
807 9 : this->template get<TimeInfectedCritical<FP>>()[i], tol_times);
808 9 : this->template get<TimeInfectedCritical<FP>>()[i] = tol_times;
809 9 : corrected = true;
810 : }
811 :
812 3384 : if (this->template get<TransmissionProbabilityOnContact<FP>>()[i] < 0.0 ||
813 1692 : this->template get<TransmissionProbabilityOnContact<FP>>()[i] > 1.0) {
814 18 : log_warning("Constraint check: Parameter TransmissionProbabilityOnContact changed from {} to {} ",
815 18 : this->template get<TransmissionProbabilityOnContact<FP>>()[i], 0.0);
816 9 : this->template get<TransmissionProbabilityOnContact<FP>>()[i] = 0.0;
817 9 : corrected = true;
818 : }
819 :
820 1692 : if (this->template get<RelativeTransmissionNoSymptoms<FP>>()[i] < 0.0) {
821 18 : log_warning("Constraint check: Parameter RelativeTransmissionNoSymptoms changed from {} to {} ",
822 18 : this->template get<RelativeTransmissionNoSymptoms<FP>>()[i], 0);
823 9 : this->template get<RelativeTransmissionNoSymptoms<FP>>()[i] = 0;
824 9 : corrected = true;
825 : }
826 :
827 3384 : if (this->template get<RecoveredPerInfectedNoSymptoms<FP>>()[i] < 0.0 ||
828 1692 : this->template get<RecoveredPerInfectedNoSymptoms<FP>>()[i] > 1.0) {
829 18 : log_warning("Constraint check: Parameter RecoveredPerInfectedNoSymptoms changed from {} to {} ",
830 18 : this->template get<RecoveredPerInfectedNoSymptoms<FP>>()[i], 0);
831 9 : this->template get<RecoveredPerInfectedNoSymptoms<FP>>()[i] = 0;
832 9 : corrected = true;
833 : }
834 :
835 3375 : if (this->template get<RiskOfInfectionFromSymptomatic<FP>>()[i] < 0.0 ||
836 1683 : this->template get<RiskOfInfectionFromSymptomatic<FP>>()[i] > 1.0) {
837 18 : log_warning("Constraint check: Parameter RiskOfInfectionFromSymptomatic changed from {} to {}",
838 18 : this->template get<RiskOfInfectionFromSymptomatic<FP>>()[i], 0);
839 9 : this->template get<RiskOfInfectionFromSymptomatic<FP>>()[i] = 0;
840 9 : corrected = true;
841 : }
842 :
843 3375 : if (this->template get<SeverePerInfectedSymptoms<FP>>()[i] < 0.0 ||
844 1683 : this->template get<SeverePerInfectedSymptoms<FP>>()[i] > 1.0) {
845 18 : log_warning("Constraint check: Parameter SeverePerInfectedSymptoms changed from {} to {}",
846 18 : this->template get<SeverePerInfectedSymptoms<FP>>()[i], 0);
847 9 : this->template get<SeverePerInfectedSymptoms<FP>>()[i] = 0;
848 9 : corrected = true;
849 : }
850 :
851 3375 : if (this->template get<CriticalPerSevere<FP>>()[i] < 0.0 ||
852 1683 : this->template get<CriticalPerSevere<FP>>()[i] > 1.0) {
853 18 : log_warning("Constraint check: Parameter CriticalPerSevere changed from {} to {}",
854 18 : this->template get<CriticalPerSevere<FP>>()[i], 0);
855 9 : this->template get<CriticalPerSevere<FP>>()[i] = 0;
856 9 : corrected = true;
857 : }
858 :
859 3384 : if (this->template get<DeathsPerCritical<FP>>()[i] < 0.0 ||
860 1692 : this->template get<DeathsPerCritical<FP>>()[i] > 1.0) {
861 18 : log_warning("Constraint check: Parameter DeathsPerCritical changed from {} to {}",
862 18 : this->template get<DeathsPerCritical<FP>>()[i], 0);
863 9 : this->template get<DeathsPerCritical<FP>>()[i] = 0;
864 9 : corrected = true;
865 : }
866 :
867 1692 : if (this->template get<DaysUntilEffectivePartialImmunity<FP>>()[i] < 0.0) {
868 18 : log_warning("Constraint check: Parameter DaysUntilEffectivePartialImmunity changed from {} to {}",
869 18 : this->template get<DaysUntilEffectivePartialImmunity<FP>>()[i], 0);
870 9 : this->template get<DaysUntilEffectivePartialImmunity<FP>>()[i] = 0;
871 9 : corrected = true;
872 : }
873 1692 : if (this->template get<DaysUntilEffectiveImprovedImmunity<FP>>()[i] < 0.0) {
874 18 : log_warning("Constraint check: Parameter DaysUntilEffectiveImprovedImmunity changed from {} to {}",
875 18 : this->template get<DaysUntilEffectiveImprovedImmunity<FP>>()[i], 0);
876 9 : this->template get<DaysUntilEffectiveImprovedImmunity<FP>>()[i] = 0;
877 9 : corrected = true;
878 : }
879 :
880 3375 : if (this->template get<ReducExposedPartialImmunity<FP>>()[i] <= 0.0 ||
881 1683 : this->template get<ReducExposedPartialImmunity<FP>>()[i] > 1.0) {
882 18 : log_warning("Constraint check: Parameter ReducExposedPartialImmunity changed from {} to {}",
883 18 : this->template get<ReducExposedPartialImmunity<FP>>()[i], 1);
884 9 : this->template get<ReducExposedPartialImmunity<FP>>()[i] = 1;
885 9 : corrected = true;
886 : }
887 3375 : if (this->template get<ReducExposedImprovedImmunity<FP>>()[i] <= 0.0 ||
888 1683 : this->template get<ReducExposedImprovedImmunity<FP>>()[i] > 1.0) {
889 18 : log_warning("Constraint check: Parameter ReducExposedImprovedImmunity changed from {} to {}",
890 18 : this->template get<ReducExposedImprovedImmunity<FP>>()[i], 1);
891 9 : this->template get<ReducExposedImprovedImmunity<FP>>()[i] = 1;
892 9 : corrected = true;
893 : }
894 3375 : if (this->template get<ReducInfectedSymptomsPartialImmunity<FP>>()[i] <= 0.0 ||
895 1683 : this->template get<ReducInfectedSymptomsPartialImmunity<FP>>()[i] > 1.0) {
896 18 : log_warning("Constraint check: Parameter ReducInfectedSymptomsPartialImmunity changed from {} to {}",
897 18 : this->template get<ReducInfectedSymptomsPartialImmunity<FP>>()[i], 1);
898 9 : this->template get<ReducInfectedSymptomsPartialImmunity<FP>>()[i] = 1;
899 9 : corrected = true;
900 : }
901 3366 : if (this->template get<ReducInfectedSymptomsImprovedImmunity<FP>>()[i] <= 0.0 ||
902 1674 : this->template get<ReducInfectedSymptomsImprovedImmunity<FP>>()[i] > 1.0) {
903 36 : log_warning("Constraint check: Parameter ReducInfectedSymptomsImprovedImmunity changed from {} to {}",
904 36 : this->template get<ReducInfectedSymptomsImprovedImmunity<FP>>()[i], 1.0);
905 18 : this->template get<ReducInfectedSymptomsImprovedImmunity<FP>>()[i] = 1.0;
906 18 : corrected = true;
907 : }
908 3366 : if (this->template get<ReducInfectedSevereCriticalDeadPartialImmunity<FP>>()[i] <= 0.0 ||
909 1674 : this->template get<ReducInfectedSevereCriticalDeadPartialImmunity<FP>>()[i] > 1.0) {
910 36 : log_warning("Constraint check: Parameter ReducInfectedSevereCriticalDeadPartialImmunity changed from "
911 : "{} to {}",
912 36 : this->template get<ReducInfectedSevereCriticalDeadPartialImmunity<FP>>()[i], 1.0);
913 18 : this->template get<ReducInfectedSevereCriticalDeadPartialImmunity<FP>>()[i] = 1.0;
914 18 : corrected = true;
915 : }
916 3366 : if (this->template get<ReducInfectedSevereCriticalDeadImprovedImmunity<FP>>()[i] <= 0.0 ||
917 1674 : this->template get<ReducInfectedSevereCriticalDeadImprovedImmunity<FP>>()[i] > 1.0) {
918 36 : log_warning("Constraint check: Parameter ReducInfectedSevereCriticalDeadImprovedImmunity changed from "
919 : "{} to {}",
920 36 : this->template get<ReducInfectedSevereCriticalDeadImprovedImmunity<FP>>()[i], 1.0);
921 18 : this->template get<ReducInfectedSevereCriticalDeadImprovedImmunity<FP>>()[i] = 1.0;
922 18 : corrected = true;
923 : }
924 3375 : if (this->template get<ReducTimeInfectedMild<FP>>()[i] <= 0.0 ||
925 1683 : this->template get<ReducTimeInfectedMild<FP>>()[i] > 1.0) {
926 234 : log_warning("Constraint check: Parameter ReducTimeInfectedMild changed from {} to {}",
927 234 : this->template get<ReducTimeInfectedMild<FP>>()[i], 1.0);
928 117 : this->template get<ReducTimeInfectedMild<FP>>()[i] = 1.0;
929 117 : corrected = true;
930 : }
931 1692 : if (this->template get<InfectiousnessNewVariant<FP>>()[i] < 0.0) {
932 18 : log_warning("Constraint check: Parameter InfectiousnessNewVariant changed from {} to {}",
933 18 : this->template get<InfectiousnessNewVariant<FP>>()[i], 1.0);
934 9 : this->template get<InfectiousnessNewVariant<FP>>()[i] = 1.0;
935 9 : corrected = true;
936 : }
937 1692 : if (this->template get<VaccinationGap<FP>>()[i] < 0.0) {
938 18 : log_warning("Constraint check: Parameter VaccinationGap changed from {} to {}",
939 18 : this->template get<VaccinationGap<FP>>()[i], 0);
940 9 : this->template get<VaccinationGap<FP>>()[i] = 0;
941 9 : corrected = true;
942 : }
943 : }
944 567 : return corrected;
945 : }
946 :
947 : /**
948 : * @brief Checks whether all Parameters satisfy their corresponding constraints and logs an error
949 : * if constraints are not satisfied.
950 : * @return Returns true if one constraint is not satisfied, otherwise false.
951 : */
952 306 : bool check_constraints() const
953 : {
954 306 : const double tol_times = 1e-1; // accepted tolerance for compartment stays
955 306 : if (this->template get<Seasonality<FP>>() < 0.0 || this->template get<Seasonality<FP>>() > 0.5) {
956 18 : log_error("Constraint check: Parameter Seasonality smaller {} or larger {}", 0, 0.5);
957 9 : return true;
958 : }
959 :
960 297 : if (this->template get<ICUCapacity<FP>>() < 0.0) {
961 18 : log_error("Constraint check: Parameter ICUCapacity smaller {}", 0);
962 9 : return true;
963 : }
964 :
965 288 : if (this->template get<TestAndTraceCapacity<FP>>() < 0.0) {
966 18 : log_error("Constraint check: Parameter TestAndTraceCapacity smaller {}", 0);
967 9 : return true;
968 : }
969 :
970 279 : if (this->template get<TestAndTraceCapacityMaxRiskSymptoms<FP>>() < 0.0) {
971 18 : log_error("Constraint check: Parameter TestAndTraceCapacityMaxRiskSymptoms smaller {}", 0);
972 9 : return true;
973 : }
974 :
975 270 : if (this->template get<TestAndTraceCapacityMaxRiskNoSymptoms<FP>>() < 0.0) {
976 18 : log_error("Constraint check: Parameter TestAndTraceCapacityMaxRiskNoSymptoms smaller {}", 0);
977 9 : return true;
978 : }
979 :
980 261 : if (this->template get<DynamicNPIsImplementationDelay<FP>>() < 0.0) {
981 18 : log_error("Constraint check: Parameter DynamicNPIsImplementationDelay smaller {:d}", 0);
982 9 : return true;
983 : }
984 :
985 324 : for (auto i = AgeGroup(0); i < AgeGroup(m_num_groups); ++i) {
986 :
987 279 : if (this->template get<TimeExposed<FP>>()[i] < tol_times) {
988 18 : log_error("Constraint check: Parameter TimeExposed {:.4f} smaller {:.4f}. Please "
989 : "note that unreasonably small compartment stays lead to massively increased run time. "
990 : "Consider to cancel and reset parameters.",
991 9 : this->template get<TimeExposed<FP>>()[i], tol_times);
992 9 : return true;
993 : }
994 :
995 270 : if (this->template get<TimeInfectedNoSymptoms<FP>>()[i] < tol_times) {
996 18 : log_error("Constraint check: Parameter TimeInfectedNoSymptoms {:.4f} smaller {:.4f}. Please "
997 : "note that unreasonably small compartment stays lead to massively increased run time. "
998 : "Consider to cancel and reset parameters.",
999 9 : this->template get<TimeInfectedNoSymptoms<FP>>()[i], tol_times);
1000 9 : return true;
1001 : }
1002 :
1003 261 : if (this->template get<TimeInfectedSymptoms<FP>>()[i] < tol_times) {
1004 18 : log_error("Constraint check: Parameter TimeInfectedSymptoms {} smaller {}. Please "
1005 : "note that unreasonably small compartment stays lead to massively increased run time. "
1006 : "Consider to cancel and reset parameters.",
1007 9 : this->template get<TimeInfectedSymptoms<FP>>()[i], tol_times);
1008 9 : return true;
1009 : }
1010 :
1011 252 : if (this->template get<TimeInfectedSevere<FP>>()[i] < tol_times) {
1012 18 : log_error("Constraint check: Parameter TimeInfectedSevere {} smaller {}. Please "
1013 : "note that unreasonably small compartment stays lead to massively increased run time. "
1014 : "Consider to cancel and reset parameters.",
1015 9 : this->template get<TimeInfectedSevere<FP>>()[i], tol_times);
1016 9 : return true;
1017 : }
1018 :
1019 243 : if (this->template get<TimeInfectedCritical<FP>>()[i] < tol_times) {
1020 18 : log_error("Constraint check: Parameter TimeInfectedCritical {} smaller {}. Please "
1021 : "note that unreasonably small compartment stays lead to massively increased run time. "
1022 : "Consider to cancel and reset parameters.",
1023 9 : this->template get<TimeInfectedCritical<FP>>()[i], tol_times);
1024 9 : return true;
1025 : }
1026 :
1027 468 : if (this->template get<TransmissionProbabilityOnContact<FP>>()[i] < 0.0 ||
1028 234 : this->template get<TransmissionProbabilityOnContact<FP>>()[i] > 1.0) {
1029 18 : log_error("Constraint check: Parameter TransmissionProbabilityOnContact smaller {} or larger {}", 0, 1);
1030 9 : return true;
1031 : }
1032 :
1033 225 : if (this->template get<RelativeTransmissionNoSymptoms<FP>>()[i] < 0.0) {
1034 18 : log_error("Constraint check: Parameter RelativeTransmissionNoSymptoms smaller {}", 0);
1035 9 : return true;
1036 : }
1037 :
1038 432 : if (this->template get<RecoveredPerInfectedNoSymptoms<FP>>()[i] < 0.0 ||
1039 216 : this->template get<RecoveredPerInfectedNoSymptoms<FP>>()[i] > 1.0) {
1040 18 : log_error("Constraint check: Parameter RecoveredPerInfectedNoSymptoms smaller {} or larger {}", 0, 1);
1041 9 : return true;
1042 : }
1043 :
1044 405 : if (this->template get<RiskOfInfectionFromSymptomatic<FP>>()[i] < 0.0 ||
1045 198 : this->template get<RiskOfInfectionFromSymptomatic<FP>>()[i] > 1.0) {
1046 18 : log_error("Constraint check: Parameter RiskOfInfectionFromSymptomatic smaller {} or larger {}", 0, 1);
1047 9 : return true;
1048 : }
1049 :
1050 387 : if (this->template get<SeverePerInfectedSymptoms<FP>>()[i] < 0.0 ||
1051 189 : this->template get<SeverePerInfectedSymptoms<FP>>()[i] > 1.0) {
1052 18 : log_error("Constraint check: Parameter SeverePerInfectedSymptoms smaller {} or larger {}", 0, 1);
1053 9 : return true;
1054 : }
1055 :
1056 369 : if (this->template get<CriticalPerSevere<FP>>()[i] < 0.0 ||
1057 180 : this->template get<CriticalPerSevere<FP>>()[i] > 1.0) {
1058 18 : log_error("Constraint check: Parameter CriticalPerSevere smaller {} or larger {}", 0, 1);
1059 9 : return true;
1060 : }
1061 :
1062 360 : if (this->template get<DeathsPerCritical<FP>>()[i] < 0.0 ||
1063 180 : this->template get<DeathsPerCritical<FP>>()[i] > 1.0) {
1064 18 : log_error("Constraint check: Parameter DeathsPerCritical smaller {} or larger {}", 0, 1);
1065 9 : return true;
1066 : }
1067 :
1068 171 : if (this->template get<VaccinationGap<FP>>()[i] < 1) {
1069 18 : log_error("Constraint check: Parameter VaccinationGap smaller {}", 1);
1070 9 : return true;
1071 : }
1072 :
1073 162 : if (this->template get<DaysUntilEffectivePartialImmunity<FP>>()[i] < 0.0) {
1074 18 : log_error("Constraint check: Parameter DaysUntilEffectivePartialImmunity smaller {}", 0);
1075 9 : return true;
1076 : }
1077 153 : if (this->template get<DaysUntilEffectiveImprovedImmunity<FP>>()[i] < 0.0) {
1078 18 : log_error("Constraint check: Parameter DaysUntilEffectiveImprovedImmunity smaller {}", 0);
1079 9 : return true;
1080 : }
1081 :
1082 279 : if (this->template get<ReducExposedPartialImmunity<FP>>()[i] <= 0.0 ||
1083 135 : this->template get<ReducExposedPartialImmunity<FP>>()[i] > 1.0) {
1084 18 : log_error("Constraint check: Parameter ReducExposedPartialImmunity smaller {} or larger {}", 0, 1);
1085 9 : return true;
1086 : }
1087 261 : if (this->template get<ReducExposedImprovedImmunity<FP>>()[i] <= 0.0 ||
1088 126 : this->template get<ReducExposedImprovedImmunity<FP>>()[i] > 1.0) {
1089 18 : log_error("Constraint check: Parameter ReducExposedImprovedImmunity smaller {} or larger {}", 0, 1);
1090 9 : return true;
1091 : }
1092 243 : if (this->template get<ReducInfectedSymptomsPartialImmunity<FP>>()[i] <= 0.0 ||
1093 117 : this->template get<ReducInfectedSymptomsPartialImmunity<FP>>()[i] > 1.0) {
1094 18 : log_error("Constraint check: Parameter ReducInfectedSymptomsPartialImmunity smaller {} or larger {}", 0,
1095 18 : 1);
1096 9 : return true;
1097 : }
1098 225 : if (this->template get<ReducInfectedSymptomsImprovedImmunity<FP>>()[i] <= 0.0 ||
1099 108 : this->template get<ReducInfectedSymptomsImprovedImmunity<FP>>()[i] > 1.0) {
1100 18 : log_error("Constraint check: Parameter ReducInfectedSymptomsImprovedImmunity smaller {} or larger {}",
1101 18 : 0, 1);
1102 9 : return true;
1103 : }
1104 207 : if (this->template get<ReducInfectedSevereCriticalDeadPartialImmunity<FP>>()[i] <= 0.0 ||
1105 99 : this->template get<ReducInfectedSevereCriticalDeadPartialImmunity<FP>>()[i] > 1.0) {
1106 18 : log_error("Constraint check: Parameter ReducInfectedSevereCriticalDeadPartialImmunity smaller {} or "
1107 : "larger {}",
1108 18 : 0, 1);
1109 9 : return true;
1110 : }
1111 189 : if (this->template get<ReducInfectedSevereCriticalDeadImprovedImmunity<FP>>()[i] <= 0.0 ||
1112 90 : this->template get<ReducInfectedSevereCriticalDeadImprovedImmunity<FP>>()[i] > 1.0) {
1113 18 : log_error("Constraint check: Parameter ReducInfectedSevereCriticalDeadImprovedImmunity smaller {} or "
1114 : "larger {}",
1115 18 : 0, 1);
1116 9 : return true;
1117 : }
1118 171 : if (this->template get<ReducTimeInfectedMild<FP>>()[i] <= 0.0 ||
1119 81 : this->template get<ReducTimeInfectedMild<FP>>()[i] > 1.0) {
1120 18 : log_error("Constraint check: Parameter ReducTimeInfectedMild smaller {} or larger {}", 0, 1);
1121 9 : return true;
1122 : }
1123 81 : if (this->template get<InfectiousnessNewVariant<FP>>()[i] < 0.0) {
1124 18 : log_error("Constraint check: Parameter InfectiousnessNewVariant smaller {}", 0);
1125 9 : return true;
1126 : }
1127 : }
1128 45 : return false;
1129 : }
1130 :
1131 : private:
1132 1 : Parameters(ParametersBase<FP>&& base)
1133 1 : : ParametersBase<FP>(std::move(base))
1134 2 : , m_num_groups(this->template get<ContactPatterns<FP>>().get_cont_freq_mat().get_num_groups())
1135 : {
1136 1 : }
1137 :
1138 : public:
1139 : /**
1140 : * deserialize an object of this class.
1141 : * @see epi::deserialize
1142 : */
1143 : template <class IOContext>
1144 1 : static IOResult<Parameters> deserialize(IOContext& io)
1145 : {
1146 1 : BOOST_OUTCOME_TRY(auto&& base, ParametersBase<FP>::deserialize(io));
1147 1 : return success(Parameters(std::move(base)));
1148 1 : }
1149 :
1150 : private:
1151 : AgeGroup m_num_groups;
1152 : double m_commuter_nondetection = 0.0;
1153 : double m_start_commuter_detection = 0.0;
1154 : double m_end_commuter_detection = 0.0;
1155 : double m_end_dynamic_npis = std::numeric_limits<double>::max();
1156 : };
1157 :
1158 : } // namespace osecirvvs
1159 : } // namespace mio
1160 :
1161 : #endif // ODESECIRVVS_PARAMETERS_H
|