Skip to content

Commit

Permalink
Removed unused grouping
Browse files Browse the repository at this point in the history
  • Loading branch information
arindamsaha1507 committed Dec 22, 2023
1 parent 3271919 commit 08b7da6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 35 deletions.
18 changes: 0 additions & 18 deletions facs/base/facs.py
Expand Up @@ -174,24 +174,6 @@ def get_seasonal_effect(self):
# print("Seasonal effect month: ",month,", multiplier: ",multipliers[month])
return multipliers[month - 1]

def make_group(self, loc_type, max_groups):
"""
Creates a grouping for a location, and assigns agents randomly to groups.
Agents need to have been read in *before* running this function.
"""
print("make group:", self.locations.keys(), loc_type)
num_locs = len(self.locations[loc_type])
self.loc_groups[loc_type] = {}
# Assign groups to specific locations of that type in round robin fashion.
for i in range(0, max_groups):
self.loc_groups[loc_type][i] = self.locations[loc_type][i % num_locs]

# randomly assign agents to groups
for k, e in enumerate(self.houses):
for hh in e.households:
for a in hh.agents:
a.assign_group(loc_type, max_groups)

def get_location_by_group(self, loc_type_id, group_num):
loc_type = building_types[loc_type_id]
return self.loc_groups[loc_type][group_num]
Expand Down
24 changes: 7 additions & 17 deletions facs/base/person.py
Expand Up @@ -16,7 +16,6 @@
from .location_types import building_types_dict, building_types_data
from .utils import (
probability,
get_random_int,
log_infection,
log_hospitalisation,
log_recovery,
Expand All @@ -28,6 +27,7 @@
from .household import Household
from .location import Location
from .disease import Disease
from .facs import Ecosystem


needs = Needs("covid_data/needs.csv", list(building_types_dict.keys()))
Expand Down Expand Up @@ -82,16 +82,6 @@ def __post_init__(self):
self.job = np.random.choice(4, 1, p=[0.865, 0.015, 0.08, 0.04])[0]
# 0=default, 1=teacher (1.5%), 2=shop worker (8%), 3=health worker (4%)

def assign_group(self, location_type, num_groups):
"""
Used to assign a grouping to a person.
For example, a campus may have 30 classes (num_groups = 30). Then you would use:
assign_group("school", 30)
The location type should match the corresponding personal needs category
(e.g., school or supermarket).
"""
self.groups[building_types_dict[location_type]] = get_random_int(num_groups)

def location_has_grouping(self, lid):
"""Check if a location has a particular grouping."""

Expand Down Expand Up @@ -188,21 +178,21 @@ def get_mortality_chance(self, disease):
age = int(min(self.age, len(disease.hospital) - 1))
return disease.mortality[age]

def infect(self, e, severity="exposed", location_type="house"):
def infect(self, eco: Ecosystem, severity="exposed", location_type="house"):
"""Infect a person."""
# severity can be overridden to infectious when rigidly inserting cases.
# but by default, it should be exposed.
self.status = severity
self.status_change_time = e.time
self.status_change_time = eco.time
self.mild_version = True
self.hospitalised = False
self.phase_duration = max(1, np.random.poisson(e.disease.incubation_period))
e.num_infections_today += log_infection(
e.time,
self.phase_duration = max(1, np.random.poisson(eco.disease.incubation_period))
eco.num_infections_today += log_infection(
eco.time,
self.location.location_x,
self.location.location_y,
location_type,
e.rank,
eco.rank,
self.phase_duration,
)

Expand Down

0 comments on commit 08b7da6

Please sign in to comment.