-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathone-server.py
45 lines (35 loc) · 1.09 KB
/
one-server.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
import numpy as np
import scipy.stats as st
rnd = np.random
rnd.seed(1)
end_time = 60 * 8
fel = [{'Type': 'Llegada', 't': st.expon.ppf(rnd.rand(), loc=0, scale=3)}]
clock = 0
Q = 0
Cajero = 0
Cliente = 0
lq = [(0, 0)]
Tiempo_espera = [(0, 0)]
while clock <= end_time:
fel = sorted(fel, key=lambda e: e['t'])
current_event = fel.pop(0)
previous_q = Q
previous_clock = clock
clock = current_event['t']
if current_event['Type'] == 'Llegada':
Cliente += 1
if Cajero == 0:
Cajero = 1
fel.append({'Type': 'Atencion', 't': clock + st.expon.ppf(rnd.rand(), loc=0, scale=4)})
else:
Q += 1
fel.append({'Type': 'Llegada', 't': clock + st.expon.ppf(rnd.rand(), loc=0, scale=3)})
elif current_event['Type'] == 'Atencion':
if Q > 0:
Q -= 1
Cajero = 1
fel.append({'Type': 'Atencion', 't': clock + st.expon.ppf(rnd.rand(), loc=0, scale=4)})
else:
Cajero = 0
lq.append((clock, Q, previous_clock, clock-previous_clock, previous_q))
Tiempo_espera.append(())