-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinterventions.py
More file actions
52 lines (44 loc) · 1.68 KB
/
interventions.py
File metadata and controls
52 lines (44 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
'''
This module defines the knobs of an intervention and forms
the available intervantions considerin school closures,
cocooning, and different levels od social distance.
'''
from numpy import exp, round, array
class Intervension:
def __init__(self, SC, CO, SD, epi, demographics):
'''
Attrs:
school_closure (int): 0 schools are open, 1 schools are closed
cocooning (float): level of cocooning [0,1)
social_distance (float): level of social distance [0,1)
epi (EpiParams): instance of the parameterization
demographics (ndarray): Population demographics
'''
self.school_closure = SC
self.cocooning = CO
self.social_distance = SD
self.cost = SC + CO + (round(exp(5 * SD), 3) - 1)
demographics_normalized = demographics / demographics.sum()
self.phi_weekday = epi.effective_phi(SC, CO, SD, demographics_normalized, weekday=True)
self.phi_weekend = epi.effective_phi(SC, CO, SD, demographics_normalized, weekday=False)
def phi(self, is_weekday):
if is_weekday:
return self.phi_weekday
else:
return self.phi_weekend
@property
def SC(self):
return self.school_closure
@property
def CO(self):
return self.cocooning
@property
def SD(self):
return self.social_distance
def form_interventions(social_distance_levels, epi, demographics):
interventions = []
for SC in [0, 1]:
for CO in [0, 1]:
for SD in social_distance_levels:
interventions.append(Intervension(SC, CO, SD, epi, demographics))
return interventions