-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexample_analytic_ac_approx.py
64 lines (42 loc) · 1.74 KB
/
example_analytic_ac_approx.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Allen Cunneen approximation (GI/G/c model)
# For models with general inter-arrival and service times there are no exact analytic solutions. The Allen Cunneen formula will give some approximation results.
# Importing modules
# Erlang module
from queuesim.analytic import ac_approx_table
# Plotting modules
import matplotlib.pyplot as plt
import matplotlib.ticker as formater
import seaborn as sns
# Defining general plot style
sns.set()
percent_formater = formater.PercentFormatter(xmax=1, decimals=0)
# Mean waiting time as a function of the coefficient of variation of the service times
# Arrival rate
l = 1 / 100
# Service rate
mu = 1 / 80
# Number of operators
c = 1
# Coefficient of variation of the inter-arrival times
cv_i = 1 # exponential distribution has always cv_i = 1
# Coefficient of variation of the service times range
cv_s_range = [i / 10 for i in range(5, 16)]
# Allen Cunneen results for different values of cv_s
results = ac_approx_table([(l, mu, c, cv_i**2, cv_s**2) for cv_s in cv_s_range])
# Display results table
print(results)
# Plot results
fig, ax = plt.subplots(figsize=(16, 9))
ax.plot(results["CV[S]"], results["E[W]"], 'r')
ax.tick_params(axis='y', labelcolor='r')
ax.set_xlabel("Coefficient of variation of the service times CV[S]")
ax.set_ylabel("E[W]", color='r')
ax.xaxis.set_major_formatter(percent_formater)
ax = ax.twinx()
ax.plot(results["CV[S]"], results["rho"], 'g')
ax.tick_params(axis='y', labelcolor='g')
ax.set_ylabel("Utilization $\\rho$", color='g')
ax.yaxis.set_major_formatter(percent_formater)
ax.set_title("Allen Cunneen model at different coefficients of variation of the service times")
plt.show()
# The mean waiting time is increasing at increasing variations of the service times (at fixed utilization).