-
Notifications
You must be signed in to change notification settings - Fork 0
/
HouseholdManager.py
43 lines (37 loc) · 2.06 KB
/
HouseholdManager.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
# -*- coding: utf-8 -*-
from Household import Household
import numpy as np
class HouseholdManager:
def __init__(self, personList, constantsAndRandom, dictHealthStatusNextChange):
self.personList = personList
self.constantsAndRandom = constantsAndRandom
self.dictHealthStatusNextChange = dictHealthStatusNextChange
self.householdList = []
shuffledPersonList = personList.copy()
np.random.shuffle(shuffledPersonList)
numberOfPeopleInHoushold = 0
while (numberOfPeopleInHoushold < self.constantsAndRandom.Main_populationSize):
houseHoldSize = self.constantsAndRandom.getRandomHouseholdSize_1()
personsInHoushold = []
i = numberOfPeopleInHoushold
while (i < numberOfPeopleInHoushold + houseHoldSize and i < self.constantsAndRandom.Main_populationSize):
personsInHoushold.append(shuffledPersonList[i])
i+=1
for person in personsInHoushold:
otherPersonsInHoushold = personsInHoushold.copy()
otherPersonsInHoushold.remove(person)
person.houseHoldMembers = otherPersonsInHoushold
self.householdList.append(Household(personsInHoushold))
numberOfPeopleInHoushold += houseHoldSize
def simulateDay(self,day,timeToday,timeTotal):
for household in self.householdList:
if(not household.everybodyInfected):
for person in household.personList:
if(person.isInfectious()):
for otherPerson in person.houseHoldMembers:
if(otherPerson.isSusceptible()):
timesHealthStatusChange = otherPerson.setHealthStatusToExposed(timeTotal)
self.dictHealthStatusNextChange.setdefault(timesHealthStatusChange[0],[]).append(otherPerson.id)
self.dictHealthStatusNextChange.setdefault(timesHealthStatusChange[1],[]).append(otherPerson.id)
self.dictHealthStatusNextChange.setdefault(timesHealthStatusChange[2],[]).append(otherPerson.id)
household.everybodyInfected=True