infection.h Source File

CPP API: infection.h Source File
infection.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2020-2026 MEmilio
3 *
4 * Authors: David Kerkmann, Sascha Korf, Khoa Nguyen
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_ABM_INFECTION_H
21 #define MIO_ABM_INFECTION_H
22 
23 #include "abm/personal_rng.h"
25 #include "abm/time.h"
26 #include "abm/infection_state.h"
27 #include "abm/virus_variant.h"
28 #include "abm/parameters.h"
29 
30 #include <vector>
31 
32 namespace mio
33 {
34 namespace abm
35 {
36 
43  TimeSpan duration; // Duration that the infection stays in from_state before transitioning to to_state.
44 };
45 
51 struct ViralLoad {
57 
60  {
61  return Members("ViralLoad")
62  .add("start_date", start_date)
63  .add("end_date", end_date)
64  .add("peak", peak)
65  .add("incline", incline)
66  .add("decline", decline);
67  }
68 };
69 
76 
77 class Infection
78 {
79 public:
93  TimePoint start_date, InfectionState start_state = InfectionState::Exposed,
94  ProtectionEvent latest_protection = {ProtectionType::NoProtection, TimePoint(0)}, bool detected = false);
95 
109  TimePoint init_date, InfectionState init_state, const InitialInfectionStateDistribution& init_state_dist,
110  ProtectionEvent latest_protection = {ProtectionType::NoProtection, TimePoint(0)}, bool detected = false);
111 
117 
133 
139 
146 
150  void set_detected();
151 
155  bool is_detected() const;
156 
160  TimePoint get_start_date() const;
161 
164  {
165  return Members("Infection")
166  .add("infection_course", m_infection_course)
167  .add("virus_variant", m_virus_variant)
168  .add("viral_load", m_viral_load)
169  .add("log_norm_alpha", m_log_norm_alpha)
170  .add("log_norm_beta", m_log_norm_beta)
171  .add("individual_viral_shed_factor", m_individual_viral_shed_factor)
172  .add("detected", m_detected);
173  }
174 
175 private:
177  Infection() = default;
178 
197  TimePoint init_date, InfectionState init_state,
198  ProtectionEvent latest_protection);
199 
212  TimePoint init_date, InfectionState init_state);
213 
223  const Parameters& params, ProtectionEvent latest_protection);
224 
233  const Parameters& params);
234 
246  InfectionState current_state, TimePoint current_time,
247  ProtectionEvent latest_protection) const;
248 
258  InfectionState current_state) const;
259 
268  const Parameters& params) const;
269 
278  const Parameters& params) const;
279 
286  ScalarType calculate_death_probability(AgeGroup age, const Parameters& params) const;
287 
296  ScalarType get_severity_protection_factor(const Parameters& params, ProtectionEvent latest_protection, AgeGroup age,
297  TimePoint current_time) const;
298 
299  std::vector<std::pair<TimePoint, InfectionState>> m_infection_course;
305  bool m_detected;
306 };
307 
308 } // namespace abm
309 } // namespace mio
310 
311 #endif
A class template for an array with custom indices.
Definition: custom_index_array.h:136
Definition: infection.h:78
auto default_serialize()
This method is used by the default serialization feature.
Definition: infection.h:163
TimePoint get_start_date() const
Definition: infection.cpp:157
void set_detected()
Set the Infection to detected.
Definition: infection.cpp:147
StateTransition get_forward_transition(PersonalRandomNumberGenerator &rng, AgeGroup age, const Parameters &params, InfectionState current_state, TimePoint current_time, ProtectionEvent latest_protection) const
Get the forward transition from a given infection state.
Definition: infection.cpp:162
ViralLoad m_viral_load
ViralLoad of the Infection.
Definition: infection.h:301
bool is_detected() const
Definition: infection.cpp:152
StateTransition get_recovered_backward_transition(PersonalRandomNumberGenerator &rng, AgeGroup age, const Parameters &params) const
Get the backward transition from recovered state.
Definition: infection.cpp:291
ScalarType get_severity_protection_factor(const Parameters &params, ProtectionEvent latest_protection, AgeGroup age, TimePoint current_time) const
Get the severity protection factor based on latest protection.
Definition: infection.cpp:356
StateTransition get_dead_backward_transition(PersonalRandomNumberGenerator &rng, AgeGroup age, const Parameters &params) const
Get the backward transition from dead state.
Definition: infection.cpp:328
ScalarType calculate_death_probability(AgeGroup age, const Parameters &params) const
Calculate the overall death probability for the infection.
Definition: infection.cpp:348
void draw_infection_course_forward(PersonalRandomNumberGenerator &rng, AgeGroup age, const Parameters &params, TimePoint init_date, InfectionState init_state, ProtectionEvent latest_protection)
Determine Infection course subsequent to the given InfectionState start_state.
Definition: infection.cpp:366
VirusVariant m_virus_variant
Variant of the Infection.
Definition: infection.h:300
VirusVariant get_virus_variant() const
: Get VirusVariant.
Definition: infection.cpp:129
bool m_detected
Whether an Infection is detected or not.
Definition: infection.h:305
TimePoint draw_infection_course_backward(PersonalRandomNumberGenerator &rng, AgeGroup age, const Parameters &params, TimePoint init_date, InfectionState init_state)
Determine Infection course prior to the given InfectionState start_state.
Definition: infection.cpp:384
std::vector< std::pair< TimePoint, InfectionState > > m_infection_course
Start date of each InfectionState.
Definition: infection.h:299
void initialize_viral_load(PersonalRandomNumberGenerator &rng, VirusVariant virus, AgeGroup age, const Parameters &params, ProtectionEvent latest_protection)
Initialize the viral load parameters for the infection.
Definition: infection.cpp:31
StateTransition get_backward_transition(PersonalRandomNumberGenerator &rng, AgeGroup age, const Parameters &params, InfectionState current_state) const
Get the backward transition from a given infection state.
Definition: infection.cpp:249
ScalarType m_individual_viral_shed_factor
Individual viral shed factor.
Definition: infection.h:304
ScalarType get_viral_load(TimePoint t) const
Gets the ViralLoad of the Infection at a given TimePoint.
Definition: infection.cpp:104
void initialize_viral_shed(PersonalRandomNumberGenerator &rng, VirusVariant virus, AgeGroup age, const Parameters &params)
Initialize the viral shed parameters and individual factor for the infection.
Definition: infection.cpp:49
ScalarType get_viral_shed(TimePoint t) const
Get viral shed at a specific time.
Definition: infection.cpp:121
ScalarType m_log_norm_beta
Parameters for the viral shed mapping, which is modelled through an invlogit function.
Definition: infection.h:303
ScalarType m_log_norm_alpha
Definition: infection.h:302
InfectionState get_infection_state(TimePoint t) const
Get the InfectionState of the Infection.
Definition: infection.cpp:134
Parameters of the simulation that are the same everywhere within the Model.
Definition: abm/parameters.h:764
Random number generator of individual persons.
Definition: personal_rng.h:50
Represents a point in time.
Definition: time.h:175
A duration of time.
Definition: time.h:36
double ScalarType
Configuration of memilio library.
Definition: memilio/config.h:30
VirusVariant
Virus variants in ABM.
Definition: virus_variant.h:38
InfectionState
InfectionState in ABM.
Definition: abm/infection_state.h:35
A collection of classes to simplify handling of matrix shapes in meta programming.
Definition: models/abm/analyze_result.h:30
The AgeGroup struct is used as a dynamically sized tag for all age dependent categories.
Definition: age_group.h:32
Creates an instance of T for later initialization.
Definition: default_serialize.h:173
List of a class's members.
Definition: default_serialize.h:113
Members< ValueTypes..., T > add(const char *member_name, T &member)
Add a class member.
Definition: default_serialize.h:139
A tuple of ProtectionType and #TimePoint.
Definition: protection_event.h:49
Represents a transition period between two infection states.
Definition: infection.h:40
TimeSpan duration
Definition: infection.h:43
InfectionState from_state
Definition: infection.h:41
InfectionState to_state
Definition: infection.h:42
Models the ViralLoad for an Infection, modelled on a log_10 scale.
Definition: infection.h:51
ScalarType incline
Incline of the ViralLoad during incline phase in log_10 scale per day (always positive).
Definition: infection.h:55
TimePoint end_date
End date of the ViralLoad concentration in the Person.
Definition: infection.h:53
TimePoint start_date
Start date of the ViralLoad concentration in the Person.
Definition: infection.h:52
ScalarType peak
Peak amplitude of the ViralLoad.
Definition: infection.h:54
auto default_serialize()
This method is used by the default serialization feature.
Definition: infection.h:59
ScalarType decline
Decline of the ViralLoad during decline phase in log_10 scale per day (always negative).
Definition: infection.h:56