Skip to content

Commit 3ce59a1

Browse files
Apply suggestions from code review
Co-authored-by: Martin J. Kühn <62713180+mknaranja@users.noreply.github.com>
1 parent ad239f4 commit 3ce59a1

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

cpp/models/ide_secir/model.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ void Model::initialize(ScalarType dt)
6767
m_populations[Eigen::Index(0)][Eigen::Index(InfectionState::Dead)];
6868
}
6969
else if (m_populations[Eigen::Index(0)][Eigen::Index(InfectionState::Susceptible)] > 1e-12) {
70-
//take initialized value for Susceptibles if value can't be calculated via the standard formula
70+
// Take initialized value for Susceptibles if value can't be calculated via the standard formula.
7171
m_initialization_method = 2;
72-
//calculate other compartment sizes for t=0
72+
// Calculate other compartment sizes for t=0.
7373
other_compartments_current_timestep(dt);
7474

75-
//R; need an initial value for R, therefore do not calculate via compute_recovered()
75+
// R; need an initial value for R, therefore do not calculate via compute_recovered()
7676
m_populations[Eigen::Index(0)][Eigen::Index(InfectionState::Recovered)] =
7777
m_N - m_populations[Eigen::Index(0)][Eigen::Index(InfectionState::Susceptible)] -
7878
m_populations[Eigen::Index(0)][Eigen::Index(InfectionState::Exposed)] -
@@ -83,9 +83,9 @@ void Model::initialize(ScalarType dt)
8383
m_populations[Eigen::Index(0)][Eigen::Index(InfectionState::Dead)];
8484
}
8585
else if (m_populations[Eigen::Index(0)][Eigen::Index(InfectionState::Recovered)] > 1e-12) {
86-
//if value for Recovered is initialized and standard method is not applicable, calculate Susceptibles via other compartments
87-
//determining other compartment sizes is not dependent of Susceptibles(0), just of the transitions of the past.
88-
//calculate other compartment sizes for t=0
86+
// If value for Recovered is initialized and standard method is not applicable (i.e., no value for total infections
87+
// or suceptibles given directly), calculate Susceptibles via other compartments.
88+
// The calculation of other compartments' values is not dependent on Susceptibles at time 0, i.e., S(0), but only on the transitions of the past.
8989
m_initialization_method = 3;
9090
other_compartments_current_timestep(dt);
9191

cpp/models/ide_secir/model.h

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,18 @@ class Model
9494
}
9595

9696
/**
97-
* @brief Calculate the number of individuals in each compartment for time 0.
98-
*
99-
* Initial transitions are used to calculate the initial compartment sizes.
100-
* @param[in] dt Time discretization step size.
101-
*/
97+
* @brief Initializes the model and sets compartment values at time zero.
98+
*
99+
* The initialization method is selected automatically based on the different values that need to be set beforehand.
100+
* Infection compartments are always computed through historic flow.
101+
* Initialization methods for susceptibles and recovered are tested in the following order:
102+
* 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.
103+
* 2.) If #Susceptible%s are set, recovered will be derived.
104+
* 3.) If #Recovered are set directly, #Susceptible%s are derived.
105+
* 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.
106+
*
107+
* @param[in] dt Time discretization step size.
108+
*/
102109
void initialize(ScalarType dt);
103110

104111
/**
@@ -201,12 +208,12 @@ class Model
201208
}
202209

203210
/**
204-
* @brief Specifies a number associated with the method used for initialization.
211+
* @brief Returns the number associated with the method selected automatically for initialization.
205212
*
206-
* @returns 0 if the initialization method has not yet been selected,
213+
* @returns 0 if the model has not yet been initialized and the method has not yet been selected,
207214
* 1 if the method using the total number of confirmed cases at time 0 is used,
208-
* 2 if the initialization is calculated using a prior set value for S,
209-
* 3 if the initialization is calculated using a prior set value for R,
215+
* 2 if the initialization is calculated using a beforehand set value for S,
216+
* 3 if the initialization is calculated using a beforehand set value for R,
210217
* 4 if the force of infection method is used,
211218
* -1 if the initialization was not possible using any of the methods and
212219
* -2 if the initialization was possible using one of the provided methods but the result is not appropriate.

0 commit comments

Comments
 (0)