most-queue 2.3__py3-none-any.whl → 2.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- most_queue/io/plots.py +78 -54
- most_queue/io/tables.py +178 -149
- most_queue/misc/tests/test_fj_delta.py +2 -2
- most_queue/misc/vacations_paper_utils.py +2 -2
- {most_queue-2.3.dist-info → most_queue-2.5.dist-info}/METADATA +1 -1
- {most_queue-2.3.dist-info → most_queue-2.5.dist-info}/RECORD +8 -8
- {most_queue-2.3.dist-info → most_queue-2.5.dist-info}/WHEEL +0 -0
- {most_queue-2.3.dist-info → most_queue-2.5.dist-info}/licenses/LICENSE +0 -0
most_queue/io/plots.py
CHANGED
|
@@ -5,6 +5,7 @@ Plotting utilities for simulation results.
|
|
|
5
5
|
from enum import Enum
|
|
6
6
|
|
|
7
7
|
import matplotlib.pyplot as plt
|
|
8
|
+
from matplotlib.axes import Axes
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
class DependsType(Enum):
|
|
@@ -18,60 +19,83 @@ class DependsType(Enum):
|
|
|
18
19
|
COEFFICIENT_OF_VARIATION = 3
|
|
19
20
|
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
xs: list[float],
|
|
23
|
-
sim_results: list[float],
|
|
24
|
-
calc_results: list[float],
|
|
25
|
-
depends_on: DependsType = DependsType.CHANNELS_NUMBER,
|
|
26
|
-
is_errors=False,
|
|
27
|
-
is_waiting_time=True,
|
|
28
|
-
save_path=None,
|
|
29
|
-
): # pylint: disable=too-many-positional-arguments, too-many-arguments
|
|
22
|
+
class Plotter:
|
|
30
23
|
"""
|
|
31
|
-
|
|
32
|
-
:param xs: A list of x values (e.g., utilization factors or number of channels).
|
|
33
|
-
:type xs: list[float]
|
|
34
|
-
:param sim_results: A list of simulated results.
|
|
35
|
-
:type sim_results: list[float]
|
|
36
|
-
:param calc_results: A list of calculated results using some analytical or numerical method.
|
|
37
|
-
:param depends_on: The type of dependency for plotting
|
|
38
|
-
(utilization factor, number of channels, etc.).
|
|
39
|
-
:type depends_on: DependsType
|
|
40
|
-
:param is_errors: If True, plots the percentage error between
|
|
41
|
-
simulation and calculation results.
|
|
42
|
-
:type is_errors: bool
|
|
43
|
-
:param is_waiting_time: If True, labels the y-axis as waiting time; otherwise, as sojourn time.
|
|
44
|
-
:type is_waiting_time: bool
|
|
45
|
-
:param save_path: The path where the plot should be saved. If None, the plot will not be saved.
|
|
46
|
-
:type save_path: str or NoneType
|
|
47
|
-
:return: None
|
|
24
|
+
A class for plotting simulation results.
|
|
48
25
|
"""
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
26
|
+
|
|
27
|
+
def __init__(
|
|
28
|
+
self,
|
|
29
|
+
xs: list[float],
|
|
30
|
+
sim_results: list[float],
|
|
31
|
+
calc_results: list[float],
|
|
32
|
+
depends_on: DependsType = DependsType.CHANNELS_NUMBER,
|
|
33
|
+
):
|
|
34
|
+
self.xs = xs
|
|
35
|
+
self.sim_results = sim_results
|
|
36
|
+
self.calc_results = calc_results
|
|
37
|
+
self.depends_on = depends_on
|
|
38
|
+
|
|
39
|
+
def _configure_plot(self, ax: Axes, ylabel: str):
|
|
40
|
+
"""
|
|
41
|
+
Helper method to configure common plot elements.
|
|
42
|
+
"""
|
|
43
|
+
ax.set_ylabel(ylabel)
|
|
44
|
+
if self.depends_on == DependsType.UTILIZATION_FACTOR:
|
|
45
|
+
ax.set_xlabel(r"$\rho$")
|
|
46
|
+
elif self.depends_on == DependsType.COEFFICIENT_OF_VARIATION:
|
|
47
|
+
ax.set_xlabel(r"$\nu$")
|
|
48
|
+
else:
|
|
49
|
+
ax.set_xlabel("n")
|
|
50
|
+
plt.xticks(range(1, len(self.xs) + 1))
|
|
51
|
+
|
|
52
|
+
def plot_errors(self, save_path: str = None):
|
|
53
|
+
"""
|
|
54
|
+
Plots the simulation and calculated moments for a given list of x values.
|
|
55
|
+
"""
|
|
56
|
+
_fig, ax = plt.subplots()
|
|
57
|
+
errors = [100 * (w_sim - w_tt) / w_tt for w_sim, w_tt in zip(self.sim_results, self.calc_results)]
|
|
58
|
+
|
|
59
|
+
ax.plot(self.xs, errors, color="black")
|
|
60
|
+
self._configure_plot(ax, r"$\varepsilon$, %")
|
|
61
|
+
|
|
62
|
+
if save_path is not None:
|
|
63
|
+
plt.savefig(save_path, dpi=300)
|
|
60
64
|
else:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
ax.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
65
|
+
plt.show()
|
|
66
|
+
|
|
67
|
+
plt.close(_fig)
|
|
68
|
+
|
|
69
|
+
def plot_waiting(self, save_path: str = None):
|
|
70
|
+
"""
|
|
71
|
+
Plots the simulation and calculated queue waiting times.
|
|
72
|
+
"""
|
|
73
|
+
_fig, ax = plt.subplots()
|
|
74
|
+
ax.plot(self.xs, self.sim_results, label="Sim", color="black", linestyle="--")
|
|
75
|
+
ax.plot(self.xs, self.calc_results, label="Calc", color="black")
|
|
76
|
+
ax.legend()
|
|
77
|
+
self._configure_plot(ax, r"$\omega_{1}$")
|
|
78
|
+
|
|
79
|
+
if save_path is not None:
|
|
80
|
+
plt.savefig(save_path, dpi=300)
|
|
81
|
+
else:
|
|
82
|
+
plt.show()
|
|
83
|
+
|
|
84
|
+
plt.close(_fig)
|
|
85
|
+
|
|
86
|
+
def plot_sojourn(self, save_path: str = None):
|
|
87
|
+
"""
|
|
88
|
+
Plots the simulation and calculated sojourn times.
|
|
89
|
+
"""
|
|
90
|
+
_fig, ax = plt.subplots()
|
|
91
|
+
ax.plot(self.xs, self.sim_results, label="Sim", color="black", linestyle="--")
|
|
92
|
+
ax.plot(self.xs, self.calc_results, label="Calc", color="black")
|
|
93
|
+
ax.legend()
|
|
94
|
+
self._configure_plot(ax, r"$\upsilon_{1}$")
|
|
95
|
+
|
|
96
|
+
if save_path is not None:
|
|
97
|
+
plt.savefig(save_path, dpi=300)
|
|
98
|
+
else:
|
|
99
|
+
plt.show()
|
|
100
|
+
|
|
101
|
+
plt.close(_fig)
|
most_queue/io/tables.py
CHANGED
|
@@ -9,10 +9,9 @@ from colorama import Fore, Style, init
|
|
|
9
9
|
init()
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
def
|
|
13
|
-
sim_moments,
|
|
14
|
-
calc_moments,
|
|
15
|
-
is_w=True,
|
|
12
|
+
def print_moments(
|
|
13
|
+
sim_moments: list[float] | list[complex] | float | complex,
|
|
14
|
+
calc_moments: list[float] | list[complex] | float | complex,
|
|
16
15
|
header=None,
|
|
17
16
|
sim_header="Sim",
|
|
18
17
|
calc_header="Num",
|
|
@@ -20,22 +19,17 @@ def times_print(
|
|
|
20
19
|
"""
|
|
21
20
|
Prints the initial moments of waiting or sojourn time in the system.
|
|
22
21
|
Args:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
sim_moments (list): List of simulated moments.
|
|
23
|
+
calc_moments (list): List of calculated moments.
|
|
24
|
+
header (str): Header for the table.
|
|
25
|
+
sim_header (str): Header for simulated moments.
|
|
26
|
+
calc_header (str): Header for calculated moments.
|
|
28
27
|
"""
|
|
29
28
|
|
|
30
|
-
if header is None:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
else:
|
|
34
|
-
spec = "soujorn"
|
|
35
|
-
header = f"Initial moments of {spec} time in the system"
|
|
29
|
+
if not header is None:
|
|
30
|
+
print(Fore.CYAN + f"\n{header:^45}")
|
|
31
|
+
print("-" * 45)
|
|
36
32
|
|
|
37
|
-
print(Fore.CYAN + f"\n{header:^45}")
|
|
38
|
-
print("-" * 45)
|
|
39
33
|
num_col = "#"
|
|
40
34
|
print(f"{num_col:^15s}|{calc_header:^15s}|{sim_header:^15s}")
|
|
41
35
|
print("-" * 45)
|
|
@@ -69,33 +63,63 @@ def times_print(
|
|
|
69
63
|
print(Style.RESET_ALL)
|
|
70
64
|
|
|
71
65
|
|
|
72
|
-
def
|
|
73
|
-
sim_moments,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
num1_header="Num1",
|
|
78
|
-
num2_header="Num2",
|
|
66
|
+
def print_waiting_times(
|
|
67
|
+
sim_moments: list[float] | list[complex] | float | complex,
|
|
68
|
+
calc_moments: list[float] | list[complex] | float | complex,
|
|
69
|
+
sim_header="Sim",
|
|
70
|
+
calc_header="Num",
|
|
79
71
|
): # pylint: disable=too-many-positional-arguments, too-many-arguments
|
|
80
72
|
"""
|
|
81
73
|
Prints the initial moments of waiting or sojourn time in the system.
|
|
82
74
|
Args:
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
75
|
+
sim_moments (list): List of simulated moments.
|
|
76
|
+
calc_moments (list): List of calculated moments.
|
|
77
|
+
sim_header (str): Header for simulated moments.
|
|
78
|
+
calc_header (str): Header for calculated moments
|
|
79
|
+
"""
|
|
80
|
+
|
|
81
|
+
header = "Initial moments of waiting time in the system"
|
|
82
|
+
|
|
83
|
+
print_moments(sim_moments, calc_moments, sim_header=sim_header, calc_header=calc_header, header=header)
|
|
88
84
|
|
|
85
|
+
|
|
86
|
+
def print_sojourn_times(
|
|
87
|
+
sim_moments: list[float] | list[complex] | float | complex,
|
|
88
|
+
calc_moments: list[float] | list[complex] | float | complex,
|
|
89
|
+
sim_header="Sim",
|
|
90
|
+
calc_header="Num",
|
|
91
|
+
): # pylint: disable=too-many-positional-arguments, too-many-arguments
|
|
92
|
+
"""
|
|
93
|
+
Prints the initial moments of waiting or sojourn time in the system.
|
|
94
|
+
Args:
|
|
95
|
+
sim_moments (list): List of simulated moments.
|
|
96
|
+
calc_moments (list): List of calculated moments.
|
|
97
|
+
sim_header (str): Header for simulated moments.
|
|
98
|
+
calc_header (str): Header for calculated moments
|
|
89
99
|
"""
|
|
90
100
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
101
|
+
header = "Initial moments of sojourn time in the system"
|
|
102
|
+
|
|
103
|
+
print_moments(sim_moments, calc_moments, sim_header=sim_header, calc_header=calc_header, header=header)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def print_with_two_numerical(
|
|
107
|
+
sim_moments: list[float] | list[complex] | float | complex,
|
|
108
|
+
calc_moments1: list[float] | list[complex] | float | complex,
|
|
109
|
+
calc_moments2: list[float] | list[complex] | float | complex,
|
|
110
|
+
num1_header="Num1",
|
|
111
|
+
num2_header="Num2",
|
|
112
|
+
):
|
|
113
|
+
"""
|
|
114
|
+
Prints the initial moments.
|
|
115
|
+
Args:
|
|
116
|
+
sim_moments (list): List of simulated moments.
|
|
117
|
+
calc_moments1 (list): List of calculated moments for the first approximation.
|
|
118
|
+
calc_moments2 (list): List of calculated moments for the second approximation.
|
|
119
|
+
num1_header (str, optional): Header for the first numerical approximation.
|
|
120
|
+
num2_header (str, optional): Header for the second numerical approximation.
|
|
121
|
+
"""
|
|
96
122
|
|
|
97
|
-
print(Fore.CYAN + f"\n{header:^45}")
|
|
98
|
-
print("-" * 60)
|
|
99
123
|
num_col = "#"
|
|
100
124
|
print(f"{num_col:^15s}|{num1_header:^15s}|{num2_header:^15s}|{'Sim':^15s}")
|
|
101
125
|
print("-" * 60)
|
|
@@ -140,75 +164,136 @@ def times_print_with_two_numerical(
|
|
|
140
164
|
print(Style.RESET_ALL)
|
|
141
165
|
|
|
142
166
|
|
|
143
|
-
def
|
|
167
|
+
def print_waiting_times_with_two_numerical(
|
|
168
|
+
sim_moments,
|
|
169
|
+
calc_moments1,
|
|
170
|
+
calc_moments2,
|
|
171
|
+
num1_header="Num1",
|
|
172
|
+
num2_header="Num2",
|
|
173
|
+
):
|
|
144
174
|
"""
|
|
145
|
-
Prints the
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
175
|
+
Prints the initial moments of waiting in the system.
|
|
176
|
+
Args:
|
|
177
|
+
sim_moments (list): List of simulated moments.
|
|
178
|
+
calc_moments1 (list): List of calculated moments for the first approximation.
|
|
179
|
+
calc_moments2 (list): List of calculated moments for the second approximation.
|
|
180
|
+
num1_header (str, optional): Header for the first numerical approximation.
|
|
181
|
+
num2_header (str, optional): Header for the second numerical approximation.
|
|
182
|
+
|
|
149
183
|
"""
|
|
150
184
|
|
|
151
|
-
|
|
152
|
-
raise ValueError("Either wait_times or sojourn_times must be provided.")
|
|
185
|
+
header = "Initial moments of waiting time in the system"
|
|
153
186
|
|
|
154
|
-
|
|
187
|
+
print(Fore.CYAN + f"\n{header:^45}")
|
|
188
|
+
print("-" * 60)
|
|
189
|
+
print_with_two_numerical(
|
|
190
|
+
sim_moments=sim_moments,
|
|
191
|
+
calc_moments1=calc_moments1,
|
|
192
|
+
calc_moments2=calc_moments2,
|
|
193
|
+
num1_header=num1_header,
|
|
194
|
+
num2_header=num2_header,
|
|
195
|
+
)
|
|
155
196
|
|
|
156
|
-
print(Fore.CYAN + "Initial moments of sojourn and wait times in the system")
|
|
157
197
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
+ f"{v_mom:^15.5g}"
|
|
174
|
-
)
|
|
175
|
-
else:
|
|
176
|
-
w_mom = wait_times.real if isinstance(wait_times, complex) else wait_times
|
|
177
|
-
v_mom = sojourn_times.real if isinstance(sojourn_times, complex) else sojourn_times
|
|
178
|
-
print(
|
|
179
|
-
Fore.CYAN
|
|
180
|
-
+ f"{1:^15d}|"
|
|
181
|
-
+ Fore.YELLOW
|
|
182
|
-
+ f"{w_mom:^15.5g}"
|
|
183
|
-
+ Fore.CYAN
|
|
184
|
-
+ "|"
|
|
185
|
-
+ Fore.YELLOW
|
|
186
|
-
+ f"{v_mom:^15.5g}"
|
|
187
|
-
)
|
|
198
|
+
def print_sojourn_times_with_two_numerical(
|
|
199
|
+
sim_moments,
|
|
200
|
+
calc_moments1,
|
|
201
|
+
calc_moments2,
|
|
202
|
+
num1_header="Num1",
|
|
203
|
+
num2_header="Num2",
|
|
204
|
+
):
|
|
205
|
+
"""
|
|
206
|
+
Prints the initial moments of sojourn time in the system.
|
|
207
|
+
Args:
|
|
208
|
+
sim_moments (list): List of simulated moments.
|
|
209
|
+
calc_moments1 (list): List of calculated moments for the first approximation.
|
|
210
|
+
calc_moments2 (list): List of calculated moments for the second approximation.
|
|
211
|
+
is_w (bool, optional): If True, prints waiting time moments.
|
|
212
|
+
Otherwise, prints sojourn time moments. Defaults to True.
|
|
188
213
|
|
|
189
|
-
|
|
214
|
+
"""
|
|
190
215
|
|
|
191
|
-
|
|
192
|
-
times = wait_times if wait_times is not None else sojourn_times
|
|
193
|
-
spec = "wait" if wait_times is not None else "sojourn"
|
|
194
|
-
times_header = "w" if wait_times is not None else "v"
|
|
195
|
-
header = f"Initial moments of {spec} time in the system"
|
|
216
|
+
header = "Initial moments of sojourn time in the system"
|
|
196
217
|
|
|
197
|
-
|
|
218
|
+
print(Fore.CYAN + f"\n{header:^45}")
|
|
219
|
+
print("-" * 60)
|
|
220
|
+
print_with_two_numerical(
|
|
221
|
+
sim_moments=sim_moments,
|
|
222
|
+
calc_moments1=calc_moments1,
|
|
223
|
+
calc_moments2=calc_moments2,
|
|
224
|
+
num1_header=num1_header,
|
|
225
|
+
num2_header=num2_header,
|
|
226
|
+
)
|
|
198
227
|
|
|
199
|
-
num_col = "#"
|
|
200
|
-
print(f"{num_col:^15s}|{times_header:^15s}")
|
|
201
|
-
print("-" * 30)
|
|
202
|
-
if isinstance(times, list):
|
|
203
|
-
for j, mom in enumerate(times):
|
|
204
|
-
mom = mom.real if isinstance(mom, complex) else mom
|
|
205
|
-
print(Fore.CYAN + f"{j + 1:^15d}|" + Fore.YELLOW + f"{mom:^15.5g}" + Fore.CYAN)
|
|
206
|
-
else:
|
|
207
|
-
mom = times.real if isinstance(times, complex) else times
|
|
208
228
|
|
|
209
|
-
|
|
229
|
+
def print_moments_with_classes(sim_moments, calc_moments):
|
|
230
|
+
"""
|
|
231
|
+
Print moments with classes
|
|
232
|
+
:param sim_moments: Simulated moments
|
|
233
|
+
:param calc_moments: Calculated moments
|
|
234
|
+
"""
|
|
235
|
+
k_num = len(sim_moments)
|
|
236
|
+
size = len(sim_moments[0])
|
|
210
237
|
|
|
211
|
-
|
|
238
|
+
blank_col, header_col, cls_col = "", "Number of moment", "Cls"
|
|
239
|
+
num_col, sim_col = "Num", "Sim"
|
|
240
|
+
|
|
241
|
+
print("-" * 60)
|
|
242
|
+
print(f"{blank_col:^11}|{header_col:^47}|")
|
|
243
|
+
print(f"{cls_col:^11}| ", end="")
|
|
244
|
+
print("-" * 45 + " |")
|
|
245
|
+
|
|
246
|
+
print(" " * 11 + "|", end="")
|
|
247
|
+
for j in range(size):
|
|
248
|
+
s = str(j + 1)
|
|
249
|
+
print(f"{s:^15}|", end="")
|
|
250
|
+
print("")
|
|
251
|
+
print("-" * 60)
|
|
252
|
+
|
|
253
|
+
for i in range(k_num):
|
|
254
|
+
print(Fore.CYAN + " " * 5 + "|", end="")
|
|
255
|
+
print(Fore.CYAN + f"{sim_col:^5}|", end="")
|
|
256
|
+
for j in range(size):
|
|
257
|
+
print(Fore.YELLOW + f"{sim_moments[i][j]:^15.3g}" + Fore.CYAN + "|", end="")
|
|
258
|
+
print("")
|
|
259
|
+
print(Fore.CYAN + f"{str(i + 1):^5}" + "|" + "-" * 54)
|
|
260
|
+
|
|
261
|
+
print(Fore.CYAN + " " * 5 + "|", end="")
|
|
262
|
+
print(Fore.CYAN + f"{num_col:^5}|", end="")
|
|
263
|
+
for j in range(size):
|
|
264
|
+
print(Fore.YELLOW + f"{calc_moments[i][j]:^15.3g}" + Fore.CYAN + "|", end="")
|
|
265
|
+
print("")
|
|
266
|
+
print(Fore.CYAN + "-" * 60)
|
|
267
|
+
|
|
268
|
+
print("\n")
|
|
269
|
+
|
|
270
|
+
print(Style.RESET_ALL)
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
def print_waiting_with_classes(sim_moments, calc_moments):
|
|
274
|
+
"""
|
|
275
|
+
Print waiting moments with classes
|
|
276
|
+
:param sim_moments: Simulated moments
|
|
277
|
+
:param calc_moments: Calculated moments
|
|
278
|
+
"""
|
|
279
|
+
header = "Initial moments of waiting time in the system"
|
|
280
|
+
|
|
281
|
+
print(Fore.CYAN + f"{header:^60s}")
|
|
282
|
+
|
|
283
|
+
print_moments_with_classes(sim_moments, calc_moments)
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
def print_sojourn_with_classes(sim_moments, calc_moments):
|
|
287
|
+
"""
|
|
288
|
+
Print sojourn moments with classes
|
|
289
|
+
:param sim_moments: Simulated moments
|
|
290
|
+
:param calc_moments: Calculated moments
|
|
291
|
+
"""
|
|
292
|
+
header = "Initial moments of sojourn time in the system"
|
|
293
|
+
|
|
294
|
+
print(Fore.CYAN + f"{header:^60s}")
|
|
295
|
+
|
|
296
|
+
print_moments_with_classes(sim_moments, calc_moments)
|
|
212
297
|
|
|
213
298
|
|
|
214
299
|
def probs_print(p_sim, p_num, size=10):
|
|
@@ -265,62 +350,6 @@ def probs_print_no_compare(probs, size=10, header="Probabilities of states"):
|
|
|
265
350
|
print(Style.RESET_ALL)
|
|
266
351
|
|
|
267
352
|
|
|
268
|
-
def times_print_with_classes(sim_moments, calc_moments, is_w=True):
|
|
269
|
-
"""
|
|
270
|
-
Print moments with classes
|
|
271
|
-
:param sim_moments: Simulated moments
|
|
272
|
-
:param calc_moments: Calculated moments
|
|
273
|
-
:param is_w: If True, print waiting time, else print sojourn time
|
|
274
|
-
:return: None
|
|
275
|
-
|
|
276
|
-
"""
|
|
277
|
-
if is_w:
|
|
278
|
-
spec = "waiting"
|
|
279
|
-
else:
|
|
280
|
-
spec = "soujorn"
|
|
281
|
-
|
|
282
|
-
header = f"Initial moments of {spec} time in the system"
|
|
283
|
-
|
|
284
|
-
k_num = len(sim_moments)
|
|
285
|
-
size = len(sim_moments[0])
|
|
286
|
-
|
|
287
|
-
print(Fore.CYAN + f"{header:^60s}")
|
|
288
|
-
|
|
289
|
-
blank_col, header_col, cls_col = "", "Number of moment", "Cls"
|
|
290
|
-
num_col, sim_col = "Num", "Sim"
|
|
291
|
-
|
|
292
|
-
print("-" * 60)
|
|
293
|
-
print(f"{blank_col:^11}|{header_col:^47}|")
|
|
294
|
-
print(f"{cls_col:^11}| ", end="")
|
|
295
|
-
print("-" * 45 + " |")
|
|
296
|
-
|
|
297
|
-
print(" " * 11 + "|", end="")
|
|
298
|
-
for j in range(size):
|
|
299
|
-
s = str(j + 1)
|
|
300
|
-
print(f"{s:^15}|", end="")
|
|
301
|
-
print("")
|
|
302
|
-
print("-" * 60)
|
|
303
|
-
|
|
304
|
-
for i in range(k_num):
|
|
305
|
-
print(Fore.CYAN + " " * 5 + "|", end="")
|
|
306
|
-
print(Fore.CYAN + f"{sim_col:^5}|", end="")
|
|
307
|
-
for j in range(size):
|
|
308
|
-
print(Fore.YELLOW + f"{sim_moments[i][j]:^15.3g}" + Fore.CYAN + "|", end="")
|
|
309
|
-
print("")
|
|
310
|
-
print(Fore.CYAN + f"{str(i + 1):^5}" + "|" + "-" * 54)
|
|
311
|
-
|
|
312
|
-
print(Fore.CYAN + " " * 5 + "|", end="")
|
|
313
|
-
print(Fore.CYAN + f"{num_col:^5}|", end="")
|
|
314
|
-
for j in range(size):
|
|
315
|
-
print(Fore.YELLOW + f"{calc_moments[i][j]:^15.3g}" + Fore.CYAN + "|", end="")
|
|
316
|
-
print("")
|
|
317
|
-
print(Fore.CYAN + "-" * 60)
|
|
318
|
-
|
|
319
|
-
print("\n")
|
|
320
|
-
|
|
321
|
-
print(Style.RESET_ALL)
|
|
322
|
-
|
|
323
|
-
|
|
324
353
|
def print_mrx(mrx, is_short=False):
|
|
325
354
|
"""
|
|
326
355
|
Print matrix mrx
|
|
@@ -7,7 +7,7 @@ import os
|
|
|
7
7
|
import numpy as np
|
|
8
8
|
import yaml
|
|
9
9
|
|
|
10
|
-
from most_queue.io.tables import
|
|
10
|
+
from most_queue.io.tables import print_sojourn_times
|
|
11
11
|
from most_queue.random.distributions import GammaDistribution
|
|
12
12
|
from most_queue.sim.fork_join_delta import ForkJoinSimDelta
|
|
13
13
|
from most_queue.theory.fork_join.split_join import SplitJoinCalc
|
|
@@ -72,7 +72,7 @@ def test_fj_delta():
|
|
|
72
72
|
print(f"Coefficient of variation of delay: {SERVICE_TIME_CV:.3f}")
|
|
73
73
|
print(f"Utilization coefficient: {utilization:.3f}")
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
print_sojourn_times(v_sim, v_num)
|
|
76
76
|
|
|
77
77
|
assert len(v_sim) == len(v_num)
|
|
78
78
|
assert np.allclose(np.array(v_sim), np.array(v_num), rtol=MOMENTS_RTOL, atol=MOMENTS_ATOL), ERROR_MSG
|
|
@@ -7,7 +7,7 @@ import math
|
|
|
7
7
|
|
|
8
8
|
import matplotlib.pyplot as plt
|
|
9
9
|
|
|
10
|
-
from most_queue.io.tables import
|
|
10
|
+
from most_queue.io.tables import print_waiting_times, probs_print
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
def print_table(experiments_stat):
|
|
@@ -47,7 +47,7 @@ def print_table(experiments_stat):
|
|
|
47
47
|
print(f"Simulation time: {stat['sim_time']:0.3f} c")
|
|
48
48
|
|
|
49
49
|
probs_print(p_sim=stat["p_sim"], p_num=stat["p_tt"], size=10)
|
|
50
|
-
|
|
50
|
+
print_waiting_times(sim_moments=stat["w_sim"], calc_moments=stat["w_tt"])
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
def dump_stat(experiments_stat, save_name="run_stat.json"):
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
most_queue/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
most_queue/structs.py,sha256=zS729ThgYaJWSU_p2kvZvKTL1yu5qJHJ0KMmkloHK-A,5089
|
|
3
3
|
most_queue/io/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
most_queue/io/plots.py,sha256=
|
|
5
|
-
most_queue/io/tables.py,sha256=
|
|
4
|
+
most_queue/io/plots.py,sha256=ihD-qB-0x64ILG_QBNzIChDaIrwe5ORM9ilCtS2qf24,2848
|
|
5
|
+
most_queue/io/tables.py,sha256=n0wK8xP9L77WClbkCxzV0Td5ddg6rKxJD5GggpqZJXA,12435
|
|
6
6
|
most_queue/misc/approx_cdf_make.py,sha256=yI1Xd-cMuqD05gDDMR3ZxlzXuGHCdmEPLzJJdOXo92c,2338
|
|
7
7
|
most_queue/misc/calc_v_pls.py,sha256=r_faWBLc_LU5bZngt48dYKFhUKI3i9WkiRlZoUYOkig,10688
|
|
8
8
|
most_queue/misc/compare_fj_calc.py,sha256=M0ZE9xUhzBu_BJ7bYtRCQSZOjOkCvlkHq7X-mGKbs4s,5314
|
|
9
9
|
most_queue/misc/flow_sum.py,sha256=vEhALDaBWpIsZPAhcKA9iRGsYmb-bi2W6o95FBXZ73o,4575
|
|
10
10
|
most_queue/misc/run_mgn_with_h2_delay_cold_warm.py,sha256=nvAX27lRg0bb9bih4zQgDBUrwu5LJwbpRWDsdp6sshg,17748
|
|
11
|
-
most_queue/misc/vacations_paper_utils.py,sha256=
|
|
12
|
-
most_queue/misc/tests/test_fj_delta.py,sha256=
|
|
11
|
+
most_queue/misc/vacations_paper_utils.py,sha256=ksh-RwjH8pijqUiwDdWhG0-4VRSheMbbnhuQD161bYs,4277
|
|
12
|
+
most_queue/misc/tests/test_fj_delta.py,sha256=q52laz6uih_EHwae6PqZ13upFRF2-5-_XXdQkM3h0mA,2576
|
|
13
13
|
most_queue/misc/tests/test_network_opt_approx.py,sha256=SSIB40m3dSZPwuOt_57GJ_FvVETsLplk-ufrtWE4fAE,1543
|
|
14
14
|
most_queue/misc/tests/test_network_opt_plus.py,sha256=HZ_k9fd6VNWiQwwSQ7CyZXd_PW7oxlXnDb0w-BNDHiU,1815
|
|
15
15
|
most_queue/random/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -104,7 +104,7 @@ most_queue/theory/vacations/m_h2_h2warm.py,sha256=HWEJHBrUr7Dt7Zt79AJBCqVvY7bqmh
|
|
|
104
104
|
most_queue/theory/vacations/mg1_warm_calc.py,sha256=8C5958gYXgPnpSCrNsWPDhCFMNOa76nvDGYFIJ5rpvM,3696
|
|
105
105
|
most_queue/theory/vacations/mgn_with_h2_delay_cold_warm.py,sha256=pUE0qigwwQ3SznbTOT9inBfgnwQUsT5rQ-zowXXbsn0,28593
|
|
106
106
|
most_queue/theory/vacations/mmn_with_h2_cold_and_h2_warmup.py,sha256=xzTRNslsHvdfp8vq_b4fZTiuWfzW1lMhdrnqPizxRB8,21264
|
|
107
|
-
most_queue-2.
|
|
108
|
-
most_queue-2.
|
|
109
|
-
most_queue-2.
|
|
110
|
-
most_queue-2.
|
|
107
|
+
most_queue-2.5.dist-info/METADATA,sha256=dG-OVrKZVmsBZAFIzBJEjrCCVc0FcdUonJJLdxZmjTc,13392
|
|
108
|
+
most_queue-2.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
109
|
+
most_queue-2.5.dist-info/licenses/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
|
|
110
|
+
most_queue-2.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|