You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: cpp/models/ide_secir/model.h
+40-30Lines changed: 40 additions & 30 deletions
Original file line number
Diff line number
Diff line change
@@ -41,7 +41,8 @@ class Model
41
41
* @param[in, out] init TimeSeries with the initial values of the number of individuals,
42
42
* which transit within one timestep dt from one compartment to another.
43
43
* Possible transitions are specified in #InfectionTransition%s.
44
-
* Considered time points should have the distance dt. The last time point determines the start time t0 of the simulation.
44
+
* Considered time points should have the distance dt. The last time point determines the start time t0 of the
45
+
* simulation.
45
46
* The time history must reach a certain point in the past so that the simulation can be performed.
46
47
* A warning is displayed if the condition is violated.
47
48
* @param[in] N_init The population of the considered region.
@@ -54,19 +55,21 @@ class Model
54
55
55
56
// ---- Functionality to calculate the sizes of the compartments for time t0. ----
56
57
/**
57
-
* @brief Compute the compartment specified in idx_InfectionState at the current time -- only using historic flow values and disrespecting potential, previous compartment value.
58
+
* @brief Compute the compartment specified in idx_InfectionState at the current time -- only using historic flow
59
+
* values and disrespecting potential, previous compartment value.
58
60
*
59
-
* The computation is meaningful for all compartments except #Susceptible, #Recovered and #Death
61
+
* The computation is meaningful for all compartments except Susceptible, Recovered and #Death
60
62
* and mostly needed for initialization.
61
-
* For #Susceptible, #Recovered and #Dead, use corresponding alternative functions.
63
+
* For Susceptible, Recovered and Dead, use corresponding alternative functions.
62
64
*
63
65
* @param[in] idx_InfectionState Specifies the considered #InfectionState
64
66
* @param[in] idx_IncomingFlow Specifies the index of the infoming flow to #InfectionState in m_transitions.
65
67
* @param[in] idx_TransitionDistribution1 Specifies the index of the first relevant TransitionDistribution,
66
68
* related to a flow from the considered #InfectionState to any other #InfectionState.
67
69
* This index is also used for related probability.
68
70
* @param[in] idx_TransitionDistribution2 Specifies the index of the second relevant TransitionDistribution,
69
-
* related to a flow from the considered #InfectionState to any other #InfectionState (in most cases to #Recovered).
71
+
* related to a flow from the considered #InfectionState to any other #InfectionState (in most cases
72
+
* to Recovered).
70
73
* Necessary related probability is calculated via 1-probability[idx_TransitionDistribution1].
71
74
* If the second index is not needed, e.g., if probability[idx_TransitionDistribution1]=1,
* @brief Computes the values of compartments at initialization.
92
95
*
93
96
* The initialization method is selected automatically based on the different values that need to be set beforehand.
94
97
* Infection compartments are always computed through historic flows.
95
-
* Initialization methods for #Susceptible and #Recovered are tested in the following order:
96
-
* 1.) If a positive number for the total number of confirmed cases is set, #Recovered is set according to that value and #Susceptible%s are derived.
97
-
* 2.) If #Susceptible%s are set, #Recovered will be derived.
98
-
* 3.) If #Recovered are set directly, #Susceptible%s are derived.
99
-
* 4.) If none of the above is set with positive value, the force of infection is used as in Messina et al (2021) to set the #Susceptible%s.
98
+
* Initialization methods for Susceptible and Recovered are tested in the following order:
99
+
* 1.) If a positive number for the total number of confirmed cases is set, Recovered is set according to that
100
+
* value and Susceptible%s are derived.
101
+
* 2.) If Susceptible%s are set, Recovered will be derived.
102
+
* 3.) If Recovered are set directly, Susceptible%s are derived.
103
+
* 4.) If none of the above is set with positive value, the force of infection is used as in Messina et al (2021)
104
+
* to set the Susceptible%s.
100
105
*
101
-
* The function calculate_compartments_initialization() is used in every method for the compartments Exposed, InfectedNoSymptoms, InfectedSymptoms, InfectedSevere and InfectedCritical.
106
+
* The function calculate_compartments_initialization() is used in every method for the compartments Exposed,
107
+
* InfectedNoSymptoms, InfectedSymptoms, InfectedSevere and InfectedCritical.
102
108
* In addition, the force of infection is calculated for start time t_0.
// ---- Functionality for the iterations of a simulation. ----
109
115
/**
110
-
* @brief Computes number of #Susceptible%s for the current last time in m_populations.
116
+
* @brief Computes number of Susceptible%s for the current last time in m_populations.
111
117
*
112
-
* Number is computed using previous number of #Susceptible%s and the force of infection (also from previous timestep).
118
+
* Number is computed using previous number of Susceptible%s and the force of infection (also from previous timestep).
113
119
* Number is stored at the matching index in m_populations.
114
120
* @param[in] dt Time discretization step size.
115
121
*/
@@ -139,13 +145,14 @@ class Model
139
145
voidflows_current_timestep(ScalarType dt);
140
146
141
147
/**
142
-
* @brief Sets the values of compartments (all apart from #Susceptible) for the current last timestep in m_populations.
148
+
* @brief Updates the values of all compartments except Susceptible at initialization.
143
149
*
144
-
* New values are stored in m_populations. The values are calculated using the compartment size in the previous time step and the related flows of the current time step.
150
+
* New values are stored in m_populations. The values are calculated using the compartment size in the previous
151
+
* time step and the related flows of the current time step.
145
152
* Therefore the flows of the current time step should be calculated before using this function.
146
153
*
147
154
*/
148
-
voidupdate_compartments_current_timestep();
155
+
voidupdate_compartments();
149
156
150
157
/**
151
158
* @brief Computes force of infection for the current last time in m_transitions.
@@ -154,8 +161,8 @@ class Model
154
161
*
155
162
* @param[in] dt Time discretization step size.
156
163
* @param[in] initialization If true we are in the case of the initialization of the model.
157
-
* For this we need forceofinfection at time point t0-dt and not at the current last time (given by m_transitions)
158
-
* as in the other time steps.
164
+
* For this we need forceofinfection at time point t0-dt and not at the current last time
165
+
* (given by m_transitions) as in the other time steps.
* The initialization method is selected automatically based on the different values that need to be set beforehand.
230
237
* Infection compartments are always computed through historic flow.
231
-
* Initialization methods for #Susceptible and #Recovered are tested in the following order:
232
-
* 1.) If a positive number for the total number of confirmed cases is set, #Recovered is set according to that value and #Susceptible%s are derived.
233
-
* 2.) If #Susceptible%s are set, #Recovered will be derived.
234
-
* 3.) If #Recovered are set directly, #Susceptible%s are derived.
235
-
* 4.) If none of the above is set with positive value, the force of infection is used as in Messina et al (2021) to set the #Susceptible%s.
238
+
* Initialization methods for Susceptible and Recovered are tested in the following order:
239
+
* 1.) If a positive number for the total number of confirmed cases is set, Recovered is set according to that value
240
+
* and Susceptible%s are derived.
241
+
* 2.) If Susceptible%s are set, Recovered will be derived.
242
+
* 3.) If Recovered are set directly, Susceptible%s are derived.
243
+
* 4.) If none of the above is set with positive value, the force of infection is used as in Messina et al (2021) to
244
+
* set the Susceptible%s.
236
245
*
237
246
* @return Index representing the initialization method.
238
247
*/
@@ -243,20 +252,21 @@ class Model
243
252
244
253
// ---- Public parameters. ----
245
254
ParameterSet parameters{}; ///< ParameterSet of Model Parameters.
246
-
/* Attention: m_populations and m_transitions do not necessarily have the same number of time points due to the initialization part. */
255
+
// Attention: m_populations and m_transitions do not necessarily have the same number of time points due to the
256
+
// initialization part.
247
257
TimeSeries<ScalarType>
248
258
m_transitions; ///< TimeSeries containing points of time and the corresponding number of transitions.
249
-
TimeSeries<ScalarType>
250
-
m_populations; ///< TimeSeries containing points of time and the corresponding number of people in defined #InfectionState%s.
259
+
TimeSeries<ScalarType> m_populations; ///< TimeSeries containing points of time and the corresponding number of
260
+
// people in defined #InfectionState%s.
251
261
252
262
private:
253
263
// ---- Private parameters. ----
254
264
ScalarType m_forceofinfection{0}; ///< Force of infection term needed for numerical scheme.
255
265
ScalarType m_N{0}; ///< Total population size of the considered region.
256
266
ScalarType m_total_confirmed_cases{0}; ///< Total number of confirmed cases at time t0.
257
267
ScalarType m_tol{1e-10}; ///< Tolerance used to calculate the maximum support of the TransitionDistributions.
258
-
int m_initialization_method{
259
-
0}; ///< Gives the index of the method used for the initialization of the model. See also get_initialization_method_compartments() for the number code.
268
+
int m_initialization_method{0}; ///< Gives the index of the method used for the initialization of the model.
269
+
//See also get_initialization_method_compartments() for the number code.
0 commit comments