forked from aalok-sathe/fire-evacuation-simulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bottleneck.py
38 lines (32 loc) · 1.21 KB
/
bottleneck.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
'''
This file accompanies other files in the evacuation simulation project.
people: Nick B., Matthew J., Aalok S.
In this file we define a useful class to model bottlenecks, 'Bottleneck'
'''
from collections import deque
# bottleneck object, represents an area where people must queue to leave, given
# a set rate at which they can pass through, one by one
class Bottleneck():
loc = None, None
queue = None
numInQueue = 0
# takes a person, and inserts them into the queue of the bottleneck
def enterBottleNeck(self, person, throughput=1):
self.queue.append(person)
self.numInQueue = self.numInQueue + throughput
# removes a person from the queue
def exitBottleNeck(self, throughput=1):
if(len(self.queue) > 0):
personLeaving = self.queue.pop()
self.numInQueue = self.numInQueue - throughput
return personLeaving
else:
return None
def __init__(self, loc):
'''
constructor method
---
loc (tuple xy): location (coordinates) of this bottleneck
'''
self.loc = loc # coordinates of the bottleneck
self.queue = deque() # queue to represents the bottleneck