parameters.h Source File

CPP API: parameters.h Source File
ode_seirv/parameters.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2020-2026 MEmilio
3 *
4 * Authors: Henrik Zunker
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 SEIRV_PARAMETERS_H
21 #define SEIRV_PARAMETERS_H
22 
23 #include "memilio/config.h"
29 
30 namespace mio
31 {
32 namespace oseirv
33 {
34 
41 template <class FP>
45  {
46  return Type(1.0);
47  }
48  static std::string name()
49  {
50  return "BaselineTransmissibility";
51  }
52 };
53 
59 template <class FP>
60 struct TimeExposed {
63  {
64  return Type(2.0);
65  }
66  static std::string name()
67  {
68  return "TimeExposed";
69  }
70 };
71 
78 template <class FP>
79 struct TimeInfected {
82  {
83  return Type(2.0);
84  }
85  static std::string name()
86  {
87  return "TimeInfected";
88  }
89 };
90 
97 template <class FP>
101  {
102  return Type(0.0);
103  }
104  static std::string name()
105  {
106  return "SeasonalityAmplitude";
107  }
108 };
109 
115 template <class FP>
119  {
120  return Type(0.0);
121  }
122  static std::string name()
123  {
124  return "SeasonalityShiftPerSubtype";
125  }
126 };
127 
133 template <class FP>
137  {
138  return Type(0.0);
139  }
140  static std::string name()
141  {
142  return "SeasonalityShiftPerSeason";
143  }
144 };
145 
153 template <class FP>
154 struct OutsideFoI {
157  {
158  return Type(0.0);
159  }
160  static std::string name()
161  {
162  return "OutsideFoI";
163  }
164 };
165 
171 template <class FP>
175  {
176  return Type(1.0);
177  }
178  static std::string name()
179  {
180  return "ClusteringExponent";
181  }
182 };
183 
190 template <class FP>
191 struct SickMixing {
194  {
195  return Type(1.0);
196  }
197  static std::string name()
198  {
199  return "SickMixing";
200  }
201 };
202 
208 template <class FP>
212  {
213  return Type(1, static_cast<Eigen::Index>((size_t)size));
214  }
215  static std::string name()
216  {
217  return "ContactPatternsHealthy";
218  }
219 };
220 
227 template <class FP>
231  {
232  return Type(1, static_cast<Eigen::Index>((size_t)size));
233  }
234  static std::string name()
235  {
236  return "ContactPatternsSick";
237  }
238 };
239 
246 template <class FP>
250  {
251  return Type(size, 1.0);
252  }
253  static std::string name()
254  {
255  return "SusceptibilityByAge";
256  }
257 };
258 
265 template <class FP>
269  {
270  return Type(size, 0.0);
271  }
272  static std::string name()
273  {
274  return "VaccineCoverage";
275  }
276 };
277 
283 template <class FP>
287  {
288  return Type(size, 0.0);
289  }
290  static std::string name()
291  {
292  return "VaccineEffectiveness";
293  }
294 };
295 
299 template <class FP>
303  {
304  return Type(1.0);
305  }
306  static std::string name()
307  {
308  return "SusceptibleFraction";
309  }
310 };
311 
312 template <class FP>
318 
325 template <class FP>
326 class Parameters : public ParametersBase<FP>
327 {
328 public:
334  : ParametersBase<FP>(ng)
335  , m_num_groups{ng}
336  {
337  }
338 
343  {
344  return m_num_groups;
345  }
346 
361  {
362  const FP tol_times = 1e-1;
363 
364  bool corrected = false;
365  if (this->template get<TimeExposed<FP>>() < tol_times) {
366  log_warning("Constraint check: Parameter TimeExposed changed from {} to {}. Please note that "
367  "unreasonably small compartment stays lead to massively increased run time. Consider to cancel "
368  "and reset parameters.",
369  this->template get<TimeExposed<FP>>(), tol_times);
370  this->template get<TimeExposed<FP>>() = tol_times;
371  corrected = true;
372  }
373  if (this->template get<TimeInfected<FP>>() < tol_times) {
374  log_warning("Constraint check: Parameter TimeInfected changed from {} to {}. Please note that "
375  "unreasonably small compartment stays lead to massively increased run time. Consider to cancel "
376  "and reset parameters.",
377  this->template get<TimeInfected<FP>>(), tol_times);
378  this->template get<TimeInfected<FP>>() = tol_times;
379  corrected = true;
380  }
381  if (this->template get<ClusteringExponent<FP>>() <= 0.0) {
382  log_warning("Constraint check: Parameter ClusteringExponent changed from {} to {}", //
383  this->template get<ClusteringExponent<FP>>(), 1.0);
384  this->template get<ClusteringExponent<FP>>() = 1.0;
385  corrected = true;
386  }
387  if (this->template get<BaselineTransmissibility<FP>>() < 0.0) {
388  log_warning("Constraint check: Parameter BaselineTransmissibility changed from {} to {}", //
389  this->template get<BaselineTransmissibility<FP>>(), 0.0);
390  this->template get<BaselineTransmissibility<FP>>() = 0.0;
391  corrected = true;
392  }
393  if (this->template get<OutsideFoI<FP>>() < 0.0) {
394  log_warning("Constraint check: Parameter OutsideFoI changed from {} to {}", //
395  this->template get<OutsideFoI<FP>>(), 0.0);
396  this->template get<OutsideFoI<FP>>() = 0.0;
397  corrected = true;
398  }
399  return corrected;
400  }
401 
407  bool check_constraints() const
408  {
409  const FP tol_times = 1e-1;
410 
411  if (this->template get<TimeExposed<FP>>() < tol_times) {
412  log_warning("Constraint check: Parameter TimeExposed {} smaller or equal {}. Please note that "
413  "unreasonably small compartment stays lead to massively increased run time. Consider to cancel "
414  "and reset parameters.",
415  this->template get<TimeExposed<FP>>(), tol_times);
416  return true;
417  }
418  if (this->template get<TimeInfected<FP>>() < tol_times) {
419  log_warning("Constraint check: Parameter TimeInfected {} smaller or equal {}. Please note that "
420  "unreasonably small compartment stays lead to massively increased run time. Consider to cancel "
421  "and reset parameters.",
422  this->template get<TimeInfected<FP>>(), tol_times);
423  return true;
424  }
425  if (this->template get<ClusteringExponent<FP>>() <= 0.0) {
426  log_error("Constraint check: Parameter ClusteringExponent {} smaller or equal {}", //
427  this->template get<ClusteringExponent<FP>>(), 0.0);
428  return true;
429  }
430  if (this->template get<BaselineTransmissibility<FP>>() < 0.0) {
431  log_error("Constraint check: Parameter BaselineTransmissibility {} smaller {}", //
432  this->template get<BaselineTransmissibility<FP>>(), 0.0);
433  return true;
434  }
435  if (this->template get<OutsideFoI<FP>>() < 0.0) {
436  log_error("Constraint check: Parameter OutsideFoI {} smaller {}", //
437  this->template get<OutsideFoI<FP>>(), 0.0);
438  return true;
439  }
440  return false;
441  }
442 
443 private:
445 };
446 
447 } // namespace oseirv
448 } // namespace mio
449 #endif
A class template for an array with custom indices.
Definition: custom_index_array.h:136
a set of parameters defined at compile time
Definition: parameter_set.h:205
const ParameterTagTraits< Tag >::Type & get() const
get value of a parameter
Definition: parameter_set.h:262
The UncertainContactMatrix class consists of a ContactMatrix with fixed baseline and uncertain Dampin...
Definition: uncertain_matrix.h:43
Parameter set for the age-resolved SEIRV model (S,E,I,R plus vaccinated states) as per the appendix.
Definition: ode_seirv/parameters.h:327
AgeGroup get_num_groups() const
Returns the number of age groups.
Definition: ode_seirv/parameters.h:342
AgeGroup m_num_groups
Definition: ode_seirv/parameters.h:444
Parameters(AgeGroup ng)
Construct with the number of age groups.
Definition: ode_seirv/parameters.h:333
bool apply_constraints()
Checks whether all Parameters satisfy their corresponding constraints and applies them,...
Definition: ode_seirv/parameters.h:360
bool check_constraints() const
Checks whether all Parameters satisfy their corresponding constraints and logs an error if constraint...
Definition: ode_seirv/parameters.h:407
int size(Comm comm)
Return the size of the given communicator.
Definition: miompi.cpp:75
A collection of classes to simplify handling of matrix shapes in meta programming.
Definition: models/abm/analyze_result.h:30
void log_warning(spdlog::string_view_t fmt, const Args &... args)
Definition: logging.h:112
void log_error(spdlog::string_view_t fmt, const Args &... args)
Definition: logging.h:100
The AgeGroup struct is used as a dynamically sized tag for all age dependent categories.
Definition: age_group.h:32
Baseline transmissibility R_e (dimensionless).
Definition: ode_seirv/parameters.h:42
static Type get_default(AgeGroup)
Definition: ode_seirv/parameters.h:44
UncertainValue< FP > Type
Definition: ode_seirv/parameters.h:43
static std::string name()
Definition: ode_seirv/parameters.h:48
Clustering/concavity parameter ρ (dimensionless).
Definition: ode_seirv/parameters.h:172
static Type get_default(AgeGroup)
Definition: ode_seirv/parameters.h:174
UncertainValue< FP > Type
Definition: ode_seirv/parameters.h:173
static std::string name()
Definition: ode_seirv/parameters.h:178
Contact patterns of healthy people (age-structured contact frequencies).
Definition: ode_seirv/parameters.h:209
static Type get_default(AgeGroup size)
Definition: ode_seirv/parameters.h:211
UncertainContactMatrix< FP > Type
Definition: ode_seirv/parameters.h:210
static std::string name()
Definition: ode_seirv/parameters.h:215
Contact patterns of symptomatically sick people (age-structured contact frequencies).
Definition: ode_seirv/parameters.h:228
static Type get_default(AgeGroup size)
Definition: ode_seirv/parameters.h:230
static std::string name()
Definition: ode_seirv/parameters.h:234
UncertainContactMatrix< FP > Type
Definition: ode_seirv/parameters.h:229
Outside force of infection in 1/week.
Definition: ode_seirv/parameters.h:154
static Type get_default(AgeGroup)
Definition: ode_seirv/parameters.h:156
UncertainValue< FP > Type
Definition: ode_seirv/parameters.h:155
static std::string name()
Definition: ode_seirv/parameters.h:160
Seasonality amplitude (dimensionless).
Definition: ode_seirv/parameters.h:98
static std::string name()
Definition: ode_seirv/parameters.h:104
UncertainValue< FP > Type
Definition: ode_seirv/parameters.h:99
static Type get_default(AgeGroup)
Definition: ode_seirv/parameters.h:100
Season-specific fine shift t_s.
Definition: ode_seirv/parameters.h:134
UncertainValue< FP > Type
Definition: ode_seirv/parameters.h:135
static std::string name()
Definition: ode_seirv/parameters.h:140
static Type get_default(AgeGroup)
Definition: ode_seirv/parameters.h:136
Subtype-specific seasonal shift t_z.
Definition: ode_seirv/parameters.h:116
static Type get_default(AgeGroup)
Definition: ode_seirv/parameters.h:118
UncertainValue< FP > Type
Definition: ode_seirv/parameters.h:117
static std::string name()
Definition: ode_seirv/parameters.h:122
Mixing parameter m for “sick” contacts (dimensionless).
Definition: ode_seirv/parameters.h:191
static Type get_default(AgeGroup)
Definition: ode_seirv/parameters.h:193
static std::string name()
Definition: ode_seirv/parameters.h:197
UncertainValue< FP > Type
Definition: ode_seirv/parameters.h:192
Age-specific baseline susceptibility σ_i.
Definition: ode_seirv/parameters.h:247
static Type get_default(AgeGroup size)
Definition: ode_seirv/parameters.h:249
CustomIndexArray< UncertainValue< FP >, AgeGroup > Type
Definition: ode_seirv/parameters.h:248
static std::string name()
Definition: ode_seirv/parameters.h:253
Fraction of the population that remains susceptible at t0 phi (dimensionless, typically in [0,...
Definition: ode_seirv/parameters.h:300
static std::string name()
Definition: ode_seirv/parameters.h:306
UncertainValue< FP > Type
Definition: ode_seirv/parameters.h:301
static Type get_default(AgeGroup)
Definition: ode_seirv/parameters.h:302
Mean time spent in the exposed compartment in weeks.
Definition: ode_seirv/parameters.h:60
static Type get_default(AgeGroup)
Definition: ode_seirv/parameters.h:62
static std::string name()
Definition: ode_seirv/parameters.h:66
UncertainValue< FP > Type
Definition: ode_seirv/parameters.h:61
Mean time spent in the infectious compartment in weeks.
Definition: ode_seirv/parameters.h:79
static std::string name()
Definition: ode_seirv/parameters.h:85
static Type get_default(AgeGroup)
Definition: ode_seirv/parameters.h:81
UncertainValue< FP > Type
Definition: ode_seirv/parameters.h:80
Vaccination coverage VC_i at t0 (dimensionless, in [0,1]).
Definition: ode_seirv/parameters.h:266
static std::string name()
Definition: ode_seirv/parameters.h:272
CustomIndexArray< UncertainValue< FP >, AgeGroup > Type
Definition: ode_seirv/parameters.h:267
static Type get_default(AgeGroup size)
Definition: ode_seirv/parameters.h:268
Vaccine effectiveness VE_i (dimensionless, in [0,1]).
Definition: ode_seirv/parameters.h:284
CustomIndexArray< UncertainValue< FP >, AgeGroup > Type
Definition: ode_seirv/parameters.h:285
static std::string name()
Definition: ode_seirv/parameters.h:290
static Type get_default(AgeGroup size)
Definition: ode_seirv/parameters.h:286