-
Notifications
You must be signed in to change notification settings - Fork 1
/
example_analytic_erlang_c_ext.py
65 lines (45 loc) · 1.68 KB
/
example_analytic_erlang_c_ext.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
65
# Extended Erlang C (M/M/c/K+M model)
# This is an Erlang C model with impatient clients.
# Importing modules
# Erlang module
from queuesim.analytic import erlang_c_ext_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 ρ
# Arrival rate range
l_range = [1 / mean_i for mean_i in range(40, 75, 2)]
# Service rate
mu = 1 / 600
# Waiting cancelation rate
nu = 1 / 900
# Number of operators
c = 10
# System size
K = 20
# Erlang C results for different values of lambda
results = erlang_c_ext_table([(l, mu, nu, c, K) for l in l_range])
# Display results table
print(results)
# Plot results
fig, ax = plt.subplots(figsize=(16, 9))
line1 = ax.plot(results["rho_offered"], results["E[W]"], 'b', label="E[W]")
ax.tick_params(axis='y', labelcolor='b')
ax.set_xlabel("Offered utilization")
ax.set_ylabel("E[W]", color='b')
ax.xaxis.set_major_formatter(percent_formater)
lines1, labels1 = ax.get_legend_handles_labels()
ax = ax.twinx()
line2 = ax.plot(results["rho_offered"], results["P(A)"], 'r', label="P(A) (waiting cancelations)")
line3 = ax.plot(results["rho_offered"], results["P(blocked)"], 'r--', label="P(blocked) (blocked clients)")
line4 = ax.plot(results["rho_offered"], results["rho_real"], 'g', label="$\\rho$ (real utilization)")
ax.set_ylabel("P(A) and $\\rho$")
ax.yaxis.set_major_formatter(percent_formater)
lines2, labels2 = ax.get_legend_handles_labels()
ax.set_title("Extended Erlang C model at different utilizations")
ax.legend(lines1 + lines2, labels1 + labels2)
plt.show()