most-queue 1.44__tar.gz → 1.46__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 (95) hide show
  1. {most_queue-1.44 → most_queue-1.46}/PKG-INFO +78 -15
  2. {most_queue-1.44 → most_queue-1.46}/README.md +73 -13
  3. {most_queue-1.44 → most_queue-1.46}/most_queue/sim/batch_sim.py +8 -8
  4. {most_queue-1.44 → most_queue-1.46}/most_queue/sim/fj_delta_sim.py +37 -23
  5. {most_queue-1.44 → most_queue-1.46}/most_queue/sim/fj_sim.py +58 -36
  6. {most_queue-1.44 → most_queue-1.46}/most_queue/sim/impatient_queue_sim.py +71 -30
  7. most_queue-1.46/most_queue/sim/priority_network.py +228 -0
  8. most_queue-1.46/most_queue/sim/priority_queue_sim.py +725 -0
  9. most_queue-1.46/most_queue/sim/qs_sim.py +563 -0
  10. most_queue-1.46/most_queue/sim/queue_finite_source_sim.py +244 -0
  11. {most_queue-1.44 → most_queue-1.46}/most_queue/sim/utils/distribution_utils.py +30 -0
  12. {most_queue-1.44 → most_queue-1.46}/most_queue/sim/utils/phase.py +27 -0
  13. most_queue-1.46/most_queue/sim/utils/servers.py +219 -0
  14. most_queue-1.46/most_queue/sim/utils/stats_update.py +16 -0
  15. most_queue-1.46/most_queue/sim/utils/tasks.py +117 -0
  16. {most_queue-1.44/most_queue/tests → most_queue-1.46/most_queue/theory}/__init__.py +0 -0
  17. {most_queue-1.44 → most_queue-1.46}/most_queue/theory/batch_mm1.py +4 -6
  18. {most_queue-1.44 → most_queue-1.46}/most_queue/theory/ek_d_n_calc.py +53 -43
  19. {most_queue-1.44 → most_queue-1.46}/most_queue/theory/mmn3_pnz_cox_approx.py +2 -2
  20. {most_queue-1.44 → most_queue-1.46}/most_queue/theory/priority_calc.py +8 -8
  21. {most_queue-1.44/most_queue/theory → most_queue-1.46/most_queue/theory/utils}/__init__.py +0 -0
  22. {most_queue-1.44 → most_queue-1.46}/most_queue/theory/utils/passage_time.py +5 -5
  23. {most_queue-1.44 → most_queue-1.46}/most_queue.egg-info/PKG-INFO +78 -15
  24. {most_queue-1.44 → most_queue-1.46}/most_queue.egg-info/SOURCES.txt +24 -23
  25. {most_queue-1.44 → most_queue-1.46}/most_queue.egg-info/top_level.txt +1 -0
  26. {most_queue-1.44 → most_queue-1.46}/pyproject.toml +1 -1
  27. {most_queue-1.44 → most_queue-1.46}/setup.py +2 -2
  28. most_queue-1.46/tests/test_ek_d_n.py +73 -0
  29. {most_queue-1.44/most_queue → most_queue-1.46}/tests/test_fj_delta.py +1 -0
  30. {most_queue-1.44/most_queue → most_queue-1.46}/tests/test_impatience.py +1 -3
  31. {most_queue-1.44/most_queue → most_queue-1.46}/tests/test_mgn_with_h2_delay_cold_warm.py +11 -11
  32. {most_queue-1.44/most_queue → most_queue-1.46}/tests/test_mmn_h2cold_h2warm.py +1 -1
  33. {most_queue-1.44/most_queue → most_queue-1.46}/tests/test_network_im_prty.py +1 -1
  34. {most_queue-1.44/most_queue → most_queue-1.46}/tests/test_qs_sim_prty.py +2 -4
  35. most_queue-1.44/most_queue/sim/priority_network.py +0 -160
  36. most_queue-1.44/most_queue/sim/priority_queue_sim.py +0 -782
  37. most_queue-1.44/most_queue/sim/qs_sim.py +0 -627
  38. most_queue-1.44/most_queue/sim/queue_finite_source_sim.py +0 -247
  39. most_queue-1.44/most_queue/sim/utils/servers.py +0 -113
  40. most_queue-1.44/most_queue/sim/utils/tasks.py +0 -70
  41. most_queue-1.44/most_queue/tests/test_ek_d_n.py +0 -72
  42. {most_queue-1.44 → most_queue-1.46}/LICENSE +0 -0
  43. {most_queue-1.44 → most_queue-1.46}/most_queue/__init__.py +0 -0
  44. {most_queue-1.44 → most_queue-1.46}/most_queue/general_utils/__init__.py +0 -0
  45. {most_queue-1.44 → most_queue-1.46}/most_queue/general_utils/approx_cdf_make.py +0 -0
  46. {most_queue-1.44 → most_queue-1.46}/most_queue/general_utils/conv.py +0 -0
  47. {most_queue-1.44 → most_queue-1.46}/most_queue/general_utils/tables.py +0 -0
  48. {most_queue-1.44 → most_queue-1.46}/most_queue/general_utils/vacations_paper_utils.py +0 -0
  49. {most_queue-1.44 → most_queue-1.46}/most_queue/rand_distribution.py +0 -0
  50. {most_queue-1.44 → most_queue-1.46}/most_queue/sim/__init__.py +0 -0
  51. {most_queue-1.44 → most_queue-1.46}/most_queue/sim/flow_sum_sim.py +0 -0
  52. {most_queue-1.44 → most_queue-1.46}/most_queue/sim/utils/__init__.py +0 -0
  53. {most_queue-1.44 → most_queue-1.46}/most_queue/sim/utils/exceptions.py +0 -0
  54. {most_queue-1.44 → most_queue-1.46}/most_queue/sim/utils/qs_queue.py +0 -0
  55. {most_queue-1.44 → most_queue-1.46}/most_queue/theory/engset_model.py +0 -0
  56. {most_queue-1.44 → most_queue-1.46}/most_queue/theory/fj_calc.py +0 -0
  57. {most_queue-1.44 → most_queue-1.46}/most_queue/theory/gi_m_1_calc.py +0 -0
  58. {most_queue-1.44 → most_queue-1.46}/most_queue/theory/gi_m_n_calc.py +0 -0
  59. {most_queue-1.44 → most_queue-1.46}/most_queue/theory/impatience_calc.py +0 -0
  60. {most_queue-1.44 → most_queue-1.46}/most_queue/theory/m_d_n_calc.py +0 -0
  61. {most_queue-1.44 → most_queue-1.46}/most_queue/theory/m_h2_h2warm.py +0 -0
  62. {most_queue-1.44 → most_queue-1.46}/most_queue/theory/m_ph_n_prty.py +0 -0
  63. {most_queue-1.44 → most_queue-1.46}/most_queue/theory/mg1_calc.py +0 -0
  64. {most_queue-1.44 → most_queue-1.46}/most_queue/theory/mg1_warm_calc.py +0 -0
  65. {most_queue-1.44 → most_queue-1.46}/most_queue/theory/mgn_tt.py +0 -0
  66. {most_queue-1.44 → most_queue-1.46}/most_queue/theory/mgn_with_h2_delay_cold_warm.py +0 -0
  67. {most_queue-1.44 → most_queue-1.46}/most_queue/theory/mmn_prty_pnz_approx.py +0 -0
  68. {most_queue-1.44 → most_queue-1.46}/most_queue/theory/mmn_with_h2_cold_and_h2_warmup.py +0 -0
  69. {most_queue-1.44 → most_queue-1.46}/most_queue/theory/mmnr_calc.py +0 -0
  70. {most_queue-1.44 → most_queue-1.46}/most_queue/theory/network_calc.py +0 -0
  71. {most_queue-1.44 → most_queue-1.46}/most_queue/theory/network_viewer.py +0 -0
  72. {most_queue-1.44 → most_queue-1.46}/most_queue/theory/utils/binom_probs.py +0 -0
  73. {most_queue-1.44 → most_queue-1.46}/most_queue/theory/utils/diff5dots.py +0 -0
  74. {most_queue-1.44 → most_queue-1.46}/most_queue/theory/utils/flow_sum.py +0 -0
  75. {most_queue-1.44 → most_queue-1.46}/most_queue/theory/utils/q_poisson_arrival_calc.py +0 -0
  76. {most_queue-1.44 → most_queue-1.46}/most_queue/theory/utils/student_stat.py +0 -0
  77. {most_queue-1.44 → most_queue-1.46}/most_queue/theory/utils/weibull.py +0 -0
  78. {most_queue-1.44 → most_queue-1.46}/most_queue.egg-info/dependency_links.txt +0 -0
  79. {most_queue-1.44 → most_queue-1.46}/most_queue.egg-info/not-zip-safe +0 -0
  80. {most_queue-1.44 → most_queue-1.46}/setup.cfg +0 -0
  81. {most_queue-1.44/most_queue/theory/utils → most_queue-1.46/tests}/__init__.py +0 -0
  82. {most_queue-1.44/most_queue → most_queue-1.46}/tests/test_batch.py +0 -0
  83. {most_queue-1.44/most_queue → most_queue-1.46}/tests/test_engset.py +0 -0
  84. {most_queue-1.44/most_queue → most_queue-1.46}/tests/test_fj_im.py +0 -0
  85. {most_queue-1.44/most_queue → most_queue-1.46}/tests/test_gi_m_1_calc.py +0 -0
  86. {most_queue-1.44/most_queue → most_queue-1.46}/tests/test_gi_m_n_calc.py +0 -0
  87. {most_queue-1.44/most_queue → most_queue-1.46}/tests/test_m_d_n_calc.py +0 -0
  88. {most_queue-1.44/most_queue → most_queue-1.46}/tests/test_m_h2_h2warm.py +0 -0
  89. {most_queue-1.44/most_queue → most_queue-1.46}/tests/test_m_ph_n_prty.py +0 -0
  90. {most_queue-1.44/most_queue → most_queue-1.46}/tests/test_mg1_calc.py +0 -0
  91. {most_queue-1.44/most_queue → most_queue-1.46}/tests/test_mgn_tt.py +0 -0
  92. {most_queue-1.44/most_queue → most_queue-1.46}/tests/test_mmn3_pnz_cox_approx.py +0 -0
  93. {most_queue-1.44/most_queue → most_queue-1.46}/tests/test_mmn_prty_pnz_approx.py +0 -0
  94. {most_queue-1.44/most_queue → most_queue-1.46}/tests/test_qs_sim_test.py +0 -0
  95. {most_queue-1.44/most_queue → most_queue-1.46}/tests/test_queue_types.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: most_queue
3
- Version: 1.44
3
+ Version: 1.46
4
4
  Summary: Software package for calculation and simulation of queuing systems
5
5
  Home-page: https://github.com/xabarov/most-queue
6
6
  Author: Xabarov Roman
@@ -31,9 +31,19 @@ Classifier: Operating System :: OS Independent
31
31
  Requires-Python: >=3.7
32
32
  Description-Content-Type: text/markdown
33
33
  License-File: LICENSE
34
+ Dynamic: author
35
+ Dynamic: home-page
36
+ Dynamic: license-file
34
37
 
35
- # most_queue
36
- Python package for calculation and simulation of queuing systems (QS) and networks
38
+ # Queueing systems. Simulation and numerical methods of queuing theory
39
+
40
+ ![Queue](assets/queue6.jpg)
41
+
42
+ Python package for calculation and simulation of queueing systems (QS) and networks.
43
+ Queueing theory. Numerical methods.
44
+
45
+ Пакет python для расчета и моделирования систем массового обслуживания (СМО) и сетей (СеМО).
46
+ Теория массового обслуживания. Численные методы.
37
47
 
38
48
  ## Authors
39
49
  - [xabarov](https://github.com/xabarov)
@@ -42,12 +52,15 @@ Python package for calculation and simulation of queuing systems (QS) and networ
42
52
  Install most-queue with pip
43
53
  ```bash
44
54
  pip install most-queue
55
+ pip install -r requirements.txt
45
56
  ```
46
57
 
47
58
  ## DESCRIPTION
48
59
  Most_queue consists of two main parts:
49
60
  - **.theory** contains programs that implement methods for calculating queuing theory models.
50
61
  - **.sim** contains simulation programs.
62
+ - **.tests** contains tests.
63
+ - **.rand_distribution** - A set of functions and classes designed to generate a random values and select parameters for distributions like H2, C2, Ek, Pa, Gamma
51
64
 
52
65
  ### Package .theory
53
66
  | # | Package name | Description |
@@ -85,16 +98,66 @@ Most_queue consists of two main parts:
85
98
  | 1. | fj_delta_sim | Simulation of QS fork-join with a delay in the start of processing between channels |
86
99
  | 2. | fj_sim | Simulation of QS with fork-join process |
87
100
  | 3. | priority_network | Simulation of queuing network with priorities in nodes |
88
- | 4. | rand_distribution | A set of functions and classes designed to generate a PRNG and select parameters for distributions H2, C2, Ek, Pa, Gamma |
89
- | 5. | qs_sim | Simulation of QS GI/G/m/n |
90
- | 6. | priority_queue_sim | Simulation of QS GI/G/m/n with priorities |
91
- | 7. | flow_sum_sim | Simulation of flow summation |
92
- | 8. | impatient_sim.py | Simulation of QS GI/G/m/n with impatience |
93
- | 9. | batch_sim.py | Simulation of QS GI/G/m/n with batch arrival |
94
- | 10. | queue_finite_source_sim.py | Simulation of QS GI/G/m/n with finite sources |
101
+ | 4. | qs_sim | Simulation of QS GI/G/m/n |
102
+ | 5. | priority_queue_sim | Simulation of QS GI/G/m/n with priorities |
103
+ | 6. | flow_sum_sim | Simulation of flow summation |
104
+ | 7. | impatient_sim.py | Simulation of QS GI/G/m/n with impatience |
105
+ | 8. | batch_sim.py | Simulation of QS GI/G/m/n with batch arrival |
106
+ | 9. | queue_finite_source_sim.py | Simulation of QS GI/G/m/n with finite sources |
95
107
 
96
108
  ## Usage
97
- - Look [here](https://github.com/xabarov/most-queue/tree/main/most_queue/pytests) for examples
109
+ - Look [here](https://github.com/xabarov/most-queue/tree/main/most_queue/tests) for examples
110
+ - Look [here](https://github.com/xabarov/most-queue/tree/main/most_queue/tutorials) for jupyter tutorials
111
+
112
+ - Simple example: numeric calc for M/G/1 QS. Run simulation for verification
113
+
114
+ ```python
115
+
116
+ import numpy as np
117
+
118
+ from most_queue.general_utils.tables import probs_print, times_print
119
+ from most_queue.rand_distribution import H2_dist, Pareto_dist, Uniform_dist
120
+ from most_queue.sim.qs_sim import QueueingSystemSimulator
121
+ from most_queue.theory.mg1_calc import get_p, get_v, get_w
122
+
123
+
124
+ """
125
+ Test QS M/G/1
126
+ """
127
+ arrival_lambda = 1 # arrival intensity
128
+ b1 = 0.7 # mean serving time
129
+ coev = 1.2 # standard deviation of serving time
130
+ num_of_jobs = 1000000 # jobs num for simulation
131
+
132
+ # get of parameters of the approximating H2-distribution for service time [y1, mu1, mu2]:
133
+ params = H2_dist.get_params_by_mean_and_coev(b1, coev)
134
+ b = H2_dist.calc_theory_moments(*params, 4)
135
+
136
+ # get wait moments, sojourn time, probs by numeric calc
137
+ w_ch = get_w(arrival_lambda, b)
138
+ v_ch = get_v(arrival_lambda, b)
139
+ p_ch = get_p(arrival_lambda, b, 100)
140
+
141
+ # run simulation for verification
142
+ qs = QueueingSystemSimulator(1) # 1 - num of channels
143
+
144
+ qs.set_servers(params, "H")
145
+ qs.set_sources(arrival_lambda, "M")
146
+
147
+ qs.run(num_of_jobs)
148
+
149
+ # get sim results
150
+ w_sim = qs.w
151
+ p_sim = qs.get_p()
152
+ v_sim = qs.v
153
+
154
+ print("M/H2/1")
155
+
156
+ times_print(w_sim, w_ch, True)
157
+ times_print(v_sim, v_ch, False)
158
+ probs_print(p_sim, p_ch, 10)
159
+
160
+ ```
98
161
 
99
162
  - As an example, we will provide the code for сomparison of calculation results by the Takahashi-Takami and Simulation.
100
163
 
@@ -102,10 +165,10 @@ Most_queue consists of two main parts:
102
165
 
103
166
  import math
104
167
  from most_queue.sim.qs_sim import QueueingSystemSimulator
105
- from most_queue.sim import rand_destribution as rd
168
+ from most_queue.rand_distribution import Gamma
106
169
  import time
107
170
  from most_queue.theory.mgn_tt import MGnCalc
108
- from most_queue.utils.tables import probs_print, times_print
171
+ from most_queue.general_utils.tables import probs_print, times_print
109
172
 
110
173
  n = 3 # number of channels
111
174
  l = 1.0 # input flow intensity
@@ -147,7 +210,7 @@ Most_queue consists of two main parts:
147
210
 
148
211
  # We set the parameters of the service channels using Gamma distribution.
149
212
  # Select the distribution parameters
150
- gamma_params = rd.Gamma.get_mu_alpha([b[0], b[1]])
213
+ gamma_params = Gamma.get_mu_alpha([b[0], b[1]])
151
214
  qs.set_servers(gamma_params, 'Gamma')
152
215
 
153
216
  # Run simulation
@@ -1,5 +1,12 @@
1
- # most_queue
2
- Python package for calculation and simulation of queuing systems (QS) and networks
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
+ Queueing theory. Numerical methods.
7
+
8
+ Пакет python для расчета и моделирования систем массового обслуживания (СМО) и сетей (СеМО).
9
+ Теория массового обслуживания. Численные методы.
3
10
 
4
11
  ## Authors
5
12
  - [xabarov](https://github.com/xabarov)
@@ -8,12 +15,15 @@ Python package for calculation and simulation of queuing systems (QS) and networ
8
15
  Install most-queue with pip
9
16
  ```bash
10
17
  pip install most-queue
18
+ pip install -r requirements.txt
11
19
  ```
12
20
 
13
21
  ## DESCRIPTION
14
22
  Most_queue consists of two main parts:
15
23
  - **.theory** contains programs that implement methods for calculating queuing theory models.
16
24
  - **.sim** contains simulation programs.
25
+ - **.tests** contains tests.
26
+ - **.rand_distribution** - A set of functions and classes designed to generate a random values and select parameters for distributions like H2, C2, Ek, Pa, Gamma
17
27
 
18
28
  ### Package .theory
19
29
  | # | Package name | Description |
@@ -51,16 +61,66 @@ Most_queue consists of two main parts:
51
61
  | 1. | fj_delta_sim | Simulation of QS fork-join with a delay in the start of processing between channels |
52
62
  | 2. | fj_sim | Simulation of QS with fork-join process |
53
63
  | 3. | priority_network | Simulation of queuing network with priorities in nodes |
54
- | 4. | rand_distribution | A set of functions and classes designed to generate a PRNG and select parameters for distributions H2, C2, Ek, Pa, Gamma |
55
- | 5. | qs_sim | Simulation of QS GI/G/m/n |
56
- | 6. | priority_queue_sim | Simulation of QS GI/G/m/n with priorities |
57
- | 7. | flow_sum_sim | Simulation of flow summation |
58
- | 8. | impatient_sim.py | Simulation of QS GI/G/m/n with impatience |
59
- | 9. | batch_sim.py | Simulation of QS GI/G/m/n with batch arrival |
60
- | 10. | queue_finite_source_sim.py | Simulation of QS GI/G/m/n with finite sources |
64
+ | 4. | qs_sim | Simulation of QS GI/G/m/n |
65
+ | 5. | priority_queue_sim | Simulation of QS GI/G/m/n with priorities |
66
+ | 6. | flow_sum_sim | Simulation of flow summation |
67
+ | 7. | impatient_sim.py | Simulation of QS GI/G/m/n with impatience |
68
+ | 8. | batch_sim.py | Simulation of QS GI/G/m/n with batch arrival |
69
+ | 9. | queue_finite_source_sim.py | Simulation of QS GI/G/m/n with finite sources |
61
70
 
62
71
  ## Usage
63
- - Look [here](https://github.com/xabarov/most-queue/tree/main/most_queue/pytests) for examples
72
+ - Look [here](https://github.com/xabarov/most-queue/tree/main/most_queue/tests) for examples
73
+ - Look [here](https://github.com/xabarov/most-queue/tree/main/most_queue/tutorials) for jupyter tutorials
74
+
75
+ - Simple example: numeric calc for M/G/1 QS. Run simulation for verification
76
+
77
+ ```python
78
+
79
+ import numpy as np
80
+
81
+ from most_queue.general_utils.tables import probs_print, times_print
82
+ from most_queue.rand_distribution import H2_dist, Pareto_dist, Uniform_dist
83
+ from most_queue.sim.qs_sim import QueueingSystemSimulator
84
+ from most_queue.theory.mg1_calc import get_p, get_v, get_w
85
+
86
+
87
+ """
88
+ Test QS M/G/1
89
+ """
90
+ arrival_lambda = 1 # arrival intensity
91
+ b1 = 0.7 # mean serving time
92
+ coev = 1.2 # standard deviation of serving time
93
+ num_of_jobs = 1000000 # jobs num for simulation
94
+
95
+ # get of parameters of the approximating H2-distribution for service time [y1, mu1, mu2]:
96
+ params = H2_dist.get_params_by_mean_and_coev(b1, coev)
97
+ b = H2_dist.calc_theory_moments(*params, 4)
98
+
99
+ # get wait moments, sojourn time, probs by numeric calc
100
+ w_ch = get_w(arrival_lambda, b)
101
+ v_ch = get_v(arrival_lambda, b)
102
+ p_ch = get_p(arrival_lambda, b, 100)
103
+
104
+ # run simulation for verification
105
+ qs = QueueingSystemSimulator(1) # 1 - num of channels
106
+
107
+ qs.set_servers(params, "H")
108
+ qs.set_sources(arrival_lambda, "M")
109
+
110
+ qs.run(num_of_jobs)
111
+
112
+ # get sim results
113
+ w_sim = qs.w
114
+ p_sim = qs.get_p()
115
+ v_sim = qs.v
116
+
117
+ print("M/H2/1")
118
+
119
+ times_print(w_sim, w_ch, True)
120
+ times_print(v_sim, v_ch, False)
121
+ probs_print(p_sim, p_ch, 10)
122
+
123
+ ```
64
124
 
65
125
  - As an example, we will provide the code for сomparison of calculation results by the Takahashi-Takami and Simulation.
66
126
 
@@ -68,10 +128,10 @@ Most_queue consists of two main parts:
68
128
 
69
129
  import math
70
130
  from most_queue.sim.qs_sim import QueueingSystemSimulator
71
- from most_queue.sim import rand_destribution as rd
131
+ from most_queue.rand_distribution import Gamma
72
132
  import time
73
133
  from most_queue.theory.mgn_tt import MGnCalc
74
- from most_queue.utils.tables import probs_print, times_print
134
+ from most_queue.general_utils.tables import probs_print, times_print
75
135
 
76
136
  n = 3 # number of channels
77
137
  l = 1.0 # input flow intensity
@@ -113,7 +173,7 @@ Most_queue consists of two main parts:
113
173
 
114
174
  # We set the parameters of the service channels using Gamma distribution.
115
175
  # Select the distribution parameters
116
- gamma_params = rd.Gamma.get_mu_alpha([b[0], b[1]])
176
+ gamma_params = Gamma.get_mu_alpha([b[0], b[1]])
117
177
  qs.set_servers(gamma_params, 'Gamma')
118
178
 
119
179
  # Run simulation
@@ -1,5 +1,5 @@
1
1
  """
2
- QS with batch arrival
2
+ Queueing system with batch arrivals.
3
3
  """
4
4
  import numpy as np
5
5
 
@@ -8,17 +8,17 @@ from most_queue.sim.qs_sim import QueueingSystemSimulator, Task
8
8
 
9
9
  class QueueingSystemBatchSim(QueueingSystemSimulator):
10
10
  """
11
- QS with batch arrivals
11
+ Queueing system with batch arrivals.
12
12
  """
13
13
 
14
14
  def __init__(self, num_of_channels,
15
15
  batch_prob,
16
16
  buffer=None, verbose=True):
17
17
  """
18
- Args:
19
- num_of_channels:
20
- batch_prob: list[float], probs of batch size 1, 2, .. len(batch_probs)
21
- buffer: Optional(int, None) : length of queueu
18
+ :param num_of_channels: int : number of channels (servers)
19
+ :param batch_prob: list : probabilities for different batch sizes
20
+ :param buffer: Optional(int, None) : length of queueu
21
+ :param verbose: bool : if True prints info about simulation process
22
22
  """
23
23
  super().__init__(num_of_channels, buffer, verbose)
24
24
 
@@ -52,7 +52,7 @@ class QueueingSystemBatchSim(QueueingSystemSimulator):
52
52
 
53
53
  self.arrival_time = self.ttek + self.source.generate()
54
54
 
55
- for tsk in range(batch_size):
55
+ for _tsk in range(batch_size):
56
56
  self.arrived += 1
57
57
  self.p[self.in_sys] += self.arrival_time - self.t_old
58
58
 
@@ -89,5 +89,5 @@ class QueueingSystemBatchSim(QueueingSystemSimulator):
89
89
  # Проверям, не наступил ли ПНЗ:
90
90
  if self.free_channels == 0:
91
91
  if self.in_sys == self.n:
92
- self.start_ppnz = self.ttek
92
+ self.start_busy = self.ttek
93
93
  break
@@ -12,13 +12,16 @@ class ForkJoinSimDelta(ForkJoinSim):
12
12
  Имитационная модель СМО Fork-Join, Split-Join
13
13
  """
14
14
 
15
- def __init__(self, num_of_channels, num_of_parts, delta, is_SJ=False, buffer=None):
15
+ def __init__(self, num_of_channels, num_of_parts, delta, is_sj=False, buffer=None):
16
16
  """
17
- num_of_channels - количество каналов СМО
18
- buffer - максимальная длина очереди
17
+ :param num_of_channels: int : количество каналов СМО
18
+ :param num_of_parts: int : количество частей на которые разбивается задача
19
+ :param delta: float : параметр модели Fork-Join с дельта-разбиением
20
+ :param is_sj: bool : если True, то используется модель Split-Join, иначе - Fork-Join
21
+ :param buffer: Optional(int, None) : максимальная длина очереди
19
22
  """
20
23
  ForkJoinSim.__init__(self, num_of_channels,
21
- num_of_parts, is_SJ, buffer)
24
+ num_of_parts, is_sj, buffer)
22
25
  self.delta = delta
23
26
  self.subtask_arr_queue = []
24
27
  self.serv_task_id = -1
@@ -26,7 +29,7 @@ class ForkJoinSimDelta(ForkJoinSim):
26
29
 
27
30
  def task_arrival(self):
28
31
  """
29
- Действия по прибытию заявки в СМО.
32
+ Действия по прибытию заявки в СМО.
30
33
  """
31
34
 
32
35
  self.arrived += 1
@@ -37,7 +40,7 @@ class ForkJoinSimDelta(ForkJoinSim):
37
40
  is_dropped = False
38
41
 
39
42
  if self.buffer: # ограниченная длина очереди
40
- if not self.is_SJ:
43
+ if not self.is_sj:
41
44
  if self.queue.size() + self.k - 1 > self.buffer + self.free_channels:
42
45
  self.dropped += 1
43
46
  is_dropped = True
@@ -54,7 +57,7 @@ class ForkJoinSimDelta(ForkJoinSim):
54
57
  self.in_sys += 1
55
58
  self.sub_task_in_sys += 1
56
59
 
57
- if not self.is_SJ: # Fork-Join discipline
60
+ if not self.is_sj: # Fork-Join discipline
58
61
 
59
62
  if self.free_channels == 0:
60
63
  self.queue.append(t.subtasks[0])
@@ -85,6 +88,9 @@ class ForkJoinSimDelta(ForkJoinSim):
85
88
  self.subtask_arr_queue.append(t.subtasks[i])
86
89
 
87
90
  def subtask_arrival(self, subtask_num):
91
+ """
92
+ Действия по прибытию подзадачи в СМО.
93
+ """
88
94
 
89
95
  subtsk = self.subtask_arr_queue.pop(subtask_num)
90
96
  self.p[self.in_sys] += subtsk.future_arr_time - self.t_old
@@ -99,7 +105,7 @@ class ForkJoinSimDelta(ForkJoinSim):
99
105
  if not is_dropped:
100
106
  self.sub_task_in_sys += 1
101
107
 
102
- if not self.is_SJ: # Fork-Join discipline
108
+ if not self.is_sj: # Fork-Join discipline
103
109
 
104
110
  if self.free_channels == 0:
105
111
  self.queue.append(subtsk)
@@ -136,7 +142,7 @@ class ForkJoinSimDelta(ForkJoinSim):
136
142
  self.total += 1
137
143
  self.free_channels += 1
138
144
 
139
- if not self.is_SJ:
145
+ if not self.is_sj:
140
146
 
141
147
  if self.served_subtask_in_task[end_ts.task_id] == self.k:
142
148
  self.served += 1
@@ -186,6 +192,9 @@ class ForkJoinSimDelta(ForkJoinSim):
186
192
  q for q in self.queue.queue if q.task_id != end_ts.task_id]
187
193
 
188
194
  def run_one_step(self):
195
+ """
196
+ Runs one step of simulation.
197
+ """
189
198
 
190
199
  num_of_server_earlier = -1
191
200
  serv_earl = 1e10
@@ -198,9 +207,9 @@ class ForkJoinSimDelta(ForkJoinSim):
198
207
  subtask_arr_time_earl = 1e10
199
208
  num_of_subtask_earl = -1
200
209
 
201
- for c in range(len(self.subtask_arr_queue)):
202
- if self.subtask_arr_queue[c].future_arr_time < subtask_arr_time_earl:
203
- subtask_arr_time_earl = self.subtask_arr_queue[c].future_arr_time
210
+ for c, subtask in enumerate(self.subtask_arr_queue):
211
+ if subtask.future_arr_time < subtask_arr_time_earl:
212
+ subtask_arr_time_earl = subtask.future_arr_time
204
213
  num_of_subtask_earl = c
205
214
 
206
215
  is_task_arr = False
@@ -219,37 +228,42 @@ class ForkJoinSimDelta(ForkJoinSim):
219
228
  self.serving(num_of_server_earlier)
220
229
 
221
230
  def __str__(self, is_short=False):
231
+ """
232
+ Returns string representation of the system
233
+ :param is_short: bool : if True returns short version of string
234
+ :return: str : string representation of the system
235
+ """
222
236
 
223
237
  res = "Queueing system " + self.source_types + \
224
238
  "/" + self.server_types + "/" + str(self.n)
225
- if self.buffer != None:
239
+ if self.buffer is not None:
226
240
  res += "/" + str(self.buffer)
227
- if self.is_SJ:
241
+ if self.is_sj:
228
242
  res += '| Split-Join'
229
243
  else:
230
244
  res += '| Fork-Join'
231
245
 
232
246
  res += "\n"
233
247
  # res += "Load: " + "{0:4.3f}".format(self.calc_load()) + "\n"
234
- res += "Current Time " + "{0:8.3f}".format(self.ttek) + "\n"
235
- res += "Arrival Time: " + "{0:8.3f}".format(self.arrival_time) + "\n"
248
+ res += f"Current Time {self.ttek:8.3f}\n"
249
+ res += f"Arrival Time: {self.arrival_time:8.3f}\n"
236
250
 
237
251
  res += "Sojourn moments:\n"
238
252
  for i in range(3):
239
- res += "\t" + "{0:8.4f}".format(self.v[i])
253
+ res += f"\t{self.v[i]:8.4f}"
240
254
  res += "\n"
241
255
 
242
256
  if not is_short:
243
257
  res += "Stationary prob:\n"
244
258
  res += "\t"
245
259
  for i in range(10):
246
- res += "{0:6.5f}".format(self.p[i] / self.ttek) + " "
260
+ res += f"{self.p[i] / self.ttek:6.5f} "
247
261
  res += "\n"
248
- res += "Arrived: " + str(self.arrived) + "\n"
249
- if self.buffer != None:
250
- res += "Dropped: " + str(self.dropped) + "\n"
251
- res += "Served: " + str(self.served) + "\n"
252
- res += "In System:" + str(self.in_sys) + "\n"
262
+ res += f"Arrived: {self.arrived}\n"
263
+ if self.buffer is not None:
264
+ res += f"Dropped: {self.dropped}\n"
265
+ res += f"Served: {self.served}\n"
266
+ res += f"In System: {self.in_sys}\n"
253
267
 
254
268
  for c in range(self.n):
255
269
  res += str(self.servers[c])