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