-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexample_sim_call_center.py
133 lines (95 loc) · 2.94 KB
/
example_sim_call_center.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# Complex call center model
# Importing modules
# Simulator
from queuesim import Simulator
# Station types
from queuesim.stations import Source, Process, Decide, Delay, Dispose
# Pseudo random number generators
from queuesim.random_dist import exp as dist_exp
# Print results
from queuesim.models import call_center_results
# Plot model
from queuesim import build_graph
import networkx as nx
import matplotlib.pyplot as plt
import seaborn as sns
# Defining general plot style
sns.set()
# Model
#
# -------------
# v |
# Source -> Process -> Forward -> Dispose
# ^ | ^
# | Retry ---------------|
# | v
# |-- Delay
#
# This model can also be simulated via this online simulator:
# https://a-herzog.github.io/MiniSimulator/
# Model parameters
# Arrivals to be simulated
count = 100_000
# Arrival process
mean_i = 100
get_i = dist_exp(mean_i)
get_ib = None # Batch arrivals
# Service process
mean_s = 80
get_s = dist_exp(mean_s)
b = 1 # Service batch size
# Post-processing times
get_s2 = None
# Impatience
mean_nu = 900
get_nu = None # None = no impatience
# Retry process
retry_rate = 0
mean_retry_delay = 900
get_retry_delay = dist_exp(mean_retry_delay)
# Number of operators
c = 1
# System size
K = -1 # -1 stands for "unlimited"
# FIFO or LIFO client selection
LIFO = False
# Forwarding
forwarding_rate = 0
# In the model abpove many of the possible properties are not activated (like retry, forwardning, batching etc.).
# Also only the exponential distribution is used. So this just a M/M/c model with mit E[I]=100, E[S]=80 and c=1.
# This can be solved analytically. The results are:
#
# * Mean waiting time: E[W]=320
# * Mean service time: E[S]=80 (just defined above)
# * Mean residence time: E[V]=E[W]+E[S]=400
# * Mean queue length: E[N<sub>Q</sub>]=3,2
# * Mean number of clients in the system: E[N]=4
# * Utilization: ρ=80%
#
# Try changing some of the model parameters and see what happens in each case compared to the Erlang C base model.
# Define stations
simulator = Simulator()
source = Source(simulator, count, get_i, get_ib)
process = Process(simulator, get_s, c, get_nu, get_s2, K, b, LIFO)
forwarding = Decide(simulator)
retry = Decide(simulator)
delay = Delay(simulator, get_retry_delay)
dispose = Dispose(simulator)
# Link stations
source.set_next(process)
process.set_next(forwarding)
process.set_next_cancel(retry)
forwarding.add_next(dispose, 1 - forwarding_rate)
forwarding.add_next(process, forwarding_rate)
retry.add_next(dispose, 1 - retry_rate)
retry.add_next(delay, retry_rate)
delay.set_next(process)
# Run simulation
simulator.run()
# Show results
print(call_center_results(source, process, forwarding, retry, delay, dispose, simulator))
# Queueing network model
dg = build_graph([source])
fig, ax = plt.subplots(figsize=(19, 9))
nx.draw(dg, ax=ax, with_labels=True, node_color='#CCCCFF', node_size=2000, arrowsize=30, width=2)
plt.show()