most-queue 2.4__tar.gz → 2.5__tar.gz

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.
Files changed (186) hide show
  1. {most_queue-2.4 → most_queue-2.5}/.gitignore +8 -1
  2. {most_queue-2.4 → most_queue-2.5}/PKG-INFO +1 -1
  3. most_queue-2.5/most_queue/io/plots.py +101 -0
  4. {most_queue-2.4 → most_queue-2.5}/most_queue/io/tables.py +178 -149
  5. {most_queue-2.4 → most_queue-2.5}/most_queue/misc/tests/test_fj_delta.py +2 -2
  6. {most_queue-2.4 → most_queue-2.5}/most_queue/misc/vacations_paper_utils.py +2 -2
  7. {most_queue-2.4 → most_queue-2.5}/pyproject.toml +1 -1
  8. {most_queue-2.4 → most_queue-2.5}/setup.py +1 -1
  9. {most_queue-2.4 → most_queue-2.5}/tests/test_base_qs_sim.py +2 -2
  10. {most_queue-2.4 → most_queue-2.5}/tests/test_batch.py +2 -2
  11. {most_queue-2.4 → most_queue-2.5}/tests/test_engset.py +3 -3
  12. {most_queue-2.4 → most_queue-2.5}/tests/test_fj_sim.py +2 -2
  13. {most_queue-2.4 → most_queue-2.5}/tests/test_gi_m_1_calc.py +3 -3
  14. {most_queue-2.4 → most_queue-2.5}/tests/test_gi_m_n_calc.py +3 -3
  15. {most_queue-2.4 → most_queue-2.5}/tests/test_impatience.py +2 -2
  16. {most_queue-2.4 → most_queue-2.5}/tests/test_m_h2_h2warm.py +3 -3
  17. {most_queue-2.4 → most_queue-2.5}/tests/test_mg1_calc.py +3 -3
  18. {most_queue-2.4 → most_queue-2.5}/tests/test_mg1_disaster.py +3 -3
  19. {most_queue-2.4 → most_queue-2.5}/tests/test_mg1_rcs.py +2 -3
  20. {most_queue-2.4 → most_queue-2.5}/tests/test_mg1_warmup.py +2 -2
  21. {most_queue-2.4 → most_queue-2.5}/tests/test_mgn_disaster.py +5 -5
  22. {most_queue-2.4 → most_queue-2.5}/tests/test_mgn_rcs.py +5 -5
  23. {most_queue-2.4 → most_queue-2.5}/tests/test_mgn_tt.py +3 -3
  24. {most_queue-2.4 → most_queue-2.5}/tests/test_mgn_with_h2_delay_cold_warm.py +2 -2
  25. {most_queue-2.4 → most_queue-2.5}/tests/test_mm2_3cls_prty_busy.py +4 -8
  26. {most_queue-2.4 → most_queue-2.5}/tests/test_mmn_h2cold_h2warm.py +2 -2
  27. {most_queue-2.4 → most_queue-2.5}/tests/test_mmn_prty_busy_approx.py +4 -9
  28. {most_queue-2.4 → most_queue-2.5}/tests/test_network_im_prty.py +3 -3
  29. {most_queue-2.4 → most_queue-2.5}/tests/test_network_no_prty.py +2 -2
  30. {most_queue-2.4 → most_queue-2.5}/tests/test_qs_sim.py +3 -3
  31. {most_queue-2.4 → most_queue-2.5}/tests/test_qs_sim_prty.py +3 -3
  32. {most_queue-2.4 → most_queue-2.5}/tests/units/test_busy_moments_calc.py +2 -2
  33. {most_queue-2.4 → most_queue-2.5}/tests/units/test_conditionals.py +4 -4
  34. {most_queue-2.4 → most_queue-2.5}/tutorials/m_h2_h2warm.ipynb +4 -4
  35. {most_queue-2.4 → most_queue-2.5}/tutorials/mgn_takahasi_takami.ipynb +4 -4
  36. {most_queue-2.4 → most_queue-2.5}/tutorials/network_with_priorities.ipynb +5 -5
  37. {most_queue-2.4 → most_queue-2.5}/tutorials/priority_queue.ipynb +2 -2
  38. {most_queue-2.4 → most_queue-2.5}/tutorials/queue_sim.ipynb +3 -3
  39. {most_queue-2.4 → most_queue-2.5}/works/negative_queues/work_mgn_negatives.py +11 -9
  40. {most_queue-2.4 → most_queue-2.5}/works/vacations/run_one_calc_vs_sim.py +2 -2
  41. most_queue-2.4/docs/Makefile +0 -20
  42. most_queue-2.4/docs/make.bat +0 -35
  43. most_queue-2.4/docs/source/conf.py +0 -32
  44. most_queue-2.4/docs/source/index.rst +0 -19
  45. most_queue-2.4/docs/source/modules.rst +0 -7
  46. most_queue-2.4/docs/source/most_queue.rst +0 -30
  47. most_queue-2.4/docs/source/most_queue.sim.rst +0 -71
  48. most_queue-2.4/docs/source/most_queue.theory.rst +0 -182
  49. most_queue-2.4/doctest-output/QS.gv +0 -18
  50. most_queue-2.4/most_queue/io/plots.py +0 -77
  51. {most_queue-2.4 → most_queue-2.5}/.pre-commit-config.yaml +0 -0
  52. {most_queue-2.4 → most_queue-2.5}/LICENSE +0 -0
  53. {most_queue-2.4 → most_queue-2.5}/README.md +0 -0
  54. {most_queue-2.4 → most_queue-2.5}/assets/3.gif +0 -0
  55. {most_queue-2.4 → most_queue-2.5}/deploy.txt +0 -0
  56. {most_queue-2.4 → most_queue-2.5}/googleb31d3dccb40f969f.html +0 -0
  57. {most_queue-2.4 → most_queue-2.5}/most_queue/__init__.py +0 -0
  58. {most_queue-2.4 → most_queue-2.5}/most_queue/io/__init__.py +0 -0
  59. {most_queue-2.4 → most_queue-2.5}/most_queue/misc/approx_cdf_make.py +0 -0
  60. {most_queue-2.4 → most_queue-2.5}/most_queue/misc/calc_v_pls.py +0 -0
  61. {most_queue-2.4 → most_queue-2.5}/most_queue/misc/compare_fj_calc.py +0 -0
  62. {most_queue-2.4 → most_queue-2.5}/most_queue/misc/flow_sum.py +0 -0
  63. {most_queue-2.4 → most_queue-2.5}/most_queue/misc/run_mgn_with_h2_delay_cold_warm.py +0 -0
  64. {most_queue-2.4 → most_queue-2.5}/most_queue/misc/tests/test_network_opt_approx.py +0 -0
  65. {most_queue-2.4 → most_queue-2.5}/most_queue/misc/tests/test_network_opt_plus.py +0 -0
  66. {most_queue-2.4 → most_queue-2.5}/most_queue/random/__init__.py +0 -0
  67. {most_queue-2.4 → most_queue-2.5}/most_queue/random/distributions.py +0 -0
  68. {most_queue-2.4 → most_queue-2.5}/most_queue/random/distributions.yaml +0 -0
  69. {most_queue-2.4 → most_queue-2.5}/most_queue/random/utils/base.py +0 -0
  70. {most_queue-2.4 → most_queue-2.5}/most_queue/random/utils/create.py +0 -0
  71. {most_queue-2.4 → most_queue-2.5}/most_queue/random/utils/fit.py +0 -0
  72. {most_queue-2.4 → most_queue-2.5}/most_queue/random/utils/load.py +0 -0
  73. {most_queue-2.4 → most_queue-2.5}/most_queue/random/utils/params.py +0 -0
  74. {most_queue-2.4 → most_queue-2.5}/most_queue/sim/__init__.py +0 -0
  75. {most_queue-2.4 → most_queue-2.5}/most_queue/sim/base.py +0 -0
  76. {most_queue-2.4 → most_queue-2.5}/most_queue/sim/batch.py +0 -0
  77. {most_queue-2.4 → most_queue-2.5}/most_queue/sim/finite_source.py +0 -0
  78. {most_queue-2.4 → most_queue-2.5}/most_queue/sim/flow_sum.py +0 -0
  79. {most_queue-2.4 → most_queue-2.5}/most_queue/sim/fork_join.py +0 -0
  80. {most_queue-2.4 → most_queue-2.5}/most_queue/sim/fork_join_delta.py +0 -0
  81. {most_queue-2.4 → most_queue-2.5}/most_queue/sim/impatient.py +0 -0
  82. {most_queue-2.4 → most_queue-2.5}/most_queue/sim/negative.py +0 -0
  83. {most_queue-2.4 → most_queue-2.5}/most_queue/sim/networks/__init__.py +0 -0
  84. {most_queue-2.4 → most_queue-2.5}/most_queue/sim/networks/base_network_sim.py +0 -0
  85. {most_queue-2.4 → most_queue-2.5}/most_queue/sim/networks/network.py +0 -0
  86. {most_queue-2.4 → most_queue-2.5}/most_queue/sim/networks/priority_network.py +0 -0
  87. {most_queue-2.4 → most_queue-2.5}/most_queue/sim/priority.py +0 -0
  88. {most_queue-2.4 → most_queue-2.5}/most_queue/sim/utils/__init__.py +0 -0
  89. {most_queue-2.4 → most_queue-2.5}/most_queue/sim/utils/phase.py +0 -0
  90. {most_queue-2.4 → most_queue-2.5}/most_queue/sim/utils/qs_queue.py +0 -0
  91. {most_queue-2.4 → most_queue-2.5}/most_queue/sim/utils/servers.py +0 -0
  92. {most_queue-2.4 → most_queue-2.5}/most_queue/sim/utils/stats_update.py +0 -0
  93. {most_queue-2.4 → most_queue-2.5}/most_queue/sim/utils/tasks.py +0 -0
  94. {most_queue-2.4 → most_queue-2.5}/most_queue/sim/vacations.py +0 -0
  95. {most_queue-2.4 → most_queue-2.5}/most_queue/structs.py +0 -0
  96. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/__init__.py +0 -0
  97. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/base_queue.py +0 -0
  98. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/batch/__init__.py +0 -0
  99. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/batch/mm1.py +0 -0
  100. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/calc_params.py +0 -0
  101. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/closed/__init__.py +0 -0
  102. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/closed/engset.py +0 -0
  103. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/fifo/__init__.py +0 -0
  104. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/fifo/ek_d_n.py +0 -0
  105. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/fifo/gi_m_1.py +0 -0
  106. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/fifo/gi_m_n.py +0 -0
  107. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/fifo/m_d_n.py +0 -0
  108. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/fifo/mg1.py +0 -0
  109. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/fifo/mgn_takahasi.py +0 -0
  110. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/fifo/mmnr.py +0 -0
  111. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/fork_join/__init__.py +0 -0
  112. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/fork_join/m_m_n.py +0 -0
  113. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/fork_join/split_join.py +0 -0
  114. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/impatience/__init__.py +0 -0
  115. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/impatience/mm1.py +0 -0
  116. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/negative/mg1_disasters.py +0 -0
  117. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/negative/mg1_rcs.py +0 -0
  118. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/negative/mgn_disaster.py +0 -0
  119. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/negative/mgn_rcs.py +0 -0
  120. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/negative/structs.py +0 -0
  121. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/networks/__init__.py +0 -0
  122. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/networks/base_network_calc.py +0 -0
  123. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/networks/network_viewer.py +0 -0
  124. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/networks/open_network.py +0 -0
  125. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/networks/open_network_prty.py +0 -0
  126. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/networks/opt/__init__.py +0 -0
  127. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/networks/opt/transition.py +0 -0
  128. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/networks/opt/transition_approx.py +0 -0
  129. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/networks/opt/transition_plus.py +0 -0
  130. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/priority/__init__.py +0 -0
  131. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/priority/mgn_invar_approx.py +0 -0
  132. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/priority/non_preemptive/__init__.py +0 -0
  133. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/priority/non_preemptive/mg1.py +0 -0
  134. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/priority/preemptive/__init__.py +0 -0
  135. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/priority/preemptive/m_ph_n_busy_approx.py +0 -0
  136. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/priority/preemptive/mg1.py +0 -0
  137. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/priority/preemptive/mm2_3cls_busy_approx.py +0 -0
  138. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/priority/preemptive/mmn_2cls_pr_busy_approx.py +0 -0
  139. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/r_example.gexf +0 -0
  140. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/utils/__init__.py +0 -0
  141. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/utils/binom_probs.py +0 -0
  142. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/utils/busy_periods.py +0 -0
  143. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/utils/conditional.py +0 -0
  144. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/utils/conv.py +0 -0
  145. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/utils/diff5dots.py +0 -0
  146. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/utils/flow_sum.py +0 -0
  147. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/utils/max_dist.py +0 -0
  148. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/utils/passage_time.py +0 -0
  149. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/utils/q_poisson_arrival_calc.py +0 -0
  150. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/utils/residual.py +0 -0
  151. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/utils/student_stat.py +0 -0
  152. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/utils/transforms.py +0 -0
  153. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/utils/utilization_approx.py +0 -0
  154. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/vacations/__init__.py +0 -0
  155. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/vacations/m_h2_h2warm.py +0 -0
  156. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/vacations/mg1_warm_calc.py +0 -0
  157. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/vacations/mgn_with_h2_delay_cold_warm.py +0 -0
  158. {most_queue-2.4 → most_queue-2.5}/most_queue/theory/vacations/mmn_with_h2_cold_and_h2_warmup.py +0 -0
  159. {most_queue-2.4 → most_queue-2.5}/requirements.txt +0 -0
  160. {most_queue-2.4 → most_queue-2.5}/tests/Dockerfile +0 -0
  161. {most_queue-2.4 → most_queue-2.5}/tests/__init__.py +0 -0
  162. {most_queue-2.4 → most_queue-2.5}/tests/default_params.yaml +0 -0
  163. {most_queue-2.4 → most_queue-2.5}/tests/run.sh +0 -0
  164. {most_queue-2.4 → most_queue-2.5}/tests/test_ek_d_n.py +0 -0
  165. {most_queue-2.4 → most_queue-2.5}/tests/test_m_d_n_calc.py +0 -0
  166. {most_queue-2.4 → most_queue-2.5}/tests/test_m_ph_n_prty.py +0 -0
  167. {most_queue-2.4 → most_queue-2.5}/tests/test_network_opt.py +0 -0
  168. {most_queue-2.4 → most_queue-2.5}/tests/units/test_h2_params_cv.py +0 -0
  169. {most_queue-2.4 → most_queue-2.5}/tests/units/test_queue_types.py +0 -0
  170. {most_queue-2.4 → most_queue-2.5}/tests/units/test_tt_up_probs.py +0 -0
  171. {most_queue-2.4 → most_queue-2.5}/tests/units/test_v1_on_channels.py +0 -0
  172. {most_queue-2.4 → most_queue-2.5}/tests/units/test_v1_utlization_approx.py +0 -0
  173. {most_queue-2.4 → most_queue-2.5}/tests/units/test_weibull.py +0 -0
  174. {most_queue-2.4 → most_queue-2.5}/works/__init__.py +0 -0
  175. {most_queue-2.4 → most_queue-2.5}/works/negative_queues/__init__.py +0 -0
  176. {most_queue-2.4 → most_queue-2.5}/works/negative_queues/base_parameters.yaml +0 -0
  177. {most_queue-2.4 → most_queue-2.5}/works/vacations/__init__.py +0 -0
  178. {most_queue-2.4 → most_queue-2.5}/works/vacations/base_parameters.yaml +0 -0
  179. {most_queue-2.4 → most_queue-2.5}/works/vacations/channels.py +0 -0
  180. {most_queue-2.4 → most_queue-2.5}/works/vacations/cooling.py +0 -0
  181. {most_queue-2.4 → most_queue-2.5}/works/vacations/cooling_delay.py +0 -0
  182. {most_queue-2.4 → most_queue-2.5}/works/vacations/main.py +0 -0
  183. {most_queue-2.4 → most_queue-2.5}/works/vacations/service.py +0 -0
  184. {most_queue-2.4 → most_queue-2.5}/works/vacations/utilization.py +0 -0
  185. {most_queue-2.4 → most_queue-2.5}/works/vacations/utils.py +0 -0
  186. {most_queue-2.4 → most_queue-2.5}/works/vacations/warmup.py +0 -0
@@ -162,4 +162,11 @@ cython_debug/
162
162
 
163
163
  .vscode
164
164
 
165
- works/negative_queues/results/*
165
+ works/negative_queues/results/*
166
+
167
+ # ignore all png files in tests/units folder
168
+ tests/units/*.png
169
+
170
+ # ignore all files in works/vacations/results
171
+ works/vacations/results/*
172
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: most_queue
3
- Version: 2.4
3
+ Version: 2.5
4
4
  Summary: Software package for calculation and simulation of queuing systems
5
5
  Project-URL: Homepage, https://github.com/xabarov/most-queue
6
6
  Author-email: Xabarov Roman <xabarov1985@gmail.com>
@@ -0,0 +1,101 @@
1
+ """
2
+ Plotting utilities for simulation results.
3
+ """
4
+
5
+ from enum import Enum
6
+
7
+ import matplotlib.pyplot as plt
8
+ from matplotlib.axes import Axes
9
+
10
+
11
+ class DependsType(Enum):
12
+ """
13
+ Enum to specify the type of dependency for plotting.
14
+ """
15
+
16
+ NONE = 0
17
+ UTILIZATION_FACTOR = 1
18
+ CHANNELS_NUMBER = 2
19
+ COEFFICIENT_OF_VARIATION = 3
20
+
21
+
22
+ class Plotter:
23
+ """
24
+ A class for plotting simulation results.
25
+ """
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)
64
+ else:
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)
@@ -9,10 +9,9 @@ from colorama import Fore, Style, init
9
9
  init()
10
10
 
11
11
 
12
- def times_print(
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
- sim_moments (list): List of simulated moments.
24
- calc_moments (list): List of calculated moments.
25
- is_w (bool, optional): If True, prints waiting time moments.
26
- Otherwise, prints sojourn time moments. Defaults to True.
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
- if is_w:
32
- spec = "waiting"
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 times_print_with_two_numerical(
73
- sim_moments,
74
- calc_moments1,
75
- calc_moments2,
76
- is_w=True,
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
- sim_moments (list): List of simulated moments.
84
- calc_moments1 (list): List of calculated moments for the first approximation.
85
- calc_moments2 (list): List of calculated moments for the second approximation.
86
- is_w (bool, optional): If True, prints waiting time moments.
87
- Otherwise, prints sojourn time moments. Defaults to True.
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
- if is_w:
92
- spec = "waiting"
93
- else:
94
- spec = "soujorn"
95
- header = f"Initial moments of {spec} time in the system"
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 times_print_no_compare(wait_times=None, sojourn_times=None):
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 wait and sojourn times.
146
- :param wait_times: Wait times
147
- :param sojourn_times: Sojourn times
148
- :return: None
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
- if sojourn_times is None and wait_times is None:
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
- if sojourn_times is not None and wait_times is not None:
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
- num_col, w_col, v_col = "#", "w", "v"
159
- print(f"{num_col:^15s}|{w_col:^15s}|{v_col:^15s}")
160
- print("-" * 45)
161
- if isinstance(wait_times, list):
162
- for j in range(min(len(wait_times), len(sojourn_times))):
163
- w_mom = wait_times[j].real if isinstance(wait_times[j], complex) else wait_times[j]
164
- v_mom = sojourn_times[j].real if isinstance(sojourn_times[j], complex) else sojourn_times[j]
165
- print(
166
- Fore.CYAN
167
- + f"{j + 1:^15d}|"
168
- + Fore.YELLOW
169
- + f"{w_mom:^15.5g}"
170
- + Fore.CYAN
171
- + "|"
172
- + Fore.YELLOW
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
- print(Style.RESET_ALL)
214
+ """
190
215
 
191
- else:
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
- print(header)
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
- print(Fore.CYAN + f"{1:^15d}|" + Fore.YELLOW + f"{mom:^15.5g}" + Fore.CYAN)
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
- print(Style.RESET_ALL)
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 times_print
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
- times_print(v_sim, v_num, is_w=False)
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 probs_print, times_print
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
- times_print(sim_moments=stat["w_sim"], calc_moments=stat["w_tt"])
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"):
@@ -42,7 +42,7 @@ max-line-length = 120
42
42
 
43
43
  [project]
44
44
  name = "most_queue"
45
- version = "2.04"
45
+ version = "2.05"
46
46
  authors = [{ name = "Xabarov Roman", email = "xabarov1985@gmail.com" }]
47
47
  description = "Software package for calculation and simulation of queuing systems"
48
48
  readme = "README.md"
@@ -2,7 +2,7 @@ from setuptools import find_packages, setup
2
2
 
3
3
  setup(
4
4
  name="most-queue",
5
- version="2.04",
5
+ version="2.05",
6
6
  description="Software package for calculation and simulation of queuing systems",
7
7
  author="Xabarov Roman",
8
8
  author_email="xabarov1985@gmail.com",
@@ -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 probs_print, times_print
10
+ from most_queue.io.tables import print_waiting_times, probs_print
11
11
  from most_queue.sim.base import QsSim
12
12
  from most_queue.theory.fifo.m_d_n import MDn
13
13
  from most_queue.theory.fifo.mmnr import MMnrCalc
@@ -58,7 +58,7 @@ def test_sim_mmnr():
58
58
  mmnr.set_servers(mu=mu)
59
59
  calc_results = mmnr.run()
60
60
 
61
- times_print(sim_results.w, calc_results.w)
61
+ print_waiting_times(sim_results.w, calc_results.w)
62
62
 
63
63
  print(f"Simulation duration: {sim_results.duration:.5f} sec")
64
64
  print(f"Calculation duration: {calc_results.duration:.5f} sec")
@@ -11,7 +11,7 @@ import os
11
11
  import numpy as np
12
12
  import yaml
13
13
 
14
- from most_queue.io.tables import times_print
14
+ from most_queue.io.tables import print_sojourn_times
15
15
  from most_queue.sim.batch import QueueingSystemBatchSim
16
16
  from most_queue.theory.batch.mm1 import BatchMM1
17
17
 
@@ -73,7 +73,7 @@ def test_batch_mm1():
73
73
  print(f"Simulation duration: {sim_results.duration:.5f} sec")
74
74
  print(f"Calculation duration: {calc_results.duration:.5f} sec")
75
75
 
76
- times_print(sim_results.v[0], calc_results.v[0], False)
76
+ print_sojourn_times(sim_results.v[0], calc_results.v[0])
77
77
 
78
78
  assert np.allclose(sim_results.v[0], calc_results.v[0], atol=MOMENTS_ATOL, rtol=MOMENTS_RTOL), ERROR_MSG
79
79
 
@@ -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 probs_print, times_print
10
+ from most_queue.io.tables import print_sojourn_times, print_waiting_times, probs_print
11
11
  from most_queue.sim.finite_source import QueueingFiniteSourceSim
12
12
  from most_queue.theory.closed.engset import Engset
13
13
 
@@ -66,8 +66,8 @@ def test_engset():
66
66
 
67
67
  assert np.allclose(sim_results.p[:10], calc_results.p[:10], atol=PROBS_ATOL, rtol=PROBS_RTOL), ERROR_MSG
68
68
 
69
- times_print(sim_results.w, calc_results.w, is_w=True)
70
- times_print(sim_results.v, calc_results.v, is_w=False)
69
+ print_waiting_times(sim_results.w, calc_results.w)
70
+ print_sojourn_times(sim_results.v, calc_results.v)
71
71
 
72
72
  assert np.allclose(sim_results.w, calc_results.w, rtol=MOMENTS_RTOL, atol=MOMENTS_ATOL), ERROR_MSG
73
73
  assert np.allclose(sim_results.v, calc_results.v, rtol=MOMENTS_RTOL, atol=MOMENTS_ATOL), ERROR_MSG
@@ -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 times_print
10
+ from most_queue.io.tables import print_sojourn_times
11
11
  from most_queue.random.distributions import GammaDistribution, GammaParams
12
12
  from most_queue.sim.fork_join import ForkJoinSim
13
13
  from most_queue.structs import QueueResults
@@ -76,7 +76,7 @@ def print_results_sj(cv: float, sim_results: QueueResults, calc_results: QueueRe
76
76
  print(f"Utilization coefficient: {calc_results.utilization:.3f}")
77
77
  print(f"Simulation duration: {sim_results.duration:.5f} sec")
78
78
  print(f"Calculation duration: {calc_results.duration:.5f} sec")
79
- times_print(sim_results.v, calc_results.v, False)
79
+ print_sojourn_times(sim_results.v, calc_results.v)
80
80
 
81
81
 
82
82
  def run_sim_fj(k: int, mu: float):
@@ -8,7 +8,7 @@ import os
8
8
  import numpy as np
9
9
  import yaml
10
10
 
11
- from most_queue.io.tables import probs_print, times_print
11
+ from most_queue.io.tables import print_sojourn_times, print_waiting_times, probs_print
12
12
  from most_queue.random.distributions import GammaDistribution
13
13
  from most_queue.sim.base import QsSim
14
14
  from most_queue.theory.fifo.gi_m_1 import GiM1
@@ -78,8 +78,8 @@ def test_gi_m_1():
78
78
  print(f"Simulation duration: {sim_results.duration:.5f} sec")
79
79
  print(f"Calculation duration: {calc_results.duration:.5f} sec")
80
80
 
81
- times_print(sim_results.w, calc_results.w, True)
82
- times_print(sim_results.v, calc_results.v, False)
81
+ print_waiting_times(sim_results.w, calc_results.w)
82
+ print_sojourn_times(sim_results.v, calc_results.v)
83
83
  probs_print(sim_results.p, calc_results.p, size=10)
84
84
 
85
85
  assert np.allclose(sim_results.v, calc_results.v, rtol=MOMENTS_RTOL, atol=MOMENTS_ATOL), ERROR_MSG