most-queue 1.50__tar.gz → 1.51__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.
- most_queue-1.51/PKG-INFO +270 -0
- most_queue-1.51/README.md +230 -0
- most_queue-1.51/assets/queue_long.png +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/sim/batch_sim.py +2 -3
- {most_queue-1.50 → most_queue-1.51}/most_queue/sim/fj_delta_sim.py +32 -33
- {most_queue-1.50 → most_queue-1.51}/most_queue/sim/fj_sim.py +38 -20
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/fj_calc.py +31 -12
- {most_queue-1.50 → most_queue-1.51}/pyproject.toml +1 -1
- {most_queue-1.50 → most_queue-1.51}/setup.py +1 -1
- {most_queue-1.50 → most_queue-1.51}/tests/test_fj_delta.py +19 -14
- most_queue-1.51/tests/test_fj_im.py +199 -0
- most_queue-1.50/PKG-INFO +0 -250
- most_queue-1.50/README.md +0 -210
- most_queue-1.50/assets/IMPATIENCE.jpg +0 -0
- most_queue-1.50/assets/queue.jpg +0 -0
- most_queue-1.50/assets/queue2.jpg +0 -0
- most_queue-1.50/assets/queue3.jpg +0 -0
- most_queue-1.50/assets/queue4.jpg +0 -0
- most_queue-1.50/assets/queue5.jpg +0 -0
- most_queue-1.50/assets/queue6.jpg +0 -0
- most_queue-1.50/tests/test_fj_im.py +0 -105
- {most_queue-1.50 → most_queue-1.51}/.gitignore +0 -0
- {most_queue-1.50 → most_queue-1.51}/LICENSE +0 -0
- {most_queue-1.50 → most_queue-1.51}/deploy.txt +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/__init__.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/general_utils/__init__.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/general_utils/approx_cdf_make.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/general_utils/conv.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/general_utils/tables.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/general_utils/vacations_paper_utils.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/misc/compare_fj_calc.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/misc/flow_sum.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/misc/test_weibull.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/rand_distribution.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/sim/__init__.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/sim/flow_sum_sim.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/sim/impatient_queue_sim.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/sim/priority_network.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/sim/priority_queue_sim.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/sim/qs_sim.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/sim/queue_finite_source_sim.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/sim/utils/__init__.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/sim/utils/distribution_utils.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/sim/utils/exceptions.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/sim/utils/phase.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/sim/utils/qs_queue.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/sim/utils/servers.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/sim/utils/stats_update.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/sim/utils/tasks.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/__init__.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/batch_mm1.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/ek_d_n_calc.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/engset_model.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/gi_m_1_calc.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/gi_m_n_calc.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/impatience_calc.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/m_d_n_calc.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/m_h2_h2warm.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/m_ph_n_prty.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/mg1_calc.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/mg1_warm_calc.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/mgn_tt.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/mgn_with_h2_delay_cold_warm.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/mmn3_pnz_cox_approx.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/mmn_prty_pnz_approx.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/mmn_with_h2_cold_and_h2_warmup.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/mmnr_calc.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/network_calc.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/network_viewer.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/priority_calc.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/r_example.gexf +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/utils/__init__.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/utils/binom_probs.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/utils/diff5dots.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/utils/flow_sum.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/utils/passage_time.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/utils/q_poisson_arrival_calc.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/utils/student_stat.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/most_queue/theory/utils/weibull.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/requirements.txt +0 -0
- {most_queue-1.50 → most_queue-1.51}/tests/__init__.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/tests/n_test/ro_0.700.json +0 -0
- {most_queue-1.50 → most_queue-1.51}/tests/ro_test/n_3.json +0 -0
- {most_queue-1.50 → most_queue-1.51}/tests/test_batch.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/tests/test_ek_d_n.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/tests/test_engset.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/tests/test_gi_m_1_calc.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/tests/test_gi_m_n_calc.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/tests/test_impatience.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/tests/test_m_d_n_calc.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/tests/test_m_h2_h2warm.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/tests/test_m_ph_n_prty.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/tests/test_mg1_calc.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/tests/test_mgn_tt.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/tests/test_mgn_with_h2_delay_cold_warm.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/tests/test_mmn3_pnz_cox_approx.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/tests/test_mmn_h2cold_h2warm.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/tests/test_mmn_prty_pnz_approx.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/tests/test_network_im_prty.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/tests/test_qs_sim_prty.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/tests/test_qs_sim_test.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/tests/test_queue_types.py +0 -0
- {most_queue-1.50 → most_queue-1.51}/tutorials/m_h2_h2warm.ipynb +0 -0
- {most_queue-1.50 → most_queue-1.51}/tutorials/mgn_takahasi_takami.ipynb +0 -0
- /most_queue-1.50/tutorials/priority queue.ipynb → /most_queue-1.51/tutorials/priority_queue.ipynb +0 -0
- {most_queue-1.50 → most_queue-1.51}/tutorials/queue_sim.ipynb +0 -0
most_queue-1.51/PKG-INFO
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: most_queue
|
|
3
|
+
Version: 1.51
|
|
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
|
+

|
|
44
|
+
|
|
45
|
+
A Python package for simulating and analyzing queueing systems (QS) and networks.
|
|
46
|
+
|
|
47
|
+

|
|
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
|
+
| # | Kendall Notations | Package Name | Description | Example | Tutorial |
|
|
88
|
+
|-----|-------------------|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|-------------------|
|
|
89
|
+
| 1. | M<sup>x</sup>/M/1 | 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) | |
|
|
90
|
+
| 2. | Ek/D/c | 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) | |
|
|
91
|
+
| 3. | M/M/1/N | 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) | |
|
|
92
|
+
| 4. | M/M/c/Fork-Join | fj_calc | Solving for Fork-Join queueing system | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_fj_im.py) | |
|
|
93
|
+
| 5. | GI/M/1 | gi_m_1_calc | Solving for QS GI/M/1 | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_gi_m_1.py) | |
|
|
94
|
+
| 6. | GI/M/c | gi_m_n_calc | Solving for QS GI/M/c | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_gi_m_n.py) | |
|
|
95
|
+
| 7. | M/M/1/D | impatience_calc | Solving for M/M/1 with exponential impatience | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_impatience.py) | |
|
|
96
|
+
| 8. | M/D/c | 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) |
|
|
97
|
+
| 9. | M/H2/c | m_h2_h2warm | Numerical calculation of the M/H2/c system with H2-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)|
|
|
98
|
+
| 10. | M/Ph/c/PR | 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) | |
|
|
99
|
+
| 11. | M/G/1 | mg1_calc | Solving for QS M/G/1 | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_mg1_calc.py) | |
|
|
100
|
+
| 12. | M/G/1 | mg1_warm_calc | Solving for QS M/G/1 with "warm-up" | | |
|
|
101
|
+
| 13. | M/H2/c | mgn_tt | Numerical calculation of QS M/H2/c by the Takahashi-Takami method with complex parameters when approximating the serving time by the H2 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) |
|
|
102
|
+
| 14. | M/Ph/c | mgn_with_h2_delay_cold_warm | 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 | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_mgn_with_h2_delay_cold_warm.py) | |
|
|
103
|
+
| 15. | M/M/c/PR | 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) | |
|
|
104
|
+
| 16. | M/M/c | mmn_with_h2_cold_h2_warmup | 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 | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_mmn_h2cold_h2warm.py) | |
|
|
105
|
+
| 17. | M/M/c/PR | 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) | |
|
|
106
|
+
| 18. | M/M/c/r | 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) |
|
|
107
|
+
| 19. | 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) | |
|
|
108
|
+
| 20. | - | network_viewer | Utility to view network structure | | |
|
|
109
|
+
| 21. | M/G/1 | 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) |
|
|
110
|
+
|
|
111
|
+
### Package most_queue.sim
|
|
112
|
+
|
|
113
|
+
| # | Kendall Notations | Package Name | Description | Example | Tutorial |
|
|
114
|
+
|-----|-------------------|----------------------------|-------------------------------------------------------------------------------------------------|-------------------|-------------------|
|
|
115
|
+
| 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) | |
|
|
116
|
+
| 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) | |
|
|
117
|
+
| 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) | |
|
|
118
|
+
| 4. | - | flow_sum_sim | Simulation of flow summation | | |
|
|
119
|
+
| 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) | |
|
|
120
|
+
| 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) | |
|
|
121
|
+
| 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) |
|
|
122
|
+
| 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) |
|
|
123
|
+
| 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) | |
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
### Usage
|
|
127
|
+
- Look [here](https://github.com/xabarov/most-queue/tree/main/tests) for examples
|
|
128
|
+
- Look [here](https://github.com/xabarov/most-queue/tree/main/tutorials) for jupyter tutorials
|
|
129
|
+
|
|
130
|
+
### Simple example: Calculate M/G/1 queueing system calculation with `most_queue` library. Run simulation and compare results with theory.
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
import numpy as np
|
|
134
|
+
|
|
135
|
+
from most_queue.general_utils.tables import probs_print, times_print
|
|
136
|
+
from most_queue.rand_distribution import H2_dist
|
|
137
|
+
from most_queue.sim.qs_sim import QueueingSystemSimulator
|
|
138
|
+
from most_queue.theory.mg1_calc import get_p, get_v, get_w
|
|
139
|
+
|
|
140
|
+
l = 1 # input flow intensity
|
|
141
|
+
b1 = 0.7 # average service time
|
|
142
|
+
coev = 1.2 # coefficient of variation of service time
|
|
143
|
+
num_of_jobs = 1000000 # number of jobs for simulation
|
|
144
|
+
|
|
145
|
+
# selecting parameters of the approximating H2-distribution for service time [y1, mu1, mu2]:
|
|
146
|
+
params = H2_dist.get_params_by_mean_and_coev(b1, coev)
|
|
147
|
+
b = H2_dist.calc_theory_moments(*params, 4)
|
|
148
|
+
|
|
149
|
+
# calculation using numerical methods
|
|
150
|
+
w_ch = get_w(l, b)
|
|
151
|
+
p_ch = get_p(l, b, 100)
|
|
152
|
+
v_ch = get_v(l, b)
|
|
153
|
+
|
|
154
|
+
# running simulation for verification of results
|
|
155
|
+
qs = QueueingSystemSimulator(1)
|
|
156
|
+
qs.set_servers(params, "H")
|
|
157
|
+
qs.set_sources(l, "M")
|
|
158
|
+
qs.run(num_of_jobs)
|
|
159
|
+
w_sim = qs.w
|
|
160
|
+
p_sim = qs.get_p()
|
|
161
|
+
v_sim = qs.v
|
|
162
|
+
|
|
163
|
+
# outputting the results
|
|
164
|
+
print("M/H2/1")
|
|
165
|
+
|
|
166
|
+
times_print(w_sim, w_ch, True)
|
|
167
|
+
times_print(v_sim, v_ch, False)
|
|
168
|
+
probs_print(p_sim, p_ch, 10)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### 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)
|
|
172
|
+
|
|
173
|
+
```python
|
|
174
|
+
n = 5 # number of servers
|
|
175
|
+
k = 3 # number of classes of requests
|
|
176
|
+
l = [0.2, 0.3, 0.4] # service intensities by request classes
|
|
177
|
+
lsum = sum(l)
|
|
178
|
+
num_of_jobs = 300000 # number of jobs for the simulation
|
|
179
|
+
|
|
180
|
+
# Set up the parameters for service times at initial moments.
|
|
181
|
+
# Set average service times by class
|
|
182
|
+
b1 = [0.45 * n, 0.9 * n, 1.35 * n]
|
|
183
|
+
|
|
184
|
+
# Coefficient of variation of service time let's be the same for all classes
|
|
185
|
+
coev = 0.577
|
|
186
|
+
|
|
187
|
+
# second initial moments
|
|
188
|
+
b2 = [0] * k
|
|
189
|
+
for i in range(k):
|
|
190
|
+
b2[i] = (b1[i] ** 2) * (1 + coev ** 2)
|
|
191
|
+
|
|
192
|
+
b_sr = sum(b1) / k
|
|
193
|
+
|
|
194
|
+
# get the coefficient of load
|
|
195
|
+
ro = lsum * b_sr / n
|
|
196
|
+
|
|
197
|
+
# now, given the two initial moments, select parameters for the approximating Gamma distribution
|
|
198
|
+
# and add them to the list of parameters params
|
|
199
|
+
params = []
|
|
200
|
+
for i in range(k):
|
|
201
|
+
params.append(Gamma.get_mu_alpha([b1[i], b2[i]]))
|
|
202
|
+
|
|
203
|
+
b = []
|
|
204
|
+
for j in range(k):
|
|
205
|
+
b.append(Gamma.calc_theory_moments(params[j][0], params[j][1], 4))
|
|
206
|
+
|
|
207
|
+
print("\nComparison of data from the simulation and results calculated using the method of invariant relations (R) \n"
|
|
208
|
+
"time spent in a multi-channel queue with priorities")
|
|
209
|
+
print("Number of servers: " + str(n) + "\nNumber of classes: " + str(k) + "\nCoefficient of load: {0:<1.2f}".format(ro) +
|
|
210
|
+
"\nCoefficient of variation of service time: " + str(coev) + "\n")
|
|
211
|
+
print("PR (Preamptive) priority")
|
|
212
|
+
|
|
213
|
+
# when creating the simulation, pass the number of servers, number of classes and type of priority.
|
|
214
|
+
# PR - absolute with re-service of requests
|
|
215
|
+
qs = PriorityQueueSimulator(n, k, "PR")
|
|
216
|
+
|
|
217
|
+
# to set up sources of requests and service servers, we need to specify a set of dictionaries with fields
|
|
218
|
+
# type - distribution type,
|
|
219
|
+
# params - its parameters.
|
|
220
|
+
# The number of such dictionaries in the lists sources and servers_params corresponds to the number of classes
|
|
221
|
+
|
|
222
|
+
sources = []
|
|
223
|
+
servers_params = []
|
|
224
|
+
for j in range(k):
|
|
225
|
+
sources.append({'type': 'M', 'params': l[j]})
|
|
226
|
+
servers_params.append({'type': 'Gamma', 'params': params[j]})
|
|
227
|
+
|
|
228
|
+
qs.set_sources(sources)
|
|
229
|
+
qs.set_servers(servers_params)
|
|
230
|
+
|
|
231
|
+
# start the simulation
|
|
232
|
+
qs.run(num_of_jobs)
|
|
233
|
+
|
|
234
|
+
# get the initial moments of time spent
|
|
235
|
+
|
|
236
|
+
v_sim = qs.v
|
|
237
|
+
|
|
238
|
+
# calculate them as well using the method of invariant relations (for comparison)
|
|
239
|
+
v_teor = priority_calc.get_v_prty_invar(l, b, n, 'PR')
|
|
240
|
+
|
|
241
|
+
assert abs(v_sim[0][0] - v_teor[0][0]) < 0.3
|
|
242
|
+
|
|
243
|
+
times_print_with_classes(v_sim, v_teor, False)
|
|
244
|
+
|
|
245
|
+
print("NP (Non-preamptive) priority")
|
|
246
|
+
|
|
247
|
+
# The same for relative priority (NP)
|
|
248
|
+
qs = PriorityQueueSimulator(n, k, "NP")
|
|
249
|
+
sources = []
|
|
250
|
+
servers_params = []
|
|
251
|
+
for j in range(k):
|
|
252
|
+
sources.append({'type': 'M', 'params': l[j]})
|
|
253
|
+
servers_params.append({'type': 'Gamma', 'params': params[j]})
|
|
254
|
+
|
|
255
|
+
qs.set_sources(sources)
|
|
256
|
+
qs.set_servers(servers_params)
|
|
257
|
+
|
|
258
|
+
qs.run(num_of_jobs)
|
|
259
|
+
|
|
260
|
+
v_sim = qs.v
|
|
261
|
+
|
|
262
|
+
v_teor = priority_calc.get_v_prty_invar(l, b, n, 'NP')
|
|
263
|
+
|
|
264
|
+
times_print_with_classes(v_sim, v_teor, False)
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### References
|
|
268
|
+
- [(Ryzhikov Y.I. *Computational Methods*. BHV-Petersburg, 2007.)](https://www.litres.ru/book/uriy-ryzhikov/vychislitelnye-metody-uchebnoe-posobie-644835/)
|
|
269
|
+
|
|
270
|
+
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# Queueing Systems: Simulation & Numerical Methods
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
A Python package for simulating and analyzing queueing systems (QS) and networks.
|
|
6
|
+
|
|
7
|
+

|
|
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
|
+
| # | Kendall Notations | Package Name | Description | Example | Tutorial |
|
|
48
|
+
|-----|-------------------|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|-------------------|
|
|
49
|
+
| 1. | M<sup>x</sup>/M/1 | 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) | |
|
|
50
|
+
| 2. | Ek/D/c | 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) | |
|
|
51
|
+
| 3. | M/M/1/N | 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) | |
|
|
52
|
+
| 4. | M/M/c/Fork-Join | fj_calc | Solving for Fork-Join queueing system | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_fj_im.py) | |
|
|
53
|
+
| 5. | GI/M/1 | gi_m_1_calc | Solving for QS GI/M/1 | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_gi_m_1.py) | |
|
|
54
|
+
| 6. | GI/M/c | gi_m_n_calc | Solving for QS GI/M/c | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_gi_m_n.py) | |
|
|
55
|
+
| 7. | M/M/1/D | impatience_calc | Solving for M/M/1 with exponential impatience | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_impatience.py) | |
|
|
56
|
+
| 8. | M/D/c | 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) |
|
|
57
|
+
| 9. | M/H2/c | m_h2_h2warm | Numerical calculation of the M/H2/c system with H2-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)|
|
|
58
|
+
| 10. | M/Ph/c/PR | 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) | |
|
|
59
|
+
| 11. | M/G/1 | mg1_calc | Solving for QS M/G/1 | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_mg1_calc.py) | |
|
|
60
|
+
| 12. | M/G/1 | mg1_warm_calc | Solving for QS M/G/1 with "warm-up" | | |
|
|
61
|
+
| 13. | M/H2/c | mgn_tt | Numerical calculation of QS M/H2/c by the Takahashi-Takami method with complex parameters when approximating the serving time by the H2 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) |
|
|
62
|
+
| 14. | M/Ph/c | mgn_with_h2_delay_cold_warm | 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 | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_mgn_with_h2_delay_cold_warm.py) | |
|
|
63
|
+
| 15. | M/M/c/PR | 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) | |
|
|
64
|
+
| 16. | M/M/c | mmn_with_h2_cold_h2_warmup | 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 | [link](https://github.com/xabarov/most-queue/blob/main/tests/test_mmn_h2cold_h2warm.py) | |
|
|
65
|
+
| 17. | M/M/c/PR | 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) | |
|
|
66
|
+
| 18. | M/M/c/r | 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) |
|
|
67
|
+
| 19. | 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) | |
|
|
68
|
+
| 20. | - | network_viewer | Utility to view network structure | | |
|
|
69
|
+
| 21. | M/G/1 | 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) |
|
|
70
|
+
|
|
71
|
+
### Package most_queue.sim
|
|
72
|
+
|
|
73
|
+
| # | Kendall Notations | Package Name | Description | Example | Tutorial |
|
|
74
|
+
|-----|-------------------|----------------------------|-------------------------------------------------------------------------------------------------|-------------------|-------------------|
|
|
75
|
+
| 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) | |
|
|
76
|
+
| 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) | |
|
|
77
|
+
| 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) | |
|
|
78
|
+
| 4. | - | flow_sum_sim | Simulation of flow summation | | |
|
|
79
|
+
| 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) | |
|
|
80
|
+
| 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) | |
|
|
81
|
+
| 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) |
|
|
82
|
+
| 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) |
|
|
83
|
+
| 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) | |
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
### Usage
|
|
87
|
+
- Look [here](https://github.com/xabarov/most-queue/tree/main/tests) for examples
|
|
88
|
+
- Look [here](https://github.com/xabarov/most-queue/tree/main/tutorials) for jupyter tutorials
|
|
89
|
+
|
|
90
|
+
### Simple example: Calculate M/G/1 queueing system calculation with `most_queue` library. Run simulation and compare results with theory.
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
import numpy as np
|
|
94
|
+
|
|
95
|
+
from most_queue.general_utils.tables import probs_print, times_print
|
|
96
|
+
from most_queue.rand_distribution import H2_dist
|
|
97
|
+
from most_queue.sim.qs_sim import QueueingSystemSimulator
|
|
98
|
+
from most_queue.theory.mg1_calc import get_p, get_v, get_w
|
|
99
|
+
|
|
100
|
+
l = 1 # input flow intensity
|
|
101
|
+
b1 = 0.7 # average service time
|
|
102
|
+
coev = 1.2 # coefficient of variation of service time
|
|
103
|
+
num_of_jobs = 1000000 # number of jobs for simulation
|
|
104
|
+
|
|
105
|
+
# selecting parameters of the approximating H2-distribution for service time [y1, mu1, mu2]:
|
|
106
|
+
params = H2_dist.get_params_by_mean_and_coev(b1, coev)
|
|
107
|
+
b = H2_dist.calc_theory_moments(*params, 4)
|
|
108
|
+
|
|
109
|
+
# calculation using numerical methods
|
|
110
|
+
w_ch = get_w(l, b)
|
|
111
|
+
p_ch = get_p(l, b, 100)
|
|
112
|
+
v_ch = get_v(l, b)
|
|
113
|
+
|
|
114
|
+
# running simulation for verification of results
|
|
115
|
+
qs = QueueingSystemSimulator(1)
|
|
116
|
+
qs.set_servers(params, "H")
|
|
117
|
+
qs.set_sources(l, "M")
|
|
118
|
+
qs.run(num_of_jobs)
|
|
119
|
+
w_sim = qs.w
|
|
120
|
+
p_sim = qs.get_p()
|
|
121
|
+
v_sim = qs.v
|
|
122
|
+
|
|
123
|
+
# outputting the results
|
|
124
|
+
print("M/H2/1")
|
|
125
|
+
|
|
126
|
+
times_print(w_sim, w_ch, True)
|
|
127
|
+
times_print(v_sim, v_ch, False)
|
|
128
|
+
probs_print(p_sim, p_ch, 10)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### 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)
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
n = 5 # number of servers
|
|
135
|
+
k = 3 # number of classes of requests
|
|
136
|
+
l = [0.2, 0.3, 0.4] # service intensities by request classes
|
|
137
|
+
lsum = sum(l)
|
|
138
|
+
num_of_jobs = 300000 # number of jobs for the simulation
|
|
139
|
+
|
|
140
|
+
# Set up the parameters for service times at initial moments.
|
|
141
|
+
# Set average service times by class
|
|
142
|
+
b1 = [0.45 * n, 0.9 * n, 1.35 * n]
|
|
143
|
+
|
|
144
|
+
# Coefficient of variation of service time let's be the same for all classes
|
|
145
|
+
coev = 0.577
|
|
146
|
+
|
|
147
|
+
# second initial moments
|
|
148
|
+
b2 = [0] * k
|
|
149
|
+
for i in range(k):
|
|
150
|
+
b2[i] = (b1[i] ** 2) * (1 + coev ** 2)
|
|
151
|
+
|
|
152
|
+
b_sr = sum(b1) / k
|
|
153
|
+
|
|
154
|
+
# get the coefficient of load
|
|
155
|
+
ro = lsum * b_sr / n
|
|
156
|
+
|
|
157
|
+
# now, given the two initial moments, select parameters for the approximating Gamma distribution
|
|
158
|
+
# and add them to the list of parameters params
|
|
159
|
+
params = []
|
|
160
|
+
for i in range(k):
|
|
161
|
+
params.append(Gamma.get_mu_alpha([b1[i], b2[i]]))
|
|
162
|
+
|
|
163
|
+
b = []
|
|
164
|
+
for j in range(k):
|
|
165
|
+
b.append(Gamma.calc_theory_moments(params[j][0], params[j][1], 4))
|
|
166
|
+
|
|
167
|
+
print("\nComparison of data from the simulation and results calculated using the method of invariant relations (R) \n"
|
|
168
|
+
"time spent in a multi-channel queue with priorities")
|
|
169
|
+
print("Number of servers: " + str(n) + "\nNumber of classes: " + str(k) + "\nCoefficient of load: {0:<1.2f}".format(ro) +
|
|
170
|
+
"\nCoefficient of variation of service time: " + str(coev) + "\n")
|
|
171
|
+
print("PR (Preamptive) priority")
|
|
172
|
+
|
|
173
|
+
# when creating the simulation, pass the number of servers, number of classes and type of priority.
|
|
174
|
+
# PR - absolute with re-service of requests
|
|
175
|
+
qs = PriorityQueueSimulator(n, k, "PR")
|
|
176
|
+
|
|
177
|
+
# to set up sources of requests and service servers, we need to specify a set of dictionaries with fields
|
|
178
|
+
# type - distribution type,
|
|
179
|
+
# params - its parameters.
|
|
180
|
+
# The number of such dictionaries in the lists sources and servers_params corresponds to the number of classes
|
|
181
|
+
|
|
182
|
+
sources = []
|
|
183
|
+
servers_params = []
|
|
184
|
+
for j in range(k):
|
|
185
|
+
sources.append({'type': 'M', 'params': l[j]})
|
|
186
|
+
servers_params.append({'type': 'Gamma', 'params': params[j]})
|
|
187
|
+
|
|
188
|
+
qs.set_sources(sources)
|
|
189
|
+
qs.set_servers(servers_params)
|
|
190
|
+
|
|
191
|
+
# start the simulation
|
|
192
|
+
qs.run(num_of_jobs)
|
|
193
|
+
|
|
194
|
+
# get the initial moments of time spent
|
|
195
|
+
|
|
196
|
+
v_sim = qs.v
|
|
197
|
+
|
|
198
|
+
# calculate them as well using the method of invariant relations (for comparison)
|
|
199
|
+
v_teor = priority_calc.get_v_prty_invar(l, b, n, 'PR')
|
|
200
|
+
|
|
201
|
+
assert abs(v_sim[0][0] - v_teor[0][0]) < 0.3
|
|
202
|
+
|
|
203
|
+
times_print_with_classes(v_sim, v_teor, False)
|
|
204
|
+
|
|
205
|
+
print("NP (Non-preamptive) priority")
|
|
206
|
+
|
|
207
|
+
# The same for relative priority (NP)
|
|
208
|
+
qs = PriorityQueueSimulator(n, k, "NP")
|
|
209
|
+
sources = []
|
|
210
|
+
servers_params = []
|
|
211
|
+
for j in range(k):
|
|
212
|
+
sources.append({'type': 'M', 'params': l[j]})
|
|
213
|
+
servers_params.append({'type': 'Gamma', 'params': params[j]})
|
|
214
|
+
|
|
215
|
+
qs.set_sources(sources)
|
|
216
|
+
qs.set_servers(servers_params)
|
|
217
|
+
|
|
218
|
+
qs.run(num_of_jobs)
|
|
219
|
+
|
|
220
|
+
v_sim = qs.v
|
|
221
|
+
|
|
222
|
+
v_teor = priority_calc.get_v_prty_invar(l, b, n, 'NP')
|
|
223
|
+
|
|
224
|
+
times_print_with_classes(v_sim, v_teor, False)
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### References
|
|
228
|
+
- [(Ryzhikov Y.I. *Computational Methods*. BHV-Petersburg, 2007.)](https://www.litres.ru/book/uriy-ryzhikov/vychislitelnye-metody-uchebnoe-posobie-644835/)
|
|
229
|
+
|
|
230
|
+
|
|
Binary file
|
|
@@ -10,7 +10,6 @@ class QueueingSystemBatchSim(QueueingSystemSimulator):
|
|
|
10
10
|
"""
|
|
11
11
|
Queueing system with batch arrivals.
|
|
12
12
|
"""
|
|
13
|
-
|
|
14
13
|
def __init__(self, num_of_channels,
|
|
15
14
|
batch_prob,
|
|
16
15
|
buffer=None, verbose=True):
|
|
@@ -59,7 +58,7 @@ class QueueingSystemBatchSim(QueueingSystemSimulator):
|
|
|
59
58
|
self.in_sys += 1
|
|
60
59
|
|
|
61
60
|
if self.free_channels == 0:
|
|
62
|
-
if self.buffer is None: #
|
|
61
|
+
if self.buffer is None: # infinite buffer
|
|
63
62
|
new_tsk = Task(self.ttek)
|
|
64
63
|
new_tsk.start_waiting_time = self.ttek
|
|
65
64
|
self.queue.append(new_tsk)
|
|
@@ -86,7 +85,7 @@ class QueueingSystemBatchSim(QueueingSystemSimulator):
|
|
|
86
85
|
self.ttek, is_warm_start)
|
|
87
86
|
self.free_channels -= 1
|
|
88
87
|
|
|
89
|
-
#
|
|
88
|
+
# Check if busy period has started:
|
|
90
89
|
if self.free_channels == 0:
|
|
91
90
|
if self.in_sys == self.n:
|
|
92
91
|
self.start_busy = self.ttek
|