Skip to content

Commit 8453a8d

Browse files
committed
fix dampings in ex3
1 parent c623124 commit 8453a8d

4 files changed

Lines changed: 9 additions & 9 deletions

File tree

cpp-tutorials/exercises/exercise03.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ int main()
4848
// all currently active dampings of one level and different types are summed up. If two dampings have different
4949
// levels (independent of the type) they are combined multiplicatively. In the following we apply a `Damping`
5050
// of 0.9 after 10 days and another damping of 0.6 after 20 days which means that the contacts are reduced
51-
// by 10% and 40%, respectively. To always retain a minimum level of contacts, a minimum contact frequency can
51+
// by 90% and 60%, respectively. To always retain a minimum level of contacts, a minimum contact frequency can
5252
// be set that is never deceeded. In our example we set this minimum contact rate to 0.
5353
contact_matrix[0].add_damping(0.9, mio::SimulationTime<ScalarType>(10.));
5454
contact_matrix[0].add_damping(0.6, mio::SimulationTime<ScalarType>(20.));
5555

56-
//EXERCISE: Please create a damping that replaces the 10% reduction after 10 days by a 20% reduction. Additionally, add a damping after 40 days that increases the contact rate by 50%.
56+
//EXERCISE: Please create a damping that replaces the 90% reduction after 10 days by a 20% reduction. Additionally, add a damping after 40 days that increases the contact rate by 50%.
5757

5858
// Again, we start with 0.5% of the population initially in `Exposed` and 0.5% initially in `InfectedNoSymptoms`
5959
// while the remaining 99% is `Susceptible`.

cpp-tutorials/tutorial03.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ int main()
4646
// all currently active dampings of one level and different types are summed up. If two dampings have different
4747
// levels (independent of the type) they are combined multiplicatively. In the following we apply a `Damping`
4848
// of 0.9 after 10 days and another damping of 0.6 after 20 days which means that the contacts are reduced
49-
// by 10% and 40%, respectively. To always retain a minimum level of contacts, a minimum contact frequency can
49+
// by 90% and 60%, respectively. To always retain a minimum level of contacts, a minimum contact frequency can
5050
// be set that is never deceeded. In our example we set this minimum contact rate to 0.
5151
contact_matrix[0].add_damping(0.9, mio::SimulationTime<ScalarType>(10.));
5252
contact_matrix[0].add_damping(0.6, mio::SimulationTime<ScalarType>(20.));

exercises/exercise03.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def _():
105105
@app.cell
106106
def _(mo):
107107
mo.md(r"""
108-
After the model initialization, we add a contact reduction (`Damping`) that represents an NPI like e.g. mask wearing or social distancing. Dampings are a factor applied to the contact frequency and can be added to the model at fixed simulation time points before simulating. They have a *Level* and a *Type*. A damping with a given level and type replaces the previously active one with the same level and type, while all currently active dampings of one level and different types are summed up. If two dampings have different levels (independent of the type) they are combined multiplicatively. In the following we apply a `Damping` of 0.9 after 10 days and another damping of 0.6 after 20 days which means that the contacts are reduced by 10% and 40%, respectively. In general, it is also possible to increase the contact rate by using Damping values greater than 1. To always retain a minimum level of contacts, a minimum contact frequency can be set that is never deceeded. In our example we set this minimum contact rate to 0.
108+
After the model initialization, we add a contact reduction (`Damping`) that represents an NPI like e.g. mask wearing or social distancing. Dampings are a factor applied to the contact frequency and can be added to the model at fixed simulation time points before simulating. They have a *Level* and a *Type*. A damping with a given level and type replaces the previously active one with the same level and type, while all currently active dampings of one level and different types are summed up. If two dampings have different levels (independent of the type) they are combined multiplicatively. In the following we apply a `Damping` of 0.9 after 10 days and another damping of 0.6 after 20 days which means that the contacts are reduced by 90% and 60%, respectively. In general, it is also possible to increase the contact rate by using negative Damping values. To always retain a minimum level of contacts, a minimum contact frequency can be set that is never deceeded. In our example we set this minimum contact rate to 0.
109109
""")
110110
return
111111

@@ -115,9 +115,9 @@ def _(Damping, model, np):
115115
# Set minimum contact frequency
116116
model.parameters.ContactPatterns.cont_freq_mat[0].minimum = np.zeros((1, 1))
117117

118-
# Add contact reduction by 10% after 10 days
118+
# Add contact reduction by 90% after 10 days
119119
model.parameters.ContactPatterns.cont_freq_mat.add_damping(Damping(coeffs=np.ones((1, 1)) * 0.9, t=10.0, level=0, type=0))
120-
# Add contact reduction by 40% after 20 days
120+
# Add contact reduction by 60% after 20 days
121121
model.parameters.ContactPatterns.cont_freq_mat.add_damping(Damping(coeffs=np.ones((1, 1)) * 0.6, t=20.0, level=0, type=0))
122122
return
123123

@@ -126,7 +126,7 @@ def _(Damping, model, np):
126126
def _(mo):
127127
mo.md(r"""
128128
### Exercise
129-
Please create a damping that replaces the 10% reduction after 10 days by a 20% reduction. Additionally, add a damping after 40 days that increases the contact rate by 50%.
129+
Please create a damping that replaces the 90% reduction after 10 days by a 20% reduction. Additionally, add a damping after 40 days that increases the contact rate by 50%.
130130
""")
131131
return
132132

tutorial03.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ def _(Damping, model, np):
100100
# Set minimum contact frequency
101101
model.parameters.ContactPatterns.cont_freq_mat[0].minimum = np.zeros((1, 1))
102102

103-
# Add contact reduction by 10% after 10 days
103+
# Add contact reduction by 90% after 10 days
104104
model.parameters.ContactPatterns.cont_freq_mat.add_damping(Damping(coeffs=np.ones((1, 1)) * 0.9, t=10.0, level=0, type=0))
105-
# Add contact reduction by 40% after 20 days
105+
# Add contact reduction by 60% after 20 days
106106
model.parameters.ContactPatterns.cont_freq_mat.add_damping(Damping(coeffs=np.ones((1, 1)) * 0.6, t=20.0, level=0, type=0))
107107
return
108108

0 commit comments

Comments
 (0)