most-queue 1.47__tar.gz → 1.50__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 (111) hide show
  1. most_queue-1.50/.gitignore +163 -0
  2. most_queue-1.50/PKG-INFO +250 -0
  3. most_queue-1.50/README.md +210 -0
  4. most_queue-1.50/assets/IMPATIENCE.jpg +0 -0
  5. most_queue-1.50/assets/queue.jpg +0 -0
  6. most_queue-1.50/assets/queue2.jpg +0 -0
  7. most_queue-1.50/assets/queue3.jpg +0 -0
  8. most_queue-1.50/assets/queue4.jpg +0 -0
  9. most_queue-1.50/assets/queue5.jpg +0 -0
  10. most_queue-1.50/assets/queue6.jpg +0 -0
  11. most_queue-1.50/deploy.txt +3 -0
  12. {most_queue-1.47 → most_queue-1.50}/most_queue/general_utils/tables.py +38 -14
  13. most_queue-1.50/most_queue/misc/compare_fj_calc.py +123 -0
  14. most_queue-1.50/most_queue/misc/flow_sum.py +98 -0
  15. most_queue-1.50/most_queue/misc/test_weibull.py +37 -0
  16. {most_queue-1.47 → most_queue-1.50}/most_queue/theory/engset_model.py +4 -1
  17. {most_queue-1.47 → most_queue-1.50}/most_queue/theory/m_h2_h2warm.py +2 -3
  18. {most_queue-1.47 → most_queue-1.50}/most_queue/theory/mgn_with_h2_delay_cold_warm.py +49 -27
  19. {most_queue-1.47 → most_queue-1.50}/most_queue/theory/mmn_with_h2_cold_and_h2_warmup.py +22 -17
  20. most_queue-1.50/most_queue/theory/r_example.gexf +27 -0
  21. {most_queue-1.47 → most_queue-1.50}/pyproject.toml +18 -3
  22. most_queue-1.50/requirements.txt +7 -0
  23. {most_queue-1.47 → most_queue-1.50}/setup.py +9 -7
  24. most_queue-1.50/tests/n_test/ro_0.700.json +1 -0
  25. most_queue-1.50/tests/ro_test/n_3.json +1 -0
  26. {most_queue-1.47 → most_queue-1.50}/tests/test_mg1_calc.py +11 -11
  27. most_queue-1.50/tests/test_qs_sim_prty.py +111 -0
  28. most_queue-1.50/tutorials/m_h2_h2warm.ipynb +347 -0
  29. most_queue-1.50/tutorials/mgn_takahasi_takami.ipynb +298 -0
  30. most_queue-1.50/tutorials/priority queue.ipynb +369 -0
  31. most_queue-1.50/tutorials/queue_sim.ipynb +334 -0
  32. most_queue-1.47/PKG-INFO +0 -241
  33. most_queue-1.47/README.md +0 -204
  34. most_queue-1.47/most_queue.egg-info/PKG-INFO +0 -241
  35. most_queue-1.47/most_queue.egg-info/SOURCES.txt +0 -86
  36. most_queue-1.47/most_queue.egg-info/dependency_links.txt +0 -1
  37. most_queue-1.47/most_queue.egg-info/not-zip-safe +0 -1
  38. most_queue-1.47/most_queue.egg-info/top_level.txt +0 -2
  39. most_queue-1.47/setup.cfg +0 -4
  40. most_queue-1.47/tests/test_qs_sim_prty.py +0 -111
  41. {most_queue-1.47 → most_queue-1.50}/LICENSE +0 -0
  42. {most_queue-1.47 → most_queue-1.50}/most_queue/__init__.py +0 -0
  43. {most_queue-1.47 → most_queue-1.50}/most_queue/general_utils/__init__.py +0 -0
  44. {most_queue-1.47 → most_queue-1.50}/most_queue/general_utils/approx_cdf_make.py +0 -0
  45. {most_queue-1.47 → most_queue-1.50}/most_queue/general_utils/conv.py +0 -0
  46. {most_queue-1.47 → most_queue-1.50}/most_queue/general_utils/vacations_paper_utils.py +0 -0
  47. {most_queue-1.47 → most_queue-1.50}/most_queue/rand_distribution.py +0 -0
  48. {most_queue-1.47 → most_queue-1.50}/most_queue/sim/__init__.py +0 -0
  49. {most_queue-1.47 → most_queue-1.50}/most_queue/sim/batch_sim.py +0 -0
  50. {most_queue-1.47 → most_queue-1.50}/most_queue/sim/fj_delta_sim.py +0 -0
  51. {most_queue-1.47 → most_queue-1.50}/most_queue/sim/fj_sim.py +0 -0
  52. {most_queue-1.47 → most_queue-1.50}/most_queue/sim/flow_sum_sim.py +0 -0
  53. {most_queue-1.47 → most_queue-1.50}/most_queue/sim/impatient_queue_sim.py +0 -0
  54. {most_queue-1.47 → most_queue-1.50}/most_queue/sim/priority_network.py +0 -0
  55. {most_queue-1.47 → most_queue-1.50}/most_queue/sim/priority_queue_sim.py +0 -0
  56. {most_queue-1.47 → most_queue-1.50}/most_queue/sim/qs_sim.py +0 -0
  57. {most_queue-1.47 → most_queue-1.50}/most_queue/sim/queue_finite_source_sim.py +0 -0
  58. {most_queue-1.47 → most_queue-1.50}/most_queue/sim/utils/__init__.py +0 -0
  59. {most_queue-1.47 → most_queue-1.50}/most_queue/sim/utils/distribution_utils.py +0 -0
  60. {most_queue-1.47 → most_queue-1.50}/most_queue/sim/utils/exceptions.py +0 -0
  61. {most_queue-1.47 → most_queue-1.50}/most_queue/sim/utils/phase.py +0 -0
  62. {most_queue-1.47 → most_queue-1.50}/most_queue/sim/utils/qs_queue.py +0 -0
  63. {most_queue-1.47 → most_queue-1.50}/most_queue/sim/utils/servers.py +0 -0
  64. {most_queue-1.47 → most_queue-1.50}/most_queue/sim/utils/stats_update.py +0 -0
  65. {most_queue-1.47 → most_queue-1.50}/most_queue/sim/utils/tasks.py +0 -0
  66. {most_queue-1.47 → most_queue-1.50}/most_queue/theory/__init__.py +0 -0
  67. {most_queue-1.47 → most_queue-1.50}/most_queue/theory/batch_mm1.py +0 -0
  68. {most_queue-1.47 → most_queue-1.50}/most_queue/theory/ek_d_n_calc.py +0 -0
  69. {most_queue-1.47 → most_queue-1.50}/most_queue/theory/fj_calc.py +0 -0
  70. {most_queue-1.47 → most_queue-1.50}/most_queue/theory/gi_m_1_calc.py +0 -0
  71. {most_queue-1.47 → most_queue-1.50}/most_queue/theory/gi_m_n_calc.py +0 -0
  72. {most_queue-1.47 → most_queue-1.50}/most_queue/theory/impatience_calc.py +0 -0
  73. {most_queue-1.47 → most_queue-1.50}/most_queue/theory/m_d_n_calc.py +0 -0
  74. {most_queue-1.47 → most_queue-1.50}/most_queue/theory/m_ph_n_prty.py +0 -0
  75. {most_queue-1.47 → most_queue-1.50}/most_queue/theory/mg1_calc.py +0 -0
  76. {most_queue-1.47 → most_queue-1.50}/most_queue/theory/mg1_warm_calc.py +0 -0
  77. {most_queue-1.47 → most_queue-1.50}/most_queue/theory/mgn_tt.py +0 -0
  78. {most_queue-1.47 → most_queue-1.50}/most_queue/theory/mmn3_pnz_cox_approx.py +0 -0
  79. {most_queue-1.47 → most_queue-1.50}/most_queue/theory/mmn_prty_pnz_approx.py +0 -0
  80. {most_queue-1.47 → most_queue-1.50}/most_queue/theory/mmnr_calc.py +0 -0
  81. {most_queue-1.47 → most_queue-1.50}/most_queue/theory/network_calc.py +0 -0
  82. {most_queue-1.47 → most_queue-1.50}/most_queue/theory/network_viewer.py +0 -0
  83. {most_queue-1.47 → most_queue-1.50}/most_queue/theory/priority_calc.py +0 -0
  84. {most_queue-1.47 → most_queue-1.50}/most_queue/theory/utils/__init__.py +0 -0
  85. {most_queue-1.47 → most_queue-1.50}/most_queue/theory/utils/binom_probs.py +0 -0
  86. {most_queue-1.47 → most_queue-1.50}/most_queue/theory/utils/diff5dots.py +0 -0
  87. {most_queue-1.47 → most_queue-1.50}/most_queue/theory/utils/flow_sum.py +0 -0
  88. {most_queue-1.47 → most_queue-1.50}/most_queue/theory/utils/passage_time.py +0 -0
  89. {most_queue-1.47 → most_queue-1.50}/most_queue/theory/utils/q_poisson_arrival_calc.py +0 -0
  90. {most_queue-1.47 → most_queue-1.50}/most_queue/theory/utils/student_stat.py +0 -0
  91. {most_queue-1.47 → most_queue-1.50}/most_queue/theory/utils/weibull.py +0 -0
  92. {most_queue-1.47 → most_queue-1.50}/tests/__init__.py +0 -0
  93. {most_queue-1.47 → most_queue-1.50}/tests/test_batch.py +0 -0
  94. {most_queue-1.47 → most_queue-1.50}/tests/test_ek_d_n.py +0 -0
  95. {most_queue-1.47 → most_queue-1.50}/tests/test_engset.py +0 -0
  96. {most_queue-1.47 → most_queue-1.50}/tests/test_fj_delta.py +0 -0
  97. {most_queue-1.47 → most_queue-1.50}/tests/test_fj_im.py +0 -0
  98. {most_queue-1.47 → most_queue-1.50}/tests/test_gi_m_1_calc.py +0 -0
  99. {most_queue-1.47 → most_queue-1.50}/tests/test_gi_m_n_calc.py +0 -0
  100. {most_queue-1.47 → most_queue-1.50}/tests/test_impatience.py +0 -0
  101. {most_queue-1.47 → most_queue-1.50}/tests/test_m_d_n_calc.py +0 -0
  102. {most_queue-1.47 → most_queue-1.50}/tests/test_m_h2_h2warm.py +0 -0
  103. {most_queue-1.47 → most_queue-1.50}/tests/test_m_ph_n_prty.py +0 -0
  104. {most_queue-1.47 → most_queue-1.50}/tests/test_mgn_tt.py +0 -0
  105. {most_queue-1.47 → most_queue-1.50}/tests/test_mgn_with_h2_delay_cold_warm.py +0 -0
  106. {most_queue-1.47 → most_queue-1.50}/tests/test_mmn3_pnz_cox_approx.py +0 -0
  107. {most_queue-1.47 → most_queue-1.50}/tests/test_mmn_h2cold_h2warm.py +0 -0
  108. {most_queue-1.47 → most_queue-1.50}/tests/test_mmn_prty_pnz_approx.py +0 -0
  109. {most_queue-1.47 → most_queue-1.50}/tests/test_network_im_prty.py +0 -0
  110. {most_queue-1.47 → most_queue-1.50}/tests/test_qs_sim_test.py +0 -0
  111. {most_queue-1.47 → most_queue-1.50}/tests/test_queue_types.py +0 -0
@@ -0,0 +1,163 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ pkg/
22
+ var/
23
+ wheels/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+
65
+ # Flask stuff:
66
+ instance/
67
+ .webassets-cache
68
+
69
+ # Scrapy stuff:
70
+ .scrapy
71
+
72
+ # Sphinx documentation
73
+ docs/_build/
74
+
75
+ # PyBuilder
76
+ .pybuilder/
77
+ target/
78
+
79
+ # Jupyter Notebook
80
+ .ipynb_checkpoints
81
+
82
+ # IPython
83
+ profile_default/
84
+ ipython_config.py
85
+
86
+ # pyenv
87
+ # For a library or package, you might want to ignore these files since the code is
88
+ # intended to run in multiple environments; otherwise, check them in:
89
+ # .python-version
90
+
91
+ # pipenv
92
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
94
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
95
+ # install all needed dependencies.
96
+ #Pipfile.lock
97
+
98
+ # poetry
99
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
100
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
101
+ # commonly ignored for libraries.
102
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
103
+ #poetry.lock
104
+
105
+ # pdm
106
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
107
+ #pdm.lock
108
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
109
+ # in version control.
110
+ # https://pdm.fming.dev/#use-with-ide
111
+ .pdm.toml
112
+
113
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
114
+ __pypackages__/
115
+
116
+ # Celery stuff
117
+ celerybeat-schedule
118
+ celerybeat.pid
119
+
120
+ # SageMath parsed files
121
+ *.sage.py
122
+
123
+ # Environments
124
+ .env
125
+ .venv
126
+ env/
127
+ venv/
128
+ ENV/
129
+ env.bak/
130
+ venv.bak/
131
+
132
+ # Spyder project settings
133
+ .spyderproject
134
+ .spyproject
135
+
136
+ # Rope project settings
137
+ .ropeproject
138
+
139
+ # mkdocs documentation
140
+ /site
141
+
142
+ # mypy
143
+ .mypy_cache/
144
+ .dmypy.json
145
+ dmypy.json
146
+
147
+ # Pyre type checker
148
+ .pyre/
149
+
150
+ # pytype static type analyzer
151
+ .pytype/
152
+ most_queue/theory/doctest-output
153
+ # Cython debug symbols
154
+ cython_debug/
155
+
156
+ # PyCharm
157
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
158
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
159
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
160
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
161
+ #.idea/
162
+
163
+ .vscode
@@ -0,0 +1,250 @@
1
+ Metadata-Version: 2.4
2
+ Name: most_queue
3
+ Version: 1.50
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 and numerical methods of Queuing theory
42
+
43
+ ![Queue](assets/queue6.jpg)
44
+
45
+ Python package for calculation and simulation of queueing systems (QS) and networks.
46
+
47
+ MOST (MOCT, Массовое обслуживание стационарные задачи) stands for “Mass Service Steady-State Problems” and refers to tasks within queueing theory that involve large-scale service systems operating under steady-state conditions.
48
+ - [Рыжиков Ю. И. Вычислительные методы. – БХВ-Петербург, 2007.](https://www.litres.ru/book/uriy-ryzhikov/vychislitelnye-metody-uchebnoe-posobie-644835/)
49
+
50
+ Queueing theory. Numerical methods.
51
+
52
+
53
+ ## Authors
54
+ - [xabarov](https://github.com/xabarov)
55
+
56
+ ## Installation
57
+ Install most-queue with pip
58
+ ```bash
59
+ pip install most-queue
60
+ ```
61
+
62
+ ## DESCRIPTION
63
+ Most_queue consists of two main parts:
64
+ - **.theory** contains programs that implement methods for calculating queuing theory models.
65
+ - **.sim** contains simulation programs.
66
+ ### Package .theory
67
+ | # | Package name | Description |
68
+ |-----|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
69
+ | 1. | batch_mm1 | Calculation of M/M/1 QS with batch arrival |
70
+ | 2. | ek_d_n_calc | Numerical calculation of a multi-channel system Ek/D/n |
71
+ | 3. | engset_model | Calculation of the Engset model for M/M/1 with a finite number of sources. |
72
+ | 4. | fj_calc | Numerical calculation of the initial moments of the random variables maximum distribution |
73
+ | 5. | gi_m_1_calc | Numerical calculation of QS GI/M/1 |
74
+ | 6. | gi_m_n_calc | Numerical calculation of QS GI/M/n |
75
+ | 7. | impatience_calc | Calculation of M/M/1 with exponential impatience |
76
+ | 8. | m_d_n_calc | Numerical calculation of QS M/D/n |
77
+ | 9. | m_h2_h2_warm | Calculation of the M/H2/n system with H2-warming using the Takahasi-Takagi method. |
78
+ | 10. | m_ph_n_prty | Numerical calculation of QS M/Ph/n with 2 classes and PR - priority. Based on the approximation of busy periods |
79
+ | 11. | mg1_calc | Numerical calculation of QS M/G/1 |
80
+ | 12. | mg1_warm_calc | Numerical calculation of QS M/G/1 with "warm-up" |
81
+ | 13. | mgn_tt | Numerical calculation of QS M/H2/n by the Takahashi-Takami method with complex parameters when approximating the serving time by the H2 distribution |
82
+ | 14. | mgn_with_h2_delay_cold_warm.py | Multichannel queuing system with H2 serving time, H2 warm-up, H2 cold delay and H2 cold (vacations). The system uses complex parameters, which allows you to calculate systems with arbitrary serving, warm-up, cold-delay and cold variation coefficients |
83
+ | 15. | mmn_prty_pnz_approx | Calculation of QS M/M/2 with 2 classes, PR - priority by the Takahashi-Takami numerical method based on the approximation of the busy period by the Cox distribution |
84
+ | 16. | mmn_with_h2_cold_h2_warmup.py | Multichannel queuing system with exp serving time, H2 warm-up and H2 cold (vacations). The system uses complex parameters, which allows to calculate systems with arbitrary warm-up and cold variation coefficients |
85
+ | 17. | mmn3_pnz_cox_approx | Calculation of QS M/M/2 with 3 classes, PR - priority by the Takahashi-Takami numerical method based on the approximation of busy period by the Cox distribution |
86
+ | 18. | mmnr_calc | Calculation of QS M/M/n/r |
87
+ | 19. | network_calc | Calculation of queuing network with priorities in nodes |
88
+ | 20. | network_viewer.py | Utility to view network structure |
89
+ | 21. | 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 |
90
+
91
+
92
+ ### Package .sim
93
+ | # | Package name | Description |
94
+ | ------------- |----------------------------|------------- |
95
+ | 1. | batch_sim | Simulation of QS in a batch system |
96
+ | 2. | fj_delta_sim | Simulation of QS fork-join with a delay in the start of processing between channels |
97
+ | 3. | fj_sim | Simulation of QS with fork-join process |
98
+ | 4. | flow_sum_sim | Simulation of flow summation |
99
+ | 5. | impatient_sim.py | Simulation of QS GI/G/m/n with impatience |
100
+ | 6. | priority_network | Simulation of queuing network with priorities in nodes |
101
+ | 7. | priority_queue_sim | Simulation of QS GI/G/m/n with priorities |
102
+ | 8. | qs_sim | Simulation of QS GI/G/m/n |
103
+ | 9. | queue_finite_source_sim.py | Simulation of QS GI/G/m/n with finite sources |
104
+
105
+ ## Usage
106
+ - Look [here](https://github.com/xabarov/most-queue/tree/main/tests) for examples
107
+ - Look [here](https://github.com/xabarov/most-queue/tree/main/tutorials) for jupyter tutorials
108
+
109
+ ### Simple example: Calculate M/G/1 queueing system calculation with `most_queue` library. Run simulation and compare results with theory.
110
+
111
+ ```python
112
+ import numpy as np
113
+
114
+ from most_queue.general_utils.tables import probs_print, times_print
115
+ from most_queue.rand_distribution import H2_dist
116
+ from most_queue.sim.qs_sim import QueueingSystemSimulator
117
+ from most_queue.theory.mg1_calc import get_p, get_v, get_w
118
+
119
+ l = 1 # input flow intensity
120
+ b1 = 0.7 # average service time
121
+ coev = 1.2 # coefficient of variation of service time
122
+ num_of_jobs = 1000000 # number of jobs for simulation
123
+
124
+ # selecting parameters of the approximating H2-distribution for service time [y1, mu1, mu2]:
125
+ params = H2_dist.get_params_by_mean_and_coev(b1, coev)
126
+ b = H2_dist.calc_theory_moments(*params, 4)
127
+
128
+ # calculation using numerical methods
129
+ w_ch = get_w(l, b)
130
+ p_ch = get_p(l, b, 100)
131
+ v_ch = get_v(l, b)
132
+
133
+ # running simulation for verification of results
134
+ qs = QueueingSystemSimulator(1)
135
+ qs.set_servers(params, "H")
136
+ qs.set_sources(l, "M")
137
+ qs.run(num_of_jobs)
138
+ w_sim = qs.w
139
+ p_sim = qs.get_p()
140
+ v_sim = qs.v
141
+
142
+ # outputting the results
143
+ print("M/H2/1")
144
+
145
+ times_print(w_sim, w_ch, True)
146
+ times_print(v_sim, v_ch, False)
147
+ probs_print(p_sim, p_ch, 10)
148
+ ```
149
+
150
+ ### 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)
151
+
152
+ ```python
153
+ n = 5 # number of servers
154
+ k = 3 # number of classes of requests
155
+ l = [0.2, 0.3, 0.4] # service intensities by request classes
156
+ lsum = sum(l)
157
+ num_of_jobs = 300000 # number of jobs for the simulation
158
+
159
+ # Set up the parameters for service times at initial moments.
160
+ # Set average service times by class
161
+ b1 = [0.45 * n, 0.9 * n, 1.35 * n]
162
+
163
+ # Coefficient of variation of service time let's be the same for all classes
164
+ coev = 0.577
165
+
166
+ # second initial moments
167
+ b2 = [0] * k
168
+ for i in range(k):
169
+ b2[i] = (b1[i] ** 2) * (1 + coev ** 2)
170
+
171
+ b_sr = sum(b1) / k
172
+
173
+ # get the coefficient of load
174
+ ro = lsum * b_sr / n
175
+
176
+ # now, given the two initial moments, select parameters for the approximating Gamma distribution
177
+ # and add them to the list of parameters params
178
+ params = []
179
+ for i in range(k):
180
+ params.append(Gamma.get_mu_alpha([b1[i], b2[i]]))
181
+
182
+ b = []
183
+ for j in range(k):
184
+ b.append(Gamma.calc_theory_moments(params[j][0], params[j][1], 4))
185
+
186
+ print("\nComparison of data from the simulation and results calculated using the method of invariant relations (R) \n"
187
+ "time spent in a multi-channel queue with priorities")
188
+ print("Number of servers: " + str(n) + "\nNumber of classes: " + str(k) + "\nCoefficient of load: {0:<1.2f}".format(ro) +
189
+ "\nCoefficient of variation of service time: " + str(coev) + "\n")
190
+ print("PR (Preamptive) priority")
191
+
192
+ # when creating the simulation, pass the number of servers, number of classes and type of priority.
193
+ # PR - absolute with re-service of requests
194
+ qs = PriorityQueueSimulator(n, k, "PR")
195
+
196
+ # to set up sources of requests and service servers, we need to specify a set of dictionaries with fields
197
+ # type - distribution type,
198
+ # params - its parameters.
199
+ # The number of such dictionaries in the lists sources and servers_params corresponds to the number of classes
200
+
201
+ sources = []
202
+ servers_params = []
203
+ for j in range(k):
204
+ sources.append({'type': 'M', 'params': l[j]})
205
+ servers_params.append({'type': 'Gamma', 'params': params[j]})
206
+
207
+ qs.set_sources(sources)
208
+ qs.set_servers(servers_params)
209
+
210
+ # start the simulation
211
+ qs.run(num_of_jobs)
212
+
213
+ # get the initial moments of time spent
214
+
215
+ v_sim = qs.v
216
+
217
+ # calculate them as well using the method of invariant relations (for comparison)
218
+ v_teor = priority_calc.get_v_prty_invar(l, b, n, 'PR')
219
+
220
+ assert abs(v_sim[0][0] - v_teor[0][0]) < 0.3
221
+
222
+ times_print_with_classes(v_sim, v_teor, False)
223
+
224
+ print("NP (Non-preamptive) priority")
225
+
226
+ # The same for relative priority (NP)
227
+ qs = PriorityQueueSimulator(n, k, "NP")
228
+ sources = []
229
+ servers_params = []
230
+ for j in range(k):
231
+ sources.append({'type': 'M', 'params': l[j]})
232
+ servers_params.append({'type': 'Gamma', 'params': params[j]})
233
+
234
+ qs.set_sources(sources)
235
+ qs.set_servers(servers_params)
236
+
237
+ qs.run(num_of_jobs)
238
+
239
+ v_sim = qs.v
240
+
241
+ v_teor = priority_calc.get_v_prty_invar(l, b, n, 'NP')
242
+
243
+ times_print_with_classes(v_sim, v_teor, False)
244
+ ```
245
+
246
+
247
+
248
+
249
+
250
+
@@ -0,0 +1,210 @@
1
+ # Queueing systems. Simulation and numerical methods of Queuing theory
2
+
3
+ ![Queue](assets/queue6.jpg)
4
+
5
+ Python package for calculation and simulation of queueing systems (QS) and networks.
6
+
7
+ MOST (MOCT, Массовое обслуживание стационарные задачи) stands for “Mass Service Steady-State Problems” and refers to tasks within queueing theory that involve large-scale service systems operating under steady-state conditions.
8
+ - [Рыжиков Ю. И. Вычислительные методы. – БХВ-Петербург, 2007.](https://www.litres.ru/book/uriy-ryzhikov/vychislitelnye-metody-uchebnoe-posobie-644835/)
9
+
10
+ Queueing theory. Numerical methods.
11
+
12
+
13
+ ## Authors
14
+ - [xabarov](https://github.com/xabarov)
15
+
16
+ ## Installation
17
+ Install most-queue with pip
18
+ ```bash
19
+ pip install most-queue
20
+ ```
21
+
22
+ ## DESCRIPTION
23
+ Most_queue consists of two main parts:
24
+ - **.theory** contains programs that implement methods for calculating queuing theory models.
25
+ - **.sim** contains simulation programs.
26
+ ### Package .theory
27
+ | # | Package name | Description |
28
+ |-----|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
29
+ | 1. | batch_mm1 | Calculation of M/M/1 QS with batch arrival |
30
+ | 2. | ek_d_n_calc | Numerical calculation of a multi-channel system Ek/D/n |
31
+ | 3. | engset_model | Calculation of the Engset model for M/M/1 with a finite number of sources. |
32
+ | 4. | fj_calc | Numerical calculation of the initial moments of the random variables maximum distribution |
33
+ | 5. | gi_m_1_calc | Numerical calculation of QS GI/M/1 |
34
+ | 6. | gi_m_n_calc | Numerical calculation of QS GI/M/n |
35
+ | 7. | impatience_calc | Calculation of M/M/1 with exponential impatience |
36
+ | 8. | m_d_n_calc | Numerical calculation of QS M/D/n |
37
+ | 9. | m_h2_h2_warm | Calculation of the M/H2/n system with H2-warming using the Takahasi-Takagi method. |
38
+ | 10. | m_ph_n_prty | Numerical calculation of QS M/Ph/n with 2 classes and PR - priority. Based on the approximation of busy periods |
39
+ | 11. | mg1_calc | Numerical calculation of QS M/G/1 |
40
+ | 12. | mg1_warm_calc | Numerical calculation of QS M/G/1 with "warm-up" |
41
+ | 13. | mgn_tt | Numerical calculation of QS M/H2/n by the Takahashi-Takami method with complex parameters when approximating the serving time by the H2 distribution |
42
+ | 14. | mgn_with_h2_delay_cold_warm.py | Multichannel queuing system with H2 serving time, H2 warm-up, H2 cold delay and H2 cold (vacations). The system uses complex parameters, which allows you to calculate systems with arbitrary serving, warm-up, cold-delay and cold variation coefficients |
43
+ | 15. | mmn_prty_pnz_approx | Calculation of QS M/M/2 with 2 classes, PR - priority by the Takahashi-Takami numerical method based on the approximation of the busy period by the Cox distribution |
44
+ | 16. | mmn_with_h2_cold_h2_warmup.py | Multichannel queuing system with exp serving time, H2 warm-up and H2 cold (vacations). The system uses complex parameters, which allows to calculate systems with arbitrary warm-up and cold variation coefficients |
45
+ | 17. | mmn3_pnz_cox_approx | Calculation of QS M/M/2 with 3 classes, PR - priority by the Takahashi-Takami numerical method based on the approximation of busy period by the Cox distribution |
46
+ | 18. | mmnr_calc | Calculation of QS M/M/n/r |
47
+ | 19. | network_calc | Calculation of queuing network with priorities in nodes |
48
+ | 20. | network_viewer.py | Utility to view network structure |
49
+ | 21. | 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 |
50
+
51
+
52
+ ### Package .sim
53
+ | # | Package name | Description |
54
+ | ------------- |----------------------------|------------- |
55
+ | 1. | batch_sim | Simulation of QS in a batch system |
56
+ | 2. | fj_delta_sim | Simulation of QS fork-join with a delay in the start of processing between channels |
57
+ | 3. | fj_sim | Simulation of QS with fork-join process |
58
+ | 4. | flow_sum_sim | Simulation of flow summation |
59
+ | 5. | impatient_sim.py | Simulation of QS GI/G/m/n with impatience |
60
+ | 6. | priority_network | Simulation of queuing network with priorities in nodes |
61
+ | 7. | priority_queue_sim | Simulation of QS GI/G/m/n with priorities |
62
+ | 8. | qs_sim | Simulation of QS GI/G/m/n |
63
+ | 9. | queue_finite_source_sim.py | Simulation of QS GI/G/m/n with finite sources |
64
+
65
+ ## Usage
66
+ - Look [here](https://github.com/xabarov/most-queue/tree/main/tests) for examples
67
+ - Look [here](https://github.com/xabarov/most-queue/tree/main/tutorials) for jupyter tutorials
68
+
69
+ ### Simple example: Calculate M/G/1 queueing system calculation with `most_queue` library. Run simulation and compare results with theory.
70
+
71
+ ```python
72
+ import numpy as np
73
+
74
+ from most_queue.general_utils.tables import probs_print, times_print
75
+ from most_queue.rand_distribution import H2_dist
76
+ from most_queue.sim.qs_sim import QueueingSystemSimulator
77
+ from most_queue.theory.mg1_calc import get_p, get_v, get_w
78
+
79
+ l = 1 # input flow intensity
80
+ b1 = 0.7 # average service time
81
+ coev = 1.2 # coefficient of variation of service time
82
+ num_of_jobs = 1000000 # number of jobs for simulation
83
+
84
+ # selecting parameters of the approximating H2-distribution for service time [y1, mu1, mu2]:
85
+ params = H2_dist.get_params_by_mean_and_coev(b1, coev)
86
+ b = H2_dist.calc_theory_moments(*params, 4)
87
+
88
+ # calculation using numerical methods
89
+ w_ch = get_w(l, b)
90
+ p_ch = get_p(l, b, 100)
91
+ v_ch = get_v(l, b)
92
+
93
+ # running simulation for verification of results
94
+ qs = QueueingSystemSimulator(1)
95
+ qs.set_servers(params, "H")
96
+ qs.set_sources(l, "M")
97
+ qs.run(num_of_jobs)
98
+ w_sim = qs.w
99
+ p_sim = qs.get_p()
100
+ v_sim = qs.v
101
+
102
+ # outputting the results
103
+ print("M/H2/1")
104
+
105
+ times_print(w_sim, w_ch, True)
106
+ times_print(v_sim, v_ch, False)
107
+ probs_print(p_sim, p_ch, 10)
108
+ ```
109
+
110
+ ### 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)
111
+
112
+ ```python
113
+ n = 5 # number of servers
114
+ k = 3 # number of classes of requests
115
+ l = [0.2, 0.3, 0.4] # service intensities by request classes
116
+ lsum = sum(l)
117
+ num_of_jobs = 300000 # number of jobs for the simulation
118
+
119
+ # Set up the parameters for service times at initial moments.
120
+ # Set average service times by class
121
+ b1 = [0.45 * n, 0.9 * n, 1.35 * n]
122
+
123
+ # Coefficient of variation of service time let's be the same for all classes
124
+ coev = 0.577
125
+
126
+ # second initial moments
127
+ b2 = [0] * k
128
+ for i in range(k):
129
+ b2[i] = (b1[i] ** 2) * (1 + coev ** 2)
130
+
131
+ b_sr = sum(b1) / k
132
+
133
+ # get the coefficient of load
134
+ ro = lsum * b_sr / n
135
+
136
+ # now, given the two initial moments, select parameters for the approximating Gamma distribution
137
+ # and add them to the list of parameters params
138
+ params = []
139
+ for i in range(k):
140
+ params.append(Gamma.get_mu_alpha([b1[i], b2[i]]))
141
+
142
+ b = []
143
+ for j in range(k):
144
+ b.append(Gamma.calc_theory_moments(params[j][0], params[j][1], 4))
145
+
146
+ print("\nComparison of data from the simulation and results calculated using the method of invariant relations (R) \n"
147
+ "time spent in a multi-channel queue with priorities")
148
+ print("Number of servers: " + str(n) + "\nNumber of classes: " + str(k) + "\nCoefficient of load: {0:<1.2f}".format(ro) +
149
+ "\nCoefficient of variation of service time: " + str(coev) + "\n")
150
+ print("PR (Preamptive) priority")
151
+
152
+ # when creating the simulation, pass the number of servers, number of classes and type of priority.
153
+ # PR - absolute with re-service of requests
154
+ qs = PriorityQueueSimulator(n, k, "PR")
155
+
156
+ # to set up sources of requests and service servers, we need to specify a set of dictionaries with fields
157
+ # type - distribution type,
158
+ # params - its parameters.
159
+ # The number of such dictionaries in the lists sources and servers_params corresponds to the number of classes
160
+
161
+ sources = []
162
+ servers_params = []
163
+ for j in range(k):
164
+ sources.append({'type': 'M', 'params': l[j]})
165
+ servers_params.append({'type': 'Gamma', 'params': params[j]})
166
+
167
+ qs.set_sources(sources)
168
+ qs.set_servers(servers_params)
169
+
170
+ # start the simulation
171
+ qs.run(num_of_jobs)
172
+
173
+ # get the initial moments of time spent
174
+
175
+ v_sim = qs.v
176
+
177
+ # calculate them as well using the method of invariant relations (for comparison)
178
+ v_teor = priority_calc.get_v_prty_invar(l, b, n, 'PR')
179
+
180
+ assert abs(v_sim[0][0] - v_teor[0][0]) < 0.3
181
+
182
+ times_print_with_classes(v_sim, v_teor, False)
183
+
184
+ print("NP (Non-preamptive) priority")
185
+
186
+ # The same for relative priority (NP)
187
+ qs = PriorityQueueSimulator(n, k, "NP")
188
+ sources = []
189
+ servers_params = []
190
+ for j in range(k):
191
+ sources.append({'type': 'M', 'params': l[j]})
192
+ servers_params.append({'type': 'Gamma', 'params': params[j]})
193
+
194
+ qs.set_sources(sources)
195
+ qs.set_servers(servers_params)
196
+
197
+ qs.run(num_of_jobs)
198
+
199
+ v_sim = qs.v
200
+
201
+ v_teor = priority_calc.get_v_prty_invar(l, b, n, 'NP')
202
+
203
+ times_print_with_classes(v_sim, v_teor, False)
204
+ ```
205
+
206
+
207
+
208
+
209
+
210
+
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,3 @@
1
+ 1. Change version in pyproject.toml and setup.py
2
+ 2. hatch build
3
+ 3. upload to PyPI: twine upload dist/*