-
Notifications
You must be signed in to change notification settings - Fork 0
/
Queue.py
33 lines (29 loc) · 892 Bytes
/
Queue.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
import numpy as np
from Customer import Customer
class Queue():
def __init__(self,meanArrivalTime = 5):
self.customers=[]
self.maxLen=0
self.customerServerd = []
self.available = 1
self.maxNumBusyServer = 0
self.numCustomer = []
self.meanArrivalTime = meanArrivalTime
def updateMaxLen(self):
if(len(self.customers)>self.maxLen):
self.maxLen = len(self.customers)
def generateCustomer(self,env):
id =0
while(self.available):
arrival_time=np.random.exponential(self.meanArrivalTime)
yield env.timeout(arrival_time)
c=Customer()
c.arrival_timeStamp = env.now
c.interarrival_time = arrival_time
c.id = id
id+=1
self.customers.append(c)
if(len(self.customers)>self.maxLen):
self.maxLen = len(self.customers)
self.numCustomer += [len(self.customers)]
return 0