most-queue 1.50__tar.gz → 1.52__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.

Potentially problematic release.


This version of most-queue might be problematic. Click here for more details.

Files changed (154) hide show
  1. most_queue-1.52/Gamma vs H2.png +0 -0
  2. most_queue-1.52/PKG-INFO +308 -0
  3. most_queue-1.52/README.md +268 -0
  4. most_queue-1.52/assets/queue_long.png +0 -0
  5. most_queue-1.52/docs/Makefile +20 -0
  6. most_queue-1.52/docs/make.bat +35 -0
  7. most_queue-1.52/docs/source/conf.py +35 -0
  8. most_queue-1.52/docs/source/index.rst +19 -0
  9. most_queue-1.52/docs/source/modules.rst +7 -0
  10. most_queue-1.52/docs/source/most_queue.rst +30 -0
  11. most_queue-1.52/docs/source/most_queue.sim.rst +71 -0
  12. most_queue-1.52/docs/source/most_queue.theory.rst +182 -0
  13. most_queue-1.52/googleb31d3dccb40f969f.html +1 -0
  14. most_queue-1.52/most_queue/general/approx_cdf_make.py +83 -0
  15. most_queue-1.52/most_queue/general/conv.py +51 -0
  16. most_queue-1.52/most_queue/general/distribution_params.py +71 -0
  17. most_queue-1.52/most_queue/general/interfaces.py +62 -0
  18. most_queue-1.52/most_queue/general/tables.py +236 -0
  19. {most_queue-1.50/most_queue/general_utils → most_queue-1.52/most_queue/general}/vacations_paper_utils.py +29 -13
  20. {most_queue-1.50 → most_queue-1.52}/most_queue/misc/compare_fj_calc.py +1 -1
  21. {most_queue-1.50 → most_queue-1.52}/most_queue/misc/flow_sum.py +17 -10
  22. most_queue-1.52/most_queue/rand_distribution.py +1089 -0
  23. {most_queue-1.50 → most_queue-1.52}/most_queue/sim/batch_sim.py +4 -4
  24. {most_queue-1.50 → most_queue-1.52}/most_queue/sim/fj_delta_sim.py +36 -37
  25. {most_queue-1.50 → most_queue-1.52}/most_queue/sim/fj_sim.py +38 -20
  26. {most_queue-1.50 → most_queue-1.52}/most_queue/sim/flow_sum_sim.py +22 -17
  27. {most_queue-1.50 → most_queue-1.52}/most_queue/sim/impatient_queue_sim.py +11 -32
  28. {most_queue-1.50 → most_queue-1.52}/most_queue/sim/priority_network.py +7 -7
  29. {most_queue-1.50 → most_queue-1.52}/most_queue/sim/priority_queue_sim.py +0 -5
  30. {most_queue-1.50 → most_queue-1.52}/most_queue/sim/qs_sim.py +17 -42
  31. {most_queue-1.50 → most_queue-1.52}/most_queue/sim/utils/distribution_utils.py +28 -28
  32. {most_queue-1.50 → most_queue-1.52}/most_queue/sim/utils/phase.py +3 -3
  33. most_queue-1.50/most_queue/theory/__init__.py → most_queue-1.52/most_queue/sim/utils/qs.py +0 -0
  34. {most_queue-1.50 → most_queue-1.52}/most_queue/sim/utils/servers.py +27 -9
  35. {most_queue-1.50/most_queue/theory/utils → most_queue-1.52/most_queue/theory}/__init__.py +0 -0
  36. {most_queue-1.50/most_queue/theory → most_queue-1.52/most_queue/theory/batch}/batch_mm1.py +16 -18
  37. most_queue-1.52/most_queue/theory/closed/__init__.py +0 -0
  38. most_queue-1.52/most_queue/theory/closed/engset_model.py +141 -0
  39. most_queue-1.52/most_queue/theory/fifo/__init__.py +0 -0
  40. {most_queue-1.50/most_queue/theory → most_queue-1.52/most_queue/theory/fifo}/ek_d_n_calc.py +5 -5
  41. most_queue-1.52/most_queue/theory/fifo/gi_m_1_calc.py +133 -0
  42. most_queue-1.52/most_queue/theory/fifo/gi_m_n_calc.py +190 -0
  43. {most_queue-1.50/most_queue/theory → most_queue-1.52/most_queue/theory/fifo}/m_d_n_calc.py +67 -59
  44. most_queue-1.52/most_queue/theory/fifo/mg1_calc.py +91 -0
  45. most_queue-1.52/most_queue/theory/fifo/mgn_tt.py +398 -0
  46. most_queue-1.52/most_queue/theory/fifo/mmnr_calc.py +116 -0
  47. most_queue-1.52/most_queue/theory/fork_join/__init__.py +0 -0
  48. most_queue-1.52/most_queue/theory/fork_join/fj_calc.py +254 -0
  49. most_queue-1.52/most_queue/theory/fork_join/sj_calc.py +284 -0
  50. most_queue-1.52/most_queue/theory/impatience/__init__.py +0 -0
  51. most_queue-1.52/most_queue/theory/impatience/impatience_mm1.py +115 -0
  52. most_queue-1.52/most_queue/theory/networks/__init__.py +0 -0
  53. most_queue-1.52/most_queue/theory/networks/open_network.py +152 -0
  54. most_queue-1.52/most_queue/theory/priority/__init__.py +0 -0
  55. {most_queue-1.50/most_queue/theory → most_queue-1.52/most_queue/theory/priority}/m_ph_n_prty.py +236 -221
  56. {most_queue-1.50/most_queue/theory → most_queue-1.52/most_queue/theory/priority}/mmn3_pnz_cox_approx.py +12 -24
  57. {most_queue-1.50/most_queue/theory → most_queue-1.52/most_queue/theory/priority}/mmn_prty_pnz_approx.py +30 -22
  58. {most_queue-1.50/most_queue/theory → most_queue-1.52/most_queue/theory/priority}/priority_calc.py +49 -32
  59. most_queue-1.52/most_queue/theory/utils/__init__.py +0 -0
  60. {most_queue-1.50 → most_queue-1.52}/most_queue/theory/utils/flow_sum.py +15 -15
  61. most_queue-1.52/most_queue/theory/utils/passage_time.py +585 -0
  62. {most_queue-1.50 → most_queue-1.52}/most_queue/theory/utils/q_poisson_arrival_calc.py +2 -2
  63. most_queue-1.52/most_queue/theory/utils/transforms.py +8 -0
  64. {most_queue-1.50 → most_queue-1.52}/most_queue/theory/utils/weibull.py +49 -7
  65. most_queue-1.52/most_queue/theory/vacations/__init__.py +0 -0
  66. {most_queue-1.50/most_queue/theory → most_queue-1.52/most_queue/theory/vacations}/m_h2_h2warm.py +175 -183
  67. most_queue-1.52/most_queue/theory/vacations/mg1_warm_calc.py +53 -0
  68. {most_queue-1.50/most_queue/theory → most_queue-1.52/most_queue/theory/vacations}/mgn_with_h2_delay_cold_warm.py +251 -304
  69. {most_queue-1.50/most_queue/theory → most_queue-1.52/most_queue/theory/vacations}/mmn_with_h2_cold_and_h2_warmup.py +9 -21
  70. {most_queue-1.50 → most_queue-1.52}/pyproject.toml +1 -1
  71. {most_queue-1.50 → most_queue-1.52}/setup.py +1 -1
  72. most_queue-1.52/tests/__init__.py +0 -0
  73. {most_queue-1.50 → most_queue-1.52}/tests/test_batch.py +11 -4
  74. {most_queue-1.50 → most_queue-1.52}/tests/test_ek_d_n.py +19 -14
  75. most_queue-1.52/tests/test_engset.py +40 -0
  76. most_queue-1.52/tests/test_fj_delta.py +90 -0
  77. most_queue-1.52/tests/test_fj_im.py +192 -0
  78. most_queue-1.52/tests/test_gi_m_1_calc.py +98 -0
  79. most_queue-1.52/tests/test_gi_m_n_calc.py +98 -0
  80. most_queue-1.52/tests/test_impatience.py +46 -0
  81. most_queue-1.52/tests/test_m_d_n_calc.py +52 -0
  82. most_queue-1.52/tests/test_m_h2_h2warm.py +85 -0
  83. most_queue-1.52/tests/test_m_ph_n_prty.py +137 -0
  84. {most_queue-1.50 → most_queue-1.52}/tests/test_mg1_calc.py +32 -23
  85. most_queue-1.52/tests/test_mgn_tt.py +92 -0
  86. {most_queue-1.50 → most_queue-1.52}/tests/test_mgn_with_h2_delay_cold_warm.py +131 -71
  87. {most_queue-1.50 → most_queue-1.52}/tests/test_mmn3_pnz_cox_approx.py +7 -5
  88. {most_queue-1.50 → most_queue-1.52}/tests/test_mmn_h2cold_h2warm.py +5 -11
  89. {most_queue-1.50 → most_queue-1.52}/tests/test_mmn_prty_pnz_approx.py +1 -3
  90. most_queue-1.52/tests/test_network_im_prty.py +118 -0
  91. {most_queue-1.50 → most_queue-1.52}/tests/test_qs_sim_prty.py +7 -6
  92. {most_queue-1.50 → most_queue-1.52}/tests/test_qs_sim_test.py +9 -6
  93. {most_queue-1.50 → most_queue-1.52}/tests/test_queue_types.py +2 -2
  94. {most_queue-1.50 → most_queue-1.52}/tutorials/m_h2_h2warm.ipynb +8 -8
  95. {most_queue-1.50 → most_queue-1.52}/tutorials/mgn_takahasi_takami.ipynb +1 -1
  96. most_queue-1.50/tutorials/priority queue.ipynb → most_queue-1.52/tutorials/priority_queue.ipynb +5 -5
  97. {most_queue-1.50 → most_queue-1.52}/tutorials/queue_sim.ipynb +6 -5
  98. most_queue-1.50/PKG-INFO +0 -250
  99. most_queue-1.50/README.md +0 -210
  100. most_queue-1.50/assets/IMPATIENCE.jpg +0 -0
  101. most_queue-1.50/assets/queue.jpg +0 -0
  102. most_queue-1.50/assets/queue2.jpg +0 -0
  103. most_queue-1.50/assets/queue3.jpg +0 -0
  104. most_queue-1.50/assets/queue4.jpg +0 -0
  105. most_queue-1.50/assets/queue5.jpg +0 -0
  106. most_queue-1.50/assets/queue6.jpg +0 -0
  107. most_queue-1.50/most_queue/general_utils/approx_cdf_make.py +0 -79
  108. most_queue-1.50/most_queue/general_utils/conv.py +0 -24
  109. most_queue-1.50/most_queue/general_utils/tables.py +0 -119
  110. most_queue-1.50/most_queue/rand_distribution.py +0 -1031
  111. most_queue-1.50/most_queue/theory/engset_model.py +0 -127
  112. most_queue-1.50/most_queue/theory/fj_calc.py +0 -372
  113. most_queue-1.50/most_queue/theory/gi_m_1_calc.py +0 -89
  114. most_queue-1.50/most_queue/theory/gi_m_n_calc.py +0 -147
  115. most_queue-1.50/most_queue/theory/impatience_calc.py +0 -103
  116. most_queue-1.50/most_queue/theory/mg1_calc.py +0 -79
  117. most_queue-1.50/most_queue/theory/mg1_warm_calc.py +0 -29
  118. most_queue-1.50/most_queue/theory/mgn_tt.py +0 -450
  119. most_queue-1.50/most_queue/theory/mmnr_calc.py +0 -76
  120. most_queue-1.50/most_queue/theory/network_calc.py +0 -190
  121. most_queue-1.50/most_queue/theory/utils/passage_time.py +0 -1033
  122. most_queue-1.50/tests/test_engset.py +0 -52
  123. most_queue-1.50/tests/test_fj_delta.py +0 -84
  124. most_queue-1.50/tests/test_fj_im.py +0 -105
  125. most_queue-1.50/tests/test_gi_m_1_calc.py +0 -116
  126. most_queue-1.50/tests/test_gi_m_n_calc.py +0 -117
  127. most_queue-1.50/tests/test_impatience.py +0 -35
  128. most_queue-1.50/tests/test_m_d_n_calc.py +0 -56
  129. most_queue-1.50/tests/test_m_h2_h2warm.py +0 -78
  130. most_queue-1.50/tests/test_m_ph_n_prty.py +0 -153
  131. most_queue-1.50/tests/test_mgn_tt.py +0 -91
  132. most_queue-1.50/tests/test_network_im_prty.py +0 -136
  133. {most_queue-1.50 → most_queue-1.52}/.gitignore +0 -0
  134. {most_queue-1.50 → most_queue-1.52}/LICENSE +0 -0
  135. {most_queue-1.50 → most_queue-1.52}/deploy.txt +0 -0
  136. {most_queue-1.50 → most_queue-1.52}/most_queue/__init__.py +0 -0
  137. {most_queue-1.50/most_queue/general_utils → most_queue-1.52/most_queue/general}/__init__.py +0 -0
  138. {most_queue-1.50 → most_queue-1.52}/most_queue/misc/test_weibull.py +0 -0
  139. {most_queue-1.50 → most_queue-1.52}/most_queue/sim/__init__.py +0 -0
  140. {most_queue-1.50 → most_queue-1.52}/most_queue/sim/queue_finite_source_sim.py +0 -0
  141. {most_queue-1.50 → most_queue-1.52}/most_queue/sim/utils/__init__.py +0 -0
  142. {most_queue-1.50 → most_queue-1.52}/most_queue/sim/utils/exceptions.py +0 -0
  143. {most_queue-1.50 → most_queue-1.52}/most_queue/sim/utils/qs_queue.py +0 -0
  144. {most_queue-1.50 → most_queue-1.52}/most_queue/sim/utils/stats_update.py +0 -0
  145. {most_queue-1.50 → most_queue-1.52}/most_queue/sim/utils/tasks.py +0 -0
  146. {most_queue-1.50/tests → most_queue-1.52/most_queue/theory/batch}/__init__.py +0 -0
  147. {most_queue-1.50/most_queue/theory → most_queue-1.52/most_queue/theory/networks}/network_viewer.py +0 -0
  148. {most_queue-1.50 → most_queue-1.52}/most_queue/theory/r_example.gexf +0 -0
  149. {most_queue-1.50 → most_queue-1.52}/most_queue/theory/utils/binom_probs.py +0 -0
  150. {most_queue-1.50 → most_queue-1.52}/most_queue/theory/utils/diff5dots.py +0 -0
  151. {most_queue-1.50 → most_queue-1.52}/most_queue/theory/utils/student_stat.py +0 -0
  152. {most_queue-1.50 → most_queue-1.52}/requirements.txt +0 -0
  153. {most_queue-1.50 → most_queue-1.52}/tests/n_test/ro_0.700.json +0 -0
  154. {most_queue-1.50 → most_queue-1.52}/tests/ro_test/n_3.json +0 -0
Binary file
@@ -0,0 +1,308 @@
1
+ Metadata-Version: 2.4
2
+ Name: most_queue
3
+ Version: 1.52
4
+ Summary: Software package for calculation and simulation of queuing systems
5
+ Project-URL: Homepage, https://github.com/xabarov/most-queue
6
+ Author-email: Xabarov Roman <xabarov1985@gmail.com>
7
+ License: Copyright (c) 2018 The Python Packaging Authority
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
26
+ License-File: LICENSE
27
+ Classifier: License :: OSI Approved :: MIT License
28
+ Classifier: Operating System :: OS Independent
29
+ Classifier: Programming Language :: Python :: 3
30
+ Requires-Python: >=3.9
31
+ Requires-Dist: colorama
32
+ Requires-Dist: graphviz
33
+ Requires-Dist: matplotlib
34
+ Requires-Dist: networkx
35
+ Requires-Dist: numpy
36
+ Requires-Dist: pandas
37
+ Requires-Dist: scipy==1.13.0
38
+ Requires-Dist: tqdm
39
+ Description-Content-Type: text/markdown
40
+
41
+ # Queueing Systems: Simulation & Numerical Methods
42
+
43
+ ![Queue](assets/queue_long.png)
44
+
45
+ A Python package for simulating and analyzing queueing systems (QS) and networks.
46
+
47
+ ![GitHub commit activity](https://img.shields.io/github/commit-activity/m/xabarov/most-queue)
48
+
49
+
50
+ ## About
51
+ This repository focuses on solving steady-state problems in queueing theory.
52
+
53
+ Key Features:
54
+ - Simulate various types of queueing systems and networks.
55
+ - Numerical methods for solving queueing theory problems.
56
+ - Analyze system performance metrics such as waiting times, soujourn times, load factor and etc.
57
+
58
+
59
+ ## Use Cases
60
+ - Modeling cloud computing infrastructure.
61
+ - Designing efficient call centers.
62
+ - Optimizing transportation systems.
63
+ - Network traffic analysis.
64
+
65
+ ## Contributing
66
+ Contributions are welcome! If you find any issues or have suggestions, please open an [issue](https://github.com/xabarov/most-queue/issues). Your pull requests are also appreciated. You can write me at [xabarov1985@gmail.com](mailto:xabarov1985@gmail.com)
67
+
68
+ ## Roadmap
69
+ - Expand support for more queueing models.
70
+ - Implement advanced numerical solution methods.
71
+
72
+ ---
73
+
74
+ ## Installation
75
+ Install most-queue with pip
76
+ ```bash
77
+ pip install most-queue
78
+ ```
79
+
80
+ ### Description of the Project
81
+
82
+ Most_queue consists of two main parts:
83
+ - **most_queue.theory** contains programs that implement methods for calculating queuing theory models.
84
+ - **most_queue.sim** contains simulation programs.
85
+ ### Package most_queue.theory
86
+
87
+ Package consist of following submodules:
88
+
89
+ #### Batch
90
+ | # | Kendall Notations | Package Name | Description | Example | Tutorial |
91
+ |-----|-------------------|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|-------------------|
92
+ | 1. | M<sup>x</sup>/M/1 | batch.batch_mm1 | Solving for the of M<sup>x</sup>/M/1 QS with batch arrival | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_batch.py) | |
93
+
94
+ #### Closed
95
+ | # | Kendall Notations | Package Name | Description | Example | Tutorial |
96
+ |-----|-------------------|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|-------------------|
97
+ | 1. | M/M/1/N | closed.engset_model | Solving for the Engset model for M/M/1 with a finite number of sources. | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_engset.py) | |
98
+
99
+
100
+ #### Fork-Join
101
+
102
+ | # | Kendall Notations | Package Name | Description | Example | Tutorial |
103
+ |-----|-------------------|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|-------------------|
104
+ | 1. | M/M/c/Fork-Join | fork_join.fj_calc | Solving for Fork-Join queueing system | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_fj_im.py) | |
105
+
106
+
107
+ #### Priority Queueing Systems
108
+
109
+ | # | Kendall Notations | Package Name | Description | Example | Tutorial |
110
+ |-----|-------------------|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|-------------------|
111
+ | 1. | M/Ph/c/PR | priority.m_ph_n_prty | Numerical calculation of QS M/Ph/c with 2 classes and PR - priority. Based on the approximation of busy periods | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_m_ph_n_prty.py) | |
112
+ | 2. | M/M/c/PR | priority.mmn_prty_pnz_approx | Numerical calculation of QS M/M/c with 2 classes, PR - priority by the Takahashi-Takami numerical method based on the approximation of the busy period by the Cox distribution | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_mmn_prty_pnz_approx.py) | |
113
+ | 3. | M/M/c/PR | priority.mmn3_pnz_cox_approx | Numerical calculation of QS M/M/c with 3 classes, PR - priority by the Takahashi-Takami numerical method based on the approximation of busy period by the Cox distribution | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_mmn3_pnz_cox_approx.py) | |
114
+ | 4. | M/G/1 | priority.priority_calc | A set of functions for calculating QS with priorities (single-channel, multi-channel). The multichannel calculation is carried out by the method of relation | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_qs_sim_prty.py) |[link](https://github.com/xabarov/most-queue/blob/main/tutorials/priority_queue.ipynb) |
115
+
116
+ #### FIFO Queueing Systems
117
+ | # | Kendall Notations | Package Name | Description | Example | Tutorial |
118
+ |-----|-------------------|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|-------------------|
119
+ | 1. | Ek/D/c | fifo.ek_d_n_calc | Numerical calculation of a multi-channel system Ek/D/n | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_ek_d_n.py) | |
120
+ | 2. | GI/M/1 | fifo.gi_m_1_calc | Solving for QS GI/M/1 | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_gi_m_1_calc.py) | |
121
+ | 3. | GI/M/c | fifo.gi_m_n_calc | Solving for QS GI/M/c | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_gi_m_n_calc.py) | |
122
+ | 4. | M/D/c | fifo.m_d_n_calc | Solving for QS M/D/c | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_m_d_n_calc.py) | [link](https://github.com/xabarov/most-queue/blob/main/tutorials/queue_sim.ipynb) |
123
+ | 5. | M/G/1 | fifo.mg1_calc | Solving for QS M/G/1 | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_mg1_calc.py) | |
124
+ | 6. | M/H<SUB>2</SUB>/c | fifo.mgn_tt | Numerical calculation of QS M/H<SUB>2</SUB>/c by the Takahashi-Takami method with complex parameters when approximating the serving time by the H<SUB>2</SUB>-distribution | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_mgn_tt.py) | [link](https://github.com/xabarov/most-queue/blob/main/tutorials/mgn_takahasi_takami.ipynb) |
125
+ | 7. | M/M/c/r | fifo.mmnr_calc | Solving for QS M/M/c/r | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_qs_sim_test.py) | [link](https://github.com/xabarov/most-queue/blob/main/tutorials/queue_sim.ipynb) |
126
+
127
+
128
+ #### Networks
129
+
130
+ | # | Kendall Notations | Package Name | Description | Example | Tutorial |
131
+ |-----|-------------------|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|-------------------|
132
+ | 1. | General Network | network_calc | Numerical calculation of queuing network with priorities in nodes | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_network_im_prty.py) | |
133
+ | 2. | - | networks.network_viewer | Utility to view network structure | | |
134
+
135
+ #### Vacations
136
+ | # | Kendall Notations | Package Name | Description | Example | Tutorial |
137
+ |-----|-------------------|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|-------------------|
138
+ | 1. | M/H<SUB>2</SUB>/c | vacations.m_h2_h2warm | Numerical calculation of the M/H<SUB>2</SUB>/c system with H<SUB>2</SUB>-warming using the Takahasi-Takagi method. | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_m_h2_h2warm.py) | [link](https://github.com/xabarov/most-queue/blob/main/tutorials/m_h2_h2warm.ipynb)| |
139
+ | 2. | M/G/1 | vacations.mg1_warm_calc | Solving for QS M/G/1 with warm-up | | |
140
+ | 3. | M/Ph/c | vacations.mgn_with_h2_delay_cold_warm | Multichannel queuing system with H<SUB>2</SUB>-serving time, H<SUB>2</SUB>-warm-up, H<SUB>2</SUB>-cold delay and H<SUB>2</SUB>-cold (vacations). The system uses complex parameters, which allows you to calculate systems with arbitrary serving, warm-up, cold-delay and cold variation coefficients | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_mgn_with_h2_delay_cold_warm.py) | |
141
+ | 4. | M/M/c | vacations.mmn_with_h2_cold_h2_warmup | Multichannel queuing system with exp serving time, H<SUB>2</SUB>-warm-up and H<SUB>2</SUB>-cold (vacations). The system uses complex parameters, which allows to calculate systems with arbitrary warm-up and cold variation coefficients | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_mmn_h2cold_h2warm.py) | |
142
+
143
+ #### Impatience
144
+ | # | Kendall Notations | Package Name | Description | Example | Tutorial |
145
+ |-----|-------------------|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|-------------------|
146
+ | 1. | M/M/1/D | impatience.impatience_mm1 | Solving for M/M/1 with exponential impatience | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_impatience.py) | |
147
+
148
+ ### Package most_queue.sim
149
+
150
+ | # | Kendall Notations | Package Name | Description | Example | Tutorial |
151
+ |-----|-------------------|----------------------------|-------------------------------------------------------------------------------------------------|-------------------|-------------------|
152
+ | 1. | M<sup>x</sup>/M/c | batch_sim | Simulation of QS in a batch system | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_batch.py) | |
153
+ | 2. | M/G/c/Fork-Join | fj_delta_sim | Simulation of QS fork-join with a delay in the start of processing between channels | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_fj_delta.py) | |
154
+ | 3. | M/M/c | fj_sim | Simulation of QS with fork-join process | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_fj_im.py) | |
155
+ | 4. | - | flow_sum_sim | Simulation of flow summation | | |
156
+ | 5. | GI/G/c | impatient_queue_sim | Simulation of QS GI/G/m/n with impatience | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_impatience.py) | |
157
+ | 6. | QN | priority_network | Simulation of queuing network with priorities in nodes | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_network_im_prty.py) | |
158
+ | 7. | GI/G/c/n/Pri | priority_queue_sim | Simulation of QS GI/G/c/n with priorities | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_qs_sim_prty.py) | [link](https://github.com/xabarov/most-queue/blob/main/tutorials/priority_queue.ipynb) |
159
+ | 8. | GI/G/c/n | qs_sim | Simulation of QS GI/G/c/n | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_qs_sim_test.py) | [link](https://github.com/xabarov/most-queue/blob/main/tutorials/mgn_takahasi_takami.ipynb) |
160
+ | 9. | GI/G/c/n/N | queue_finite_source_sim | Simulation of QS GI/G/c/n with finite sources | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_engset.py) | |
161
+
162
+
163
+ ### Usage
164
+ - Look [here](https://github.com/xabarov/most-queue/tree/main/tests) for examples
165
+ - Look [here](https://github.com/xabarov/most-queue/tree/main/tutorials) for jupyter tutorials
166
+
167
+ ### Simple example: Calculate M/G/1 queueing system calculation with `most_queue` library. Run simulation and compare results with theory.
168
+
169
+ ```python
170
+ import numpy as np
171
+
172
+ from most_queue.general_utils.tables import probs_print, times_print
173
+ from most_queue.rand_distribution import H2Distribution
174
+ from most_queue.sim.qs_sim import QueueingSystemSimulator
175
+ from most_queue.theory.mg1_calc import MG1Calculation
176
+
177
+ l = 1 # input flow intensity
178
+ b1 = 0.7 # average service time
179
+ coev = 1.2 # coefficient of variation of service time
180
+ num_of_jobs = 1000000 # number of jobs for simulation
181
+
182
+ # selecting parameters of the approximating H2-distribution for service time [y1, mu1, mu2]:
183
+ params = H2Distribution.get_params_by_mean_and_coev(b1, coev)
184
+ b = H2Distribution.calc_theory_moments(params, 4)
185
+
186
+ # calculation using numerical methods
187
+ mg1_num = MG1Calculation(l, b)
188
+ w_ch = mg1_num.get_w()
189
+ p_ch = mg1_num.get_p()
190
+ v_ch = mg1_num.get_v()
191
+
192
+ # running simulation for verification of results
193
+ qs = QueueingSystemSimulator(1)
194
+ qs.set_servers(params, "H")
195
+ qs.set_sources(l, "M")
196
+ qs.run(num_of_jobs)
197
+ w_sim = qs.w
198
+ p_sim = qs.get_p()
199
+ v_sim = qs.v
200
+
201
+ # outputting the results
202
+ print("M/H2/1")
203
+
204
+ times_print(w_sim, w_ch, True)
205
+ times_print(v_sim, v_ch, False)
206
+ probs_print(p_sim, p_ch, 10)
207
+ ```
208
+
209
+ ### Priority queue example. For verification, comparing results with those calculated using the method of [invariant relations](https://cyberleninka.ru/article/n/raschet-mnogokanalnyh-sistem-obsluzhivaniya-s-absolyutnym-i-otnositelnym-prioritetami-na-osnove-invariantov-otnosheniya)
210
+
211
+ ```python
212
+ n = 5 # number of servers
213
+ k = 3 # number of classes of requests
214
+ l = [0.2, 0.3, 0.4] # service intensities by request classes
215
+ lsum = sum(l)
216
+ num_of_jobs = 300000 # number of jobs for the simulation
217
+
218
+ # Set up the parameters for service times at initial moments.
219
+ # Set average service times by class
220
+ b1 = [0.45 * n, 0.9 * n, 1.35 * n]
221
+
222
+ # Coefficient of variation of service time let's be the same for all classes
223
+ coev = 0.577
224
+
225
+ # second initial moments
226
+ b2 = [0] * k
227
+ for i in range(k):
228
+ b2[i] = (b1[i] ** 2) * (1 + coev ** 2)
229
+
230
+ b_sr = sum(b1) / k
231
+
232
+ # get the coefficient of load
233
+ ro = lsum * b_sr / n
234
+
235
+ # now, given the two initial moments, select parameters for the approximating Gamma distribution
236
+ # and add them to the list of parameters params
237
+ params = []
238
+ for i in range(k):
239
+ params.append(GammaDistribution.get_params([b1[i], b2[i]]))
240
+
241
+ b = []
242
+ for j in range(k):
243
+ b.append(GammaDistribution.calc_theory_moments(params[j], 4))
244
+
245
+ print("\nComparison of data from the simulation and results calculated using the method of invariant relations (R) \n"
246
+ "time spent in a multi-channel queue with priorities")
247
+ print("Number of servers: " + str(n) + "\nNumber of classes: " + str(k) + "\nCoefficient of load: {0:<1.2f}".format(ro) +
248
+ "\nCoefficient of variation of service time: " + str(coev) + "\n")
249
+ print("PR (Preamptive) priority")
250
+
251
+ # when creating the simulation, pass the number of servers, number of classes and type of priority.
252
+ # PR - absolute with re-service of requests
253
+ qs = PriorityQueueSimulator(n, k, "PR")
254
+
255
+ # to set up sources of requests and service servers, we need to specify a set of dictionaries with fields
256
+ # type - distribution type,
257
+ # params - its parameters.
258
+ # The number of such dictionaries in the lists sources and servers_params corresponds to the number of classes
259
+
260
+ sources = []
261
+ servers_params = []
262
+ for j in range(k):
263
+ sources.append({'type': 'M', 'params': l[j]})
264
+ servers_params.append({'type': 'Gamma', 'params': params[j]})
265
+
266
+ qs.set_sources(sources)
267
+ qs.set_servers(servers_params)
268
+
269
+ # start the simulation
270
+ qs.run(num_of_jobs)
271
+
272
+ # get the initial moments of time spent
273
+
274
+ v_sim = qs.v
275
+
276
+ # calculate them as well using the method of invariant relations (for comparison)
277
+ v_teor = priority_calc.get_v_prty_invar(l, b, n, 'PR')
278
+
279
+ assert abs(v_sim[0][0] - v_teor[0][0]) < 0.3
280
+
281
+ times_print_with_classes(v_sim, v_teor, False)
282
+
283
+ print("NP (Non-preamptive) priority")
284
+
285
+ # The same for relative priority (NP)
286
+ qs = PriorityQueueSimulator(n, k, "NP")
287
+ sources = []
288
+ servers_params = []
289
+ for j in range(k):
290
+ sources.append({'type': 'M', 'params': l[j]})
291
+ servers_params.append({'type': 'Gamma', 'params': params[j]})
292
+
293
+ qs.set_sources(sources)
294
+ qs.set_servers(servers_params)
295
+
296
+ qs.run(num_of_jobs)
297
+
298
+ v_sim = qs.v
299
+
300
+ v_teor = priority_calc.get_v_prty_invar(l, b, n, 'NP')
301
+
302
+ times_print_with_classes(v_sim, v_teor, False)
303
+ ```
304
+
305
+ ### References
306
+ - [(Ryzhikov Y.I. *Computational Methods*. BHV-Petersburg, 2007.)](https://www.litres.ru/book/uriy-ryzhikov/vychislitelnye-metody-uchebnoe-posobie-644835/)
307
+
308
+
@@ -0,0 +1,268 @@
1
+ # Queueing Systems: Simulation & Numerical Methods
2
+
3
+ ![Queue](assets/queue_long.png)
4
+
5
+ A Python package for simulating and analyzing queueing systems (QS) and networks.
6
+
7
+ ![GitHub commit activity](https://img.shields.io/github/commit-activity/m/xabarov/most-queue)
8
+
9
+
10
+ ## About
11
+ This repository focuses on solving steady-state problems in queueing theory.
12
+
13
+ Key Features:
14
+ - Simulate various types of queueing systems and networks.
15
+ - Numerical methods for solving queueing theory problems.
16
+ - Analyze system performance metrics such as waiting times, soujourn times, load factor and etc.
17
+
18
+
19
+ ## Use Cases
20
+ - Modeling cloud computing infrastructure.
21
+ - Designing efficient call centers.
22
+ - Optimizing transportation systems.
23
+ - Network traffic analysis.
24
+
25
+ ## Contributing
26
+ Contributions are welcome! If you find any issues or have suggestions, please open an [issue](https://github.com/xabarov/most-queue/issues). Your pull requests are also appreciated. You can write me at [xabarov1985@gmail.com](mailto:xabarov1985@gmail.com)
27
+
28
+ ## Roadmap
29
+ - Expand support for more queueing models.
30
+ - Implement advanced numerical solution methods.
31
+
32
+ ---
33
+
34
+ ## Installation
35
+ Install most-queue with pip
36
+ ```bash
37
+ pip install most-queue
38
+ ```
39
+
40
+ ### Description of the Project
41
+
42
+ Most_queue consists of two main parts:
43
+ - **most_queue.theory** contains programs that implement methods for calculating queuing theory models.
44
+ - **most_queue.sim** contains simulation programs.
45
+ ### Package most_queue.theory
46
+
47
+ Package consist of following submodules:
48
+
49
+ #### Batch
50
+ | # | Kendall Notations | Package Name | Description | Example | Tutorial |
51
+ |-----|-------------------|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|-------------------|
52
+ | 1. | M<sup>x</sup>/M/1 | batch.batch_mm1 | Solving for the of M<sup>x</sup>/M/1 QS with batch arrival | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_batch.py) | |
53
+
54
+ #### Closed
55
+ | # | Kendall Notations | Package Name | Description | Example | Tutorial |
56
+ |-----|-------------------|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|-------------------|
57
+ | 1. | M/M/1/N | closed.engset_model | Solving for the Engset model for M/M/1 with a finite number of sources. | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_engset.py) | |
58
+
59
+
60
+ #### Fork-Join
61
+
62
+ | # | Kendall Notations | Package Name | Description | Example | Tutorial |
63
+ |-----|-------------------|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|-------------------|
64
+ | 1. | M/M/c/Fork-Join | fork_join.fj_calc | Solving for Fork-Join queueing system | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_fj_im.py) | |
65
+
66
+
67
+ #### Priority Queueing Systems
68
+
69
+ | # | Kendall Notations | Package Name | Description | Example | Tutorial |
70
+ |-----|-------------------|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|-------------------|
71
+ | 1. | M/Ph/c/PR | priority.m_ph_n_prty | Numerical calculation of QS M/Ph/c with 2 classes and PR - priority. Based on the approximation of busy periods | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_m_ph_n_prty.py) | |
72
+ | 2. | M/M/c/PR | priority.mmn_prty_pnz_approx | Numerical calculation of QS M/M/c with 2 classes, PR - priority by the Takahashi-Takami numerical method based on the approximation of the busy period by the Cox distribution | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_mmn_prty_pnz_approx.py) | |
73
+ | 3. | M/M/c/PR | priority.mmn3_pnz_cox_approx | Numerical calculation of QS M/M/c with 3 classes, PR - priority by the Takahashi-Takami numerical method based on the approximation of busy period by the Cox distribution | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_mmn3_pnz_cox_approx.py) | |
74
+ | 4. | M/G/1 | priority.priority_calc | A set of functions for calculating QS with priorities (single-channel, multi-channel). The multichannel calculation is carried out by the method of relation | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_qs_sim_prty.py) |[link](https://github.com/xabarov/most-queue/blob/main/tutorials/priority_queue.ipynb) |
75
+
76
+ #### FIFO Queueing Systems
77
+ | # | Kendall Notations | Package Name | Description | Example | Tutorial |
78
+ |-----|-------------------|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|-------------------|
79
+ | 1. | Ek/D/c | fifo.ek_d_n_calc | Numerical calculation of a multi-channel system Ek/D/n | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_ek_d_n.py) | |
80
+ | 2. | GI/M/1 | fifo.gi_m_1_calc | Solving for QS GI/M/1 | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_gi_m_1_calc.py) | |
81
+ | 3. | GI/M/c | fifo.gi_m_n_calc | Solving for QS GI/M/c | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_gi_m_n_calc.py) | |
82
+ | 4. | M/D/c | fifo.m_d_n_calc | Solving for QS M/D/c | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_m_d_n_calc.py) | [link](https://github.com/xabarov/most-queue/blob/main/tutorials/queue_sim.ipynb) |
83
+ | 5. | M/G/1 | fifo.mg1_calc | Solving for QS M/G/1 | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_mg1_calc.py) | |
84
+ | 6. | M/H<SUB>2</SUB>/c | fifo.mgn_tt | Numerical calculation of QS M/H<SUB>2</SUB>/c by the Takahashi-Takami method with complex parameters when approximating the serving time by the H<SUB>2</SUB>-distribution | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_mgn_tt.py) | [link](https://github.com/xabarov/most-queue/blob/main/tutorials/mgn_takahasi_takami.ipynb) |
85
+ | 7. | M/M/c/r | fifo.mmnr_calc | Solving for QS M/M/c/r | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_qs_sim_test.py) | [link](https://github.com/xabarov/most-queue/blob/main/tutorials/queue_sim.ipynb) |
86
+
87
+
88
+ #### Networks
89
+
90
+ | # | Kendall Notations | Package Name | Description | Example | Tutorial |
91
+ |-----|-------------------|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|-------------------|
92
+ | 1. | General Network | network_calc | Numerical calculation of queuing network with priorities in nodes | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_network_im_prty.py) | |
93
+ | 2. | - | networks.network_viewer | Utility to view network structure | | |
94
+
95
+ #### Vacations
96
+ | # | Kendall Notations | Package Name | Description | Example | Tutorial |
97
+ |-----|-------------------|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|-------------------|
98
+ | 1. | M/H<SUB>2</SUB>/c | vacations.m_h2_h2warm | Numerical calculation of the M/H<SUB>2</SUB>/c system with H<SUB>2</SUB>-warming using the Takahasi-Takagi method. | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_m_h2_h2warm.py) | [link](https://github.com/xabarov/most-queue/blob/main/tutorials/m_h2_h2warm.ipynb)| |
99
+ | 2. | M/G/1 | vacations.mg1_warm_calc | Solving for QS M/G/1 with warm-up | | |
100
+ | 3. | M/Ph/c | vacations.mgn_with_h2_delay_cold_warm | Multichannel queuing system with H<SUB>2</SUB>-serving time, H<SUB>2</SUB>-warm-up, H<SUB>2</SUB>-cold delay and H<SUB>2</SUB>-cold (vacations). The system uses complex parameters, which allows you to calculate systems with arbitrary serving, warm-up, cold-delay and cold variation coefficients | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_mgn_with_h2_delay_cold_warm.py) | |
101
+ | 4. | M/M/c | vacations.mmn_with_h2_cold_h2_warmup | Multichannel queuing system with exp serving time, H<SUB>2</SUB>-warm-up and H<SUB>2</SUB>-cold (vacations). The system uses complex parameters, which allows to calculate systems with arbitrary warm-up and cold variation coefficients | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_mmn_h2cold_h2warm.py) | |
102
+
103
+ #### Impatience
104
+ | # | Kendall Notations | Package Name | Description | Example | Tutorial |
105
+ |-----|-------------------|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|-------------------|
106
+ | 1. | M/M/1/D | impatience.impatience_mm1 | Solving for M/M/1 with exponential impatience | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_impatience.py) | |
107
+
108
+ ### Package most_queue.sim
109
+
110
+ | # | Kendall Notations | Package Name | Description | Example | Tutorial |
111
+ |-----|-------------------|----------------------------|-------------------------------------------------------------------------------------------------|-------------------|-------------------|
112
+ | 1. | M<sup>x</sup>/M/c | batch_sim | Simulation of QS in a batch system | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_batch.py) | |
113
+ | 2. | M/G/c/Fork-Join | fj_delta_sim | Simulation of QS fork-join with a delay in the start of processing between channels | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_fj_delta.py) | |
114
+ | 3. | M/M/c | fj_sim | Simulation of QS with fork-join process | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_fj_im.py) | |
115
+ | 4. | - | flow_sum_sim | Simulation of flow summation | | |
116
+ | 5. | GI/G/c | impatient_queue_sim | Simulation of QS GI/G/m/n with impatience | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_impatience.py) | |
117
+ | 6. | QN | priority_network | Simulation of queuing network with priorities in nodes | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_network_im_prty.py) | |
118
+ | 7. | GI/G/c/n/Pri | priority_queue_sim | Simulation of QS GI/G/c/n with priorities | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_qs_sim_prty.py) | [link](https://github.com/xabarov/most-queue/blob/main/tutorials/priority_queue.ipynb) |
119
+ | 8. | GI/G/c/n | qs_sim | Simulation of QS GI/G/c/n | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_qs_sim_test.py) | [link](https://github.com/xabarov/most-queue/blob/main/tutorials/mgn_takahasi_takami.ipynb) |
120
+ | 9. | GI/G/c/n/N | queue_finite_source_sim | Simulation of QS GI/G/c/n with finite sources | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_engset.py) | |
121
+
122
+
123
+ ### Usage
124
+ - Look [here](https://github.com/xabarov/most-queue/tree/main/tests) for examples
125
+ - Look [here](https://github.com/xabarov/most-queue/tree/main/tutorials) for jupyter tutorials
126
+
127
+ ### Simple example: Calculate M/G/1 queueing system calculation with `most_queue` library. Run simulation and compare results with theory.
128
+
129
+ ```python
130
+ import numpy as np
131
+
132
+ from most_queue.general_utils.tables import probs_print, times_print
133
+ from most_queue.rand_distribution import H2Distribution
134
+ from most_queue.sim.qs_sim import QueueingSystemSimulator
135
+ from most_queue.theory.mg1_calc import MG1Calculation
136
+
137
+ l = 1 # input flow intensity
138
+ b1 = 0.7 # average service time
139
+ coev = 1.2 # coefficient of variation of service time
140
+ num_of_jobs = 1000000 # number of jobs for simulation
141
+
142
+ # selecting parameters of the approximating H2-distribution for service time [y1, mu1, mu2]:
143
+ params = H2Distribution.get_params_by_mean_and_coev(b1, coev)
144
+ b = H2Distribution.calc_theory_moments(params, 4)
145
+
146
+ # calculation using numerical methods
147
+ mg1_num = MG1Calculation(l, b)
148
+ w_ch = mg1_num.get_w()
149
+ p_ch = mg1_num.get_p()
150
+ v_ch = mg1_num.get_v()
151
+
152
+ # running simulation for verification of results
153
+ qs = QueueingSystemSimulator(1)
154
+ qs.set_servers(params, "H")
155
+ qs.set_sources(l, "M")
156
+ qs.run(num_of_jobs)
157
+ w_sim = qs.w
158
+ p_sim = qs.get_p()
159
+ v_sim = qs.v
160
+
161
+ # outputting the results
162
+ print("M/H2/1")
163
+
164
+ times_print(w_sim, w_ch, True)
165
+ times_print(v_sim, v_ch, False)
166
+ probs_print(p_sim, p_ch, 10)
167
+ ```
168
+
169
+ ### Priority queue example. For verification, comparing results with those calculated using the method of [invariant relations](https://cyberleninka.ru/article/n/raschet-mnogokanalnyh-sistem-obsluzhivaniya-s-absolyutnym-i-otnositelnym-prioritetami-na-osnove-invariantov-otnosheniya)
170
+
171
+ ```python
172
+ n = 5 # number of servers
173
+ k = 3 # number of classes of requests
174
+ l = [0.2, 0.3, 0.4] # service intensities by request classes
175
+ lsum = sum(l)
176
+ num_of_jobs = 300000 # number of jobs for the simulation
177
+
178
+ # Set up the parameters for service times at initial moments.
179
+ # Set average service times by class
180
+ b1 = [0.45 * n, 0.9 * n, 1.35 * n]
181
+
182
+ # Coefficient of variation of service time let's be the same for all classes
183
+ coev = 0.577
184
+
185
+ # second initial moments
186
+ b2 = [0] * k
187
+ for i in range(k):
188
+ b2[i] = (b1[i] ** 2) * (1 + coev ** 2)
189
+
190
+ b_sr = sum(b1) / k
191
+
192
+ # get the coefficient of load
193
+ ro = lsum * b_sr / n
194
+
195
+ # now, given the two initial moments, select parameters for the approximating Gamma distribution
196
+ # and add them to the list of parameters params
197
+ params = []
198
+ for i in range(k):
199
+ params.append(GammaDistribution.get_params([b1[i], b2[i]]))
200
+
201
+ b = []
202
+ for j in range(k):
203
+ b.append(GammaDistribution.calc_theory_moments(params[j], 4))
204
+
205
+ print("\nComparison of data from the simulation and results calculated using the method of invariant relations (R) \n"
206
+ "time spent in a multi-channel queue with priorities")
207
+ print("Number of servers: " + str(n) + "\nNumber of classes: " + str(k) + "\nCoefficient of load: {0:<1.2f}".format(ro) +
208
+ "\nCoefficient of variation of service time: " + str(coev) + "\n")
209
+ print("PR (Preamptive) priority")
210
+
211
+ # when creating the simulation, pass the number of servers, number of classes and type of priority.
212
+ # PR - absolute with re-service of requests
213
+ qs = PriorityQueueSimulator(n, k, "PR")
214
+
215
+ # to set up sources of requests and service servers, we need to specify a set of dictionaries with fields
216
+ # type - distribution type,
217
+ # params - its parameters.
218
+ # The number of such dictionaries in the lists sources and servers_params corresponds to the number of classes
219
+
220
+ sources = []
221
+ servers_params = []
222
+ for j in range(k):
223
+ sources.append({'type': 'M', 'params': l[j]})
224
+ servers_params.append({'type': 'Gamma', 'params': params[j]})
225
+
226
+ qs.set_sources(sources)
227
+ qs.set_servers(servers_params)
228
+
229
+ # start the simulation
230
+ qs.run(num_of_jobs)
231
+
232
+ # get the initial moments of time spent
233
+
234
+ v_sim = qs.v
235
+
236
+ # calculate them as well using the method of invariant relations (for comparison)
237
+ v_teor = priority_calc.get_v_prty_invar(l, b, n, 'PR')
238
+
239
+ assert abs(v_sim[0][0] - v_teor[0][0]) < 0.3
240
+
241
+ times_print_with_classes(v_sim, v_teor, False)
242
+
243
+ print("NP (Non-preamptive) priority")
244
+
245
+ # The same for relative priority (NP)
246
+ qs = PriorityQueueSimulator(n, k, "NP")
247
+ sources = []
248
+ servers_params = []
249
+ for j in range(k):
250
+ sources.append({'type': 'M', 'params': l[j]})
251
+ servers_params.append({'type': 'Gamma', 'params': params[j]})
252
+
253
+ qs.set_sources(sources)
254
+ qs.set_servers(servers_params)
255
+
256
+ qs.run(num_of_jobs)
257
+
258
+ v_sim = qs.v
259
+
260
+ v_teor = priority_calc.get_v_prty_invar(l, b, n, 'NP')
261
+
262
+ times_print_with_classes(v_sim, v_teor, False)
263
+ ```
264
+
265
+ ### References
266
+ - [(Ryzhikov Y.I. *Computational Methods*. BHV-Petersburg, 2007.)](https://www.litres.ru/book/uriy-ryzhikov/vychislitelnye-metody-uchebnoe-posobie-644835/)
267
+
268
+
Binary file
@@ -0,0 +1,20 @@
1
+ # Minimal makefile for Sphinx documentation
2
+ #
3
+
4
+ # You can set these variables from the command line, and also
5
+ # from the environment for the first two.
6
+ SPHINXOPTS ?=
7
+ SPHINXBUILD ?= sphinx-build
8
+ SOURCEDIR = source
9
+ BUILDDIR = build
10
+
11
+ # Put it first so that "make" without argument is like "make help".
12
+ help:
13
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14
+
15
+ .PHONY: help Makefile
16
+
17
+ # Catch-all target: route all unknown targets to Sphinx using the new
18
+ # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19
+ %: Makefile
20
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@@ -0,0 +1,35 @@
1
+ @ECHO OFF
2
+
3
+ pushd %~dp0
4
+
5
+ REM Command file for Sphinx documentation
6
+
7
+ if "%SPHINXBUILD%" == "" (
8
+ set SPHINXBUILD=sphinx-build
9
+ )
10
+ set SOURCEDIR=source
11
+ set BUILDDIR=build
12
+
13
+ %SPHINXBUILD% >NUL 2>NUL
14
+ if errorlevel 9009 (
15
+ echo.
16
+ echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17
+ echo.installed, then set the SPHINXBUILD environment variable to point
18
+ echo.to the full path of the 'sphinx-build' executable. Alternatively you
19
+ echo.may add the Sphinx directory to PATH.
20
+ echo.
21
+ echo.If you don't have Sphinx installed, grab it from
22
+ echo.https://www.sphinx-doc.org/
23
+ exit /b 1
24
+ )
25
+
26
+ if "%1" == "" goto help
27
+
28
+ %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29
+ goto end
30
+
31
+ :help
32
+ %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33
+
34
+ :end
35
+ popd