-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPerson.py
88 lines (77 loc) · 3.69 KB
/
Person.py
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
from Types import PersonState, Quarantine, Gender
import random
import utils
class Person:
def __init__(self, chance_of_infection):
self.age = utils.set_age()
self.age_group = utils.get_age_group(self.age) # TODO We only set this property but we did not use it!
self.background_sickness = utils.get_background_sickness(self.age)
self.exposure_radius = random.randint(1, 3)
self.follow_protocol = utils.get_adherence(self.age)
self.smoking = utils.get_smoking(self.age)
self.bmi = utils.get_obesity(self.age)
self.quarantine = Quarantine.NO
self.quarantine_count = 0
self.gender = Gender.FEMALE if random.uniform(0, 1) < 0.5 else Gender.MALE
self.state = PersonState.INFECTIOUS if random.uniform(0, 1) < chance_of_infection else PersonState.HEALTHY
self.incubation_period = random.randint(2, 14)
self.recovery_period = random.randint(7, 28)
self.risk_of_infecting_others = 0
self.risk_of_getting_infected = 0
self.death_ratio = self.set_death_ratio()
def get_vulnerability_ratio(self, mask, distancing, hygiene, curfew):
"""
Risk of getting infected by an infected neighbor.
:param mask: float 0-1
:param distancing: float 0-1
:param hygiene: float 0-1
:param curfew: float 0-1
:return: float 0-1
"""
self.risk_of_getting_infected = (1 - ((mask + distancing + hygiene + curfew + self.follow_protocol)/5)) * 0.7
return self.risk_of_getting_infected
def get_risk_ratio(self, mask, distancing, hygiene, curfew):
"""
Risk of infecting others.
:param mask: float 0-1
:param distancing: float 0-1
:param hygiene: float 0-1
:param curfew: float 0-1
:return:
"""
if self.state not in [PersonState.SICK, PersonState.INFECTIOUS]:
self.risk_of_infecting_others = 0
else:
if self.quarantine == Quarantine.TOTAL_ISOLATION:
self.risk_of_infecting_others = 0
elif self.quarantine == Quarantine.QUARANTINE:
self.risk_of_infecting_others = (1 - self.follow_protocol) * 0.1
else:
self.risk_of_infecting_others = (1 - ((distancing + mask + hygiene + curfew + self.follow_protocol)/5)) * 0.7
return self.risk_of_infecting_others
def set_death_ratio(self):
"""
Background\_sickness, maybe age, lifestyle (smoking, weight), health care (respirator, medicines)
https://www.fhi.no/contentassets/8a971e7b0a3c4a06bdbf381ab52e6157/vedlegg/andre-halvar-2020/2020.09.23-ukerapport-uke-38-covid-19.pdf
page 24
1.38% som får corona dør av det. 87% av desse har underliggende sykdom
If the person is smoking, increase the chance of death by 5%
If the person is overweight, increase the chance of death by 5%
:return:
"""
if self.background_sickness:
return 0.0120006 * (
0.01 * self.age) + 0.05 if self.smoking else 0 + 0.05 if self.bmi else 0 + 0.02 if self.gender == Gender.MALE else 0
else:
return 0.001794 * (
0.01 * self.age) + 0.05 if self.smoking else 0 + 0.05 if self.bmi else 0 + 0.02 if self.gender == Gender.MALE else 0
def get_death_ratio(self):
return self.death_ratio
def print_self(self):
print('Age =', self.age)
print('bs =', self.background_sickness)
print('Exposure =', self.exposure_radius)
print('Follow protocol =', self.follow_protocol)
print('In quarantine =', self.quarantine)
print('State =', self.state)
print('Gender =', self.gender)