-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevents.py
More file actions
44 lines (35 loc) · 1.01 KB
/
events.py
File metadata and controls
44 lines (35 loc) · 1.01 KB
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
from functools import total_ordering
@total_ordering
class Event:
"""
An abstraction of an event
It contains two instance variables:
time: the event time
owner: the agent whom this event is attached to
It has a n important method:
handle: it processes this event
"""
def __init__(self, time):
"""
constructor.
:param time: the time of the event
:return: None
"""
# instance variables:
# time: event time
self.time = time
# owner: the agent that owns the event
self.owner = None
def handle(self, sim):
"""
handle the event
:param sim: the current simulation
:param owner: the previous owner of this event. Note that when the event is handled,
it has already be unscheduled
:return: None
"""
pass
def __lt__(self, other):
return self.time < other.time
def __eq__(self, other):
return self.time == other.time