Skip to content

Commit

Permalink
plan_visits does nothing?
Browse files Browse the repository at this point in the history
  • Loading branch information
arindamsaha1507 committed Dec 24, 2023
1 parent f81024f commit 7f9f145
Showing 1 changed file with 49 additions and 49 deletions.
98 changes: 49 additions & 49 deletions facs/base/person.py
Expand Up @@ -107,55 +107,55 @@ def vaccinate(
self.symptoms_suppressed = True
# print("vac", self.status, self.symptoms_suppressed, self.phase_duration)

def plan_visits(self, e):
"""
Plan visits for the day.
TODO: plan visits to classes not using nearest location (make an override).
"""

if self.status in [
"susceptible",
"exposed",
"infectious",
]: # recovered people are assumed to be immune.
personal_needs = needs.get_needs(self)
for k, minutes in enumerate(personal_needs):
nearest_locs = self.home_location.nearest_locations

if minutes < 1:
continue
elif k == building_types_dict["hospital"] and self.hospitalised:
location_to_visit = self.hospital

elif k == building_types_dict["office"] and self.job > 0:
if self.job == 1: # teacher
location_to_visit = nearest_locs[building_types_dict["school"]]
if self.job == 2: # shop employee
location_to_visit = nearest_locs[
building_types_dict["shopping"]
]
if self.job == 3: # health worker
location_to_visit = nearest_locs[
building_types_dict["hospital"]
]

elif nearest_locs[k]:
location_to_visit = nearest_locs[k]
else: # no known nearby locations.
continue

e.visit_minutes += minutes

if isinstance(location_to_visit, list):
loc_type = location_to_visit[0].loc_type

if building_types_data[loc_type]["weighted"]:
sizes = [x.sqm for x in location_to_visit]
prob = [x / sum(sizes) for x in sizes]
location_to_visit = np.random.choice(location_to_visit, p=prob)

else:
location_to_visit = random.choice(location_to_visit)
# def plan_visits(self, e):
# """
# Plan visits for the day.
# TODO: plan visits to classes not using nearest location (make an override).
# """

# if self.status in [
# "susceptible",
# "exposed",
# "infectious",
# ]: # recovered people are assumed to be immune.
# personal_needs = needs.get_needs(self)
# for k, minutes in enumerate(personal_needs):
# nearest_locs = self.home_location.nearest_locations

# if minutes < 1:
# continue
# elif k == building_types_dict["hospital"] and self.hospitalised:
# location_to_visit = self.hospital

# elif k == building_types_dict["office"] and self.job > 0:
# if self.job == 1: # teacher
# location_to_visit = nearest_locs[building_types_dict["school"]]
# if self.job == 2: # shop employee
# location_to_visit = nearest_locs[
# building_types_dict["shopping"]
# ]
# if self.job == 3: # health worker
# location_to_visit = nearest_locs[
# building_types_dict["hospital"]
# ]

# elif nearest_locs[k]:
# location_to_visit = nearest_locs[k]
# else: # no known nearby locations.
# continue

# e.visit_minutes += minutes

# if isinstance(location_to_visit, list):
# loc_type = location_to_visit[0].loc_type

# if building_types_data[loc_type]["weighted"]:
# sizes = [x.sqm for x in location_to_visit]
# prob = [x / sum(sizes) for x in sizes]
# location_to_visit = np.random.choice(location_to_visit, p=prob)

# else:
# location_to_visit = random.choice(location_to_visit)

def print_needs(self):
"""Print the needs of a person."""
Expand Down

0 comments on commit 7f9f145

Please sign in to comment.