-
Notifications
You must be signed in to change notification settings - Fork 0
/
Policy.py
59 lines (44 loc) · 1.56 KB
/
Policy.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
import random
class Policy():
def __init__(self):
self.policy_name=None
def enact_policy(self,time_step,agents,locations):
pass
class full_lockdown(Policy):
def __init__(self,do_lockdown_fn):
self.do_lockdown_fn=do_lockdown_fn
def enact_policy(self,time_step,agents,locations):
if self.do_lockdown_fn(time_step):
for agent in agents:
agent.lock_down_state=True
class agent_lockdown(Policy):
def __init__(self,parameter,value_list,do_lockdown_fn):
self.do_lockdown_fn=do_lockdown_fn
self.parameter=parameter
self.value_list=value_list
def enact_policy(self,time_step,agents,locations):
if self.do_lockdown_fn(time_step):
for agent in agents:
if agent.info[self.parameter] in self.value_list:
agent.lock_down_state=True
class location_lockdown(Policy):
def __init__(self,parameter,value_list):
self.do_lockdown_fn=do_lockdown_fn
self.parameter=parameter
self.value_list=value_list
def enact_policy(self,time_step,agents,locations):
if self.do_lockdown_fn(time_step):
for location in locations:
if location.info[self.parameter] in self.value_list:
location.lock_down_state=True
'''
class Vaccination(Policy):
def __init__(self,vaccinations_per_time_step_fn,vaccination_state,scheduled_time,agents_obj):
self.vaccinations_per_time_step_fn=vaccinations_per_time_step_fn
self.agents=agents_obj.agents
self.not_vaccinated_index=[]
for agent_index in self.agents.keys():
self.not_vaccinated_index.append(agent_index)
random.shuffle(self.not_vaccinated_index)
def enact_policy(self,time_step,agents,locations):
'''