-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.py
More file actions
63 lines (60 loc) · 1.56 KB
/
code.py
File metadata and controls
63 lines (60 loc) · 1.56 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from scipy.stats import poisson
import random
TF=[]
TH=[]
TC=[]
WqF=[]
WqH=[]
WqC=[]
Fserver_busy = False
Hserver_busy = False
Cserver_busy = False
jh=0
jc=0
jf=0
qlc=[]
qlf=[]
qlh=[]
#random the type of coffee and number of customer each minutes
def rand(a,i):
for k in range(0,a):
rand=random.randint(0,10)
if(rand>=7):
TC.append(i)
elif(rand>=4):
TH.append(i)
else:
TF.append(i)
#simulation in i minutes
for i in range(0,780):
qlf.append(len(TF))
qlh.append(len(TH))
qlc.append(len(TC))
if i <=750:
a=poisson.rvs(mu=1/3)
rand(a,i)
if not Fserver_busy and len(TF) > 0:
Fserver_busy= True
WqF.append(i-TF[0])
del TF[0]
jf=i+5
if jf<=i:
Fserver_busy = False
if not Cserver_busy and len(TC) > 0:
Cserver_busy= True
WqC.append(i-TC[0])
del TC[0]
jc=i+4
if jc<=i:
Cserver_busy = False
if not Hserver_busy and len(TH) > 0:
Hserver_busy= True
WqH.append(i-TH[0])
del TH[0]
jh=i+3
if jh<=i:
Hserver_busy= False
print(sum(WqH)/len(WqH),'is expect waiting time of customer who order Hot coffee in queue')
print(sum(WqC)/len(WqC),'is expect waiting time of customer who order Cold coffee in queue')
print(sum(WqF)/len(WqF),'is expect waiting time of customer who order Frappe coffee in queue')
print(max(qlf),',',max(qlh),',',max(qlc),'are maximum queue length of Frappe coffee, Hot coffee and Cold coffee respectivelly ')