-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAgent.py
49 lines (40 loc) · 1.36 KB
/
Agent.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
import random
import copy
import numpy as np
class Agent():
def __init__(self,state,info_dict):
self.state=state
self.next_state=None
self.contact_list=[]
self.location_list=[]
self.info=info_dict
self.index=info_dict['Agent Index']
self.event_probabilities=[]
self.schedule_time_left=None
self.testing_history=[] #tuple of (<testing time(Time tested)>, <testing type(Pool, Antigen,...)>, <test machine id(unique machine)>, <result(Positive, Negative, Viral Load...)>)
self.compliance = None #Can be a dictionary of Guideline compliance, Restriction compliancce, Governemnt Policy compliance
self.lock_down_state=False
def add_contact(self,contact_dict):
if not self.lock_down_state:
self.contact_list.append(contact_dict)
def add_event_result(self,p):
if not self.lock_down_state:
self.event_probabilities.append(p)
def new_time_step(self):
self.lock_down_state=False
self.next_state=None
self.contact_list=[]
self.event_probabilities=[]
if self.schedule_time_left!=None:
self.schedule_time_left-=1
if self.schedule_time_left <=0:
self.schedule_time_left=None
def update_state(self):
if self.next_state==None:
return
self.state=self.next_state
self.next_state=None
def set_next_state(self,state_info):
next_state,schedule_time=state_info
self.next_state=next_state
self.schedule_time_left=schedule_time