most-queue 1.43__tar.gz → 1.45__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 (91) hide show
  1. {most_queue-1.43 → most_queue-1.45}/PKG-INFO +74 -14
  2. {most_queue-1.43 → most_queue-1.45}/README.md +73 -13
  3. {most_queue-1.43 → most_queue-1.45}/most_queue/general_utils/tables.py +19 -8
  4. {most_queue-1.43 → most_queue-1.45}/most_queue/sim/batch_sim.py +15 -3
  5. {most_queue-1.43 → most_queue-1.45}/most_queue/sim/fj_sim.py +14 -9
  6. {most_queue-1.43 → most_queue-1.45}/most_queue/sim/priority_network.py +13 -6
  7. {most_queue-1.43 → most_queue-1.45}/most_queue/sim/priority_queue_sim.py +16 -11
  8. most_queue-1.45/most_queue/sim/qs_sim.py +550 -0
  9. {most_queue-1.43 → most_queue-1.45}/most_queue/sim/utils/phase.py +27 -0
  10. most_queue-1.45/most_queue/sim/utils/stats_update.py +16 -0
  11. most_queue-1.45/most_queue/tests/test_batch.py +52 -0
  12. most_queue-1.45/most_queue/tests/test_ek_d_n.py +73 -0
  13. {most_queue-1.43 → most_queue-1.45}/most_queue/tests/test_mg1_calc.py +1 -1
  14. {most_queue-1.43 → most_queue-1.45}/most_queue/tests/test_mgn_with_h2_delay_cold_warm.py +11 -11
  15. {most_queue-1.43 → most_queue-1.45}/most_queue/tests/test_mmn_h2cold_h2warm.py +1 -1
  16. {most_queue-1.43 → most_queue-1.45}/most_queue/tests/test_qs_sim_prty.py +4 -5
  17. {most_queue-1.43 → most_queue-1.45}/most_queue/theory/batch_mm1.py +43 -9
  18. {most_queue-1.43 → most_queue-1.45}/most_queue.egg-info/PKG-INFO +74 -14
  19. {most_queue-1.43 → most_queue-1.45}/most_queue.egg-info/SOURCES.txt +1 -0
  20. {most_queue-1.43 → most_queue-1.45}/pyproject.toml +1 -1
  21. {most_queue-1.43 → most_queue-1.45}/setup.py +11 -11
  22. most_queue-1.43/most_queue/sim/qs_sim.py +0 -629
  23. most_queue-1.43/most_queue/tests/test_batch.py +0 -43
  24. most_queue-1.43/most_queue/tests/test_ek_d_n.py +0 -70
  25. {most_queue-1.43 → most_queue-1.45}/LICENSE +0 -0
  26. {most_queue-1.43 → most_queue-1.45}/most_queue/__init__.py +0 -0
  27. {most_queue-1.43 → most_queue-1.45}/most_queue/general_utils/__init__.py +0 -0
  28. {most_queue-1.43 → most_queue-1.45}/most_queue/general_utils/approx_cdf_make.py +0 -0
  29. {most_queue-1.43 → most_queue-1.45}/most_queue/general_utils/conv.py +0 -0
  30. {most_queue-1.43 → most_queue-1.45}/most_queue/general_utils/vacations_paper_utils.py +0 -0
  31. {most_queue-1.43 → most_queue-1.45}/most_queue/rand_distribution.py +0 -0
  32. {most_queue-1.43 → most_queue-1.45}/most_queue/sim/__init__.py +0 -0
  33. {most_queue-1.43 → most_queue-1.45}/most_queue/sim/fj_delta_sim.py +0 -0
  34. {most_queue-1.43 → most_queue-1.45}/most_queue/sim/flow_sum_sim.py +0 -0
  35. {most_queue-1.43 → most_queue-1.45}/most_queue/sim/impatient_queue_sim.py +0 -0
  36. {most_queue-1.43 → most_queue-1.45}/most_queue/sim/queue_finite_source_sim.py +0 -0
  37. {most_queue-1.43 → most_queue-1.45}/most_queue/sim/utils/__init__.py +0 -0
  38. {most_queue-1.43 → most_queue-1.45}/most_queue/sim/utils/distribution_utils.py +0 -0
  39. {most_queue-1.43 → most_queue-1.45}/most_queue/sim/utils/exceptions.py +0 -0
  40. {most_queue-1.43 → most_queue-1.45}/most_queue/sim/utils/qs_queue.py +0 -0
  41. {most_queue-1.43 → most_queue-1.45}/most_queue/sim/utils/servers.py +0 -0
  42. {most_queue-1.43 → most_queue-1.45}/most_queue/sim/utils/tasks.py +0 -0
  43. {most_queue-1.43 → most_queue-1.45}/most_queue/tests/__init__.py +0 -0
  44. {most_queue-1.43 → most_queue-1.45}/most_queue/tests/test_engset.py +0 -0
  45. {most_queue-1.43 → most_queue-1.45}/most_queue/tests/test_fj_delta.py +0 -0
  46. {most_queue-1.43 → most_queue-1.45}/most_queue/tests/test_fj_im.py +0 -0
  47. {most_queue-1.43 → most_queue-1.45}/most_queue/tests/test_gi_m_1_calc.py +0 -0
  48. {most_queue-1.43 → most_queue-1.45}/most_queue/tests/test_gi_m_n_calc.py +0 -0
  49. {most_queue-1.43 → most_queue-1.45}/most_queue/tests/test_impatience.py +0 -0
  50. {most_queue-1.43 → most_queue-1.45}/most_queue/tests/test_m_d_n_calc.py +0 -0
  51. {most_queue-1.43 → most_queue-1.45}/most_queue/tests/test_m_h2_h2warm.py +0 -0
  52. {most_queue-1.43 → most_queue-1.45}/most_queue/tests/test_m_ph_n_prty.py +0 -0
  53. {most_queue-1.43 → most_queue-1.45}/most_queue/tests/test_mgn_tt.py +0 -0
  54. {most_queue-1.43 → most_queue-1.45}/most_queue/tests/test_mmn3_pnz_cox_approx.py +0 -0
  55. {most_queue-1.43 → most_queue-1.45}/most_queue/tests/test_mmn_prty_pnz_approx.py +0 -0
  56. {most_queue-1.43 → most_queue-1.45}/most_queue/tests/test_network_im_prty.py +0 -0
  57. {most_queue-1.43 → most_queue-1.45}/most_queue/tests/test_qs_sim_test.py +0 -0
  58. {most_queue-1.43 → most_queue-1.45}/most_queue/tests/test_queue_types.py +0 -0
  59. {most_queue-1.43 → most_queue-1.45}/most_queue/theory/__init__.py +0 -0
  60. {most_queue-1.43 → most_queue-1.45}/most_queue/theory/ek_d_n_calc.py +0 -0
  61. {most_queue-1.43 → most_queue-1.45}/most_queue/theory/engset_model.py +0 -0
  62. {most_queue-1.43 → most_queue-1.45}/most_queue/theory/fj_calc.py +0 -0
  63. {most_queue-1.43 → most_queue-1.45}/most_queue/theory/gi_m_1_calc.py +0 -0
  64. {most_queue-1.43 → most_queue-1.45}/most_queue/theory/gi_m_n_calc.py +0 -0
  65. {most_queue-1.43 → most_queue-1.45}/most_queue/theory/impatience_calc.py +0 -0
  66. {most_queue-1.43 → most_queue-1.45}/most_queue/theory/m_d_n_calc.py +0 -0
  67. {most_queue-1.43 → most_queue-1.45}/most_queue/theory/m_h2_h2warm.py +0 -0
  68. {most_queue-1.43 → most_queue-1.45}/most_queue/theory/m_ph_n_prty.py +0 -0
  69. {most_queue-1.43 → most_queue-1.45}/most_queue/theory/mg1_calc.py +0 -0
  70. {most_queue-1.43 → most_queue-1.45}/most_queue/theory/mg1_warm_calc.py +0 -0
  71. {most_queue-1.43 → most_queue-1.45}/most_queue/theory/mgn_tt.py +0 -0
  72. {most_queue-1.43 → most_queue-1.45}/most_queue/theory/mgn_with_h2_delay_cold_warm.py +0 -0
  73. {most_queue-1.43 → most_queue-1.45}/most_queue/theory/mmn3_pnz_cox_approx.py +0 -0
  74. {most_queue-1.43 → most_queue-1.45}/most_queue/theory/mmn_prty_pnz_approx.py +0 -0
  75. {most_queue-1.43 → most_queue-1.45}/most_queue/theory/mmn_with_h2_cold_and_h2_warmup.py +0 -0
  76. {most_queue-1.43 → most_queue-1.45}/most_queue/theory/mmnr_calc.py +0 -0
  77. {most_queue-1.43 → most_queue-1.45}/most_queue/theory/network_calc.py +0 -0
  78. {most_queue-1.43 → most_queue-1.45}/most_queue/theory/network_viewer.py +0 -0
  79. {most_queue-1.43 → most_queue-1.45}/most_queue/theory/priority_calc.py +0 -0
  80. {most_queue-1.43 → most_queue-1.45}/most_queue/theory/utils/__init__.py +0 -0
  81. {most_queue-1.43 → most_queue-1.45}/most_queue/theory/utils/binom_probs.py +0 -0
  82. {most_queue-1.43 → most_queue-1.45}/most_queue/theory/utils/diff5dots.py +0 -0
  83. {most_queue-1.43 → most_queue-1.45}/most_queue/theory/utils/flow_sum.py +0 -0
  84. {most_queue-1.43 → most_queue-1.45}/most_queue/theory/utils/passage_time.py +0 -0
  85. {most_queue-1.43 → most_queue-1.45}/most_queue/theory/utils/q_poisson_arrival_calc.py +0 -0
  86. {most_queue-1.43 → most_queue-1.45}/most_queue/theory/utils/student_stat.py +0 -0
  87. {most_queue-1.43 → most_queue-1.45}/most_queue/theory/utils/weibull.py +0 -0
  88. {most_queue-1.43 → most_queue-1.45}/most_queue.egg-info/dependency_links.txt +0 -0
  89. {most_queue-1.43 → most_queue-1.45}/most_queue.egg-info/not-zip-safe +0 -0
  90. {most_queue-1.43 → most_queue-1.45}/most_queue.egg-info/top_level.txt +0 -0
  91. {most_queue-1.43 → most_queue-1.45}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: most_queue
3
- Version: 1.43
3
+ Version: 1.45
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
@@ -32,8 +32,15 @@ Requires-Python: >=3.7
32
32
  Description-Content-Type: text/markdown
33
33
  License-File: LICENSE
34
34
 
35
- # most_queue
36
- Python package for calculation and simulation of queuing systems (QS) and networks
35
+ # MostQueue
36
+
37
+ ![Queue](assets/queue6.jpg)
38
+
39
+ Python package for calculation and simulation of queueing systems (QS) and networks.
40
+ Queueing theory. Numerical methods.
41
+
42
+ Пакет python для расчета и моделирования систем массового обслуживания (СМО) и сетей (СеМО).
43
+ Теория массового обслуживания. Численные методы.
37
44
 
38
45
  ## Authors
39
46
  - [xabarov](https://github.com/xabarov)
@@ -42,12 +49,15 @@ Python package for calculation and simulation of queuing systems (QS) and networ
42
49
  Install most-queue with pip
43
50
  ```bash
44
51
  pip install most-queue
52
+ pip install -r requirements.txt
45
53
  ```
46
54
 
47
55
  ## DESCRIPTION
48
56
  Most_queue consists of two main parts:
49
57
  - **.theory** contains programs that implement methods for calculating queuing theory models.
50
58
  - **.sim** contains simulation programs.
59
+ - **.tests** contains tests.
60
+ - **.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
61
 
52
62
  ### Package .theory
53
63
  | # | Package name | Description |
@@ -85,16 +95,66 @@ Most_queue consists of two main parts:
85
95
  | 1. | fj_delta_sim | Simulation of QS fork-join with a delay in the start of processing between channels |
86
96
  | 2. | fj_sim | Simulation of QS with fork-join process |
87
97
  | 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 |
98
+ | 4. | qs_sim | Simulation of QS GI/G/m/n |
99
+ | 5. | priority_queue_sim | Simulation of QS GI/G/m/n with priorities |
100
+ | 6. | flow_sum_sim | Simulation of flow summation |
101
+ | 7. | impatient_sim.py | Simulation of QS GI/G/m/n with impatience |
102
+ | 8. | batch_sim.py | Simulation of QS GI/G/m/n with batch arrival |
103
+ | 9. | queue_finite_source_sim.py | Simulation of QS GI/G/m/n with finite sources |
95
104
 
96
105
  ## Usage
97
- - Look [here](https://github.com/xabarov/most-queue/tree/main/most_queue/pytests) for examples
106
+ - Look [here](https://github.com/xabarov/most-queue/tree/main/most_queue/tests) for examples
107
+ - Look [here](https://github.com/xabarov/most-queue/tree/main/most_queue/tutorials) for jupyter tutorials
108
+
109
+ - Simple example: numeric calc for M/G/1 QS. Run simulation for verification
110
+
111
+ ```python
112
+
113
+ import numpy as np
114
+
115
+ from most_queue.general_utils.tables import probs_print, times_print
116
+ from most_queue.rand_distribution import H2_dist, Pareto_dist, Uniform_dist
117
+ from most_queue.sim.qs_sim import QueueingSystemSimulator
118
+ from most_queue.theory.mg1_calc import get_p, get_v, get_w
119
+
120
+
121
+ """
122
+ Test QS M/G/1
123
+ """
124
+ arrival_lambda = 1 # arrival intensity
125
+ b1 = 0.7 # mean serving time
126
+ coev = 1.2 # standard deviation of serving time
127
+ num_of_jobs = 1000000 # jobs num for simulation
128
+
129
+ # get of parameters of the approximating H2-distribution for service time [y1, mu1, mu2]:
130
+ params = H2_dist.get_params_by_mean_and_coev(b1, coev)
131
+ b = H2_dist.calc_theory_moments(*params, 4)
132
+
133
+ # get wait moments, sojourn time, probs by numeric calc
134
+ w_ch = get_w(arrival_lambda, b)
135
+ v_ch = get_v(arrival_lambda, b)
136
+ p_ch = get_p(arrival_lambda, b, 100)
137
+
138
+ # run simulation for verification
139
+ qs = QueueingSystemSimulator(1) # 1 - num of channels
140
+
141
+ qs.set_servers(params, "H")
142
+ qs.set_sources(arrival_lambda, "M")
143
+
144
+ qs.run(num_of_jobs)
145
+
146
+ # get sim results
147
+ w_sim = qs.w
148
+ p_sim = qs.get_p()
149
+ v_sim = qs.v
150
+
151
+ print("M/H2/1")
152
+
153
+ times_print(w_sim, w_ch, True)
154
+ times_print(v_sim, v_ch, False)
155
+ probs_print(p_sim, p_ch, 10)
156
+
157
+ ```
98
158
 
99
159
  - As an example, we will provide the code for сomparison of calculation results by the Takahashi-Takami and Simulation.
100
160
 
@@ -102,10 +162,10 @@ Most_queue consists of two main parts:
102
162
 
103
163
  import math
104
164
  from most_queue.sim.qs_sim import QueueingSystemSimulator
105
- from most_queue.sim import rand_destribution as rd
165
+ from most_queue.rand_distribution import Gamma
106
166
  import time
107
167
  from most_queue.theory.mgn_tt import MGnCalc
108
- from most_queue.utils.tables import probs_print, times_print
168
+ from most_queue.general_utils.tables import probs_print, times_print
109
169
 
110
170
  n = 3 # number of channels
111
171
  l = 1.0 # input flow intensity
@@ -147,7 +207,7 @@ Most_queue consists of two main parts:
147
207
 
148
208
  # We set the parameters of the service channels using Gamma distribution.
149
209
  # Select the distribution parameters
150
- gamma_params = rd.Gamma.get_mu_alpha([b[0], b[1]])
210
+ gamma_params = Gamma.get_mu_alpha([b[0], b[1]])
151
211
  qs.set_servers(gamma_params, 'Gamma')
152
212
 
153
213
  # Run simulation
@@ -1,5 +1,12 @@
1
- # most_queue
2
- Python package for calculation and simulation of queuing systems (QS) and networks
1
+ # MostQueue
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,4 @@
1
- from colorama import init
2
- from colorama import Fore, Back, Style
1
+ from colorama import Back, Fore, Style, init
3
2
 
4
3
  init()
5
4
 
@@ -16,11 +15,21 @@ def times_print(sim_moments, calc_moments, is_w=True):
16
15
 
17
16
  print("{0:^15s}|{1:^15s}|{2:^15s}".format("№ момента", "Числ", "ИМ"))
18
17
  print("-" * 45)
19
- for j in range(min(len(sim_moments), len(calc_moments))):
20
- calc_mom = calc_moments[j].real if isinstance(calc_moments[j], complex) else calc_moments[j]
21
- sim_mom = sim_moments[j].real if isinstance(sim_moments[j], complex) else sim_moments[j]
18
+ if isinstance(sim_moments, list):
19
+ for j in range(min(len(sim_moments), len(calc_moments))):
20
+ calc_mom = calc_moments[j].real if isinstance(
21
+ calc_moments[j], complex) else calc_moments[j]
22
+ sim_mom = sim_moments[j].real if isinstance(
23
+ sim_moments[j], complex) else sim_moments[j]
24
+ print(
25
+ Fore.CYAN + f"{j + 1:^15d}|" + Fore.YELLOW + f"{calc_mom:^15.5g}" + Fore.CYAN + "|" + Fore.YELLOW + f"{sim_mom:^15.5g}")
26
+ else:
27
+ calc_mom = calc_moments.real if isinstance(
28
+ calc_moments, complex) else calc_moments
29
+ sim_mom = sim_moments.real if isinstance(
30
+ sim_moments, complex) else sim_moments
22
31
  print(
23
- Fore.CYAN + f"{j + 1:^15d}|" + Fore.YELLOW + f"{calc_mom:^15.5g}" + Fore.CYAN + "|" + Fore.YELLOW + f"{sim_mom:^15.5g}")
32
+ Fore.CYAN + f"{1:^15d}|" + Fore.YELLOW + f"{calc_mom:^15.5g}" + Fore.CYAN + "|" + Fore.YELLOW + f"{sim_mom:^15.5g}")
24
33
 
25
34
  print(Style.RESET_ALL)
26
35
 
@@ -68,14 +77,16 @@ def times_print_with_classes(sim_moments, calc_moments, is_w=True):
68
77
  print(Fore.CYAN + " " * 5 + "|", end="")
69
78
  print(Fore.CYAN + "{:^5s}|".format("ИМ"), end="")
70
79
  for j in range(size):
71
- print(Fore.YELLOW + "{:^15.3g}".format(sim_moments[i][j]) + Fore.CYAN + "|", end="")
80
+ print(
81
+ Fore.YELLOW + "{:^15.3g}".format(sim_moments[i][j]) + Fore.CYAN + "|", end="")
72
82
  print("")
73
83
  print(Fore.CYAN + "{:^5s}".format(str(i + 1)) + "|" + "-" * 54)
74
84
 
75
85
  print(Fore.CYAN + " " * 5 + "|", end="")
76
86
  print(Fore.CYAN + "{:^5s}|".format("Р"), end="")
77
87
  for j in range(size):
78
- print(Fore.YELLOW + "{:^15.3g}".format(calc_moments[i][j]) + Fore.CYAN + "|", end="")
88
+ print(
89
+ Fore.YELLOW + "{:^15.3g}".format(calc_moments[i][j]) + Fore.CYAN + "|", end="")
79
90
  print("")
80
91
  print(Fore.CYAN + "-" * 60)
81
92
 
@@ -8,15 +8,27 @@ from most_queue.sim.qs_sim import QueueingSystemSimulator, Task
8
8
 
9
9
  class QueueingSystemBatchSim(QueueingSystemSimulator):
10
10
  """
11
- QS with batch arrival
11
+ QS with batch arrivals
12
12
  """
13
- def __init__(self, num_of_channels, batch_prob, buffer=None, verbose=True):
13
+
14
+ def __init__(self, num_of_channels,
15
+ batch_prob,
16
+ buffer=None, verbose=True):
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
22
+ """
14
23
  super().__init__(num_of_channels, buffer, verbose)
15
24
 
16
25
  self.batch_prob = batch_prob
17
26
  self.calc_cdf_prob()
18
27
 
19
28
  def calc_cdf_prob(self):
29
+ """
30
+ Calcs CDF of batch probs distribution
31
+ """
20
32
  summ = 0
21
33
  self.batch_cdf = []
22
34
  for p in self.batch_prob:
@@ -25,7 +37,7 @@ class QueueingSystemBatchSim(QueueingSystemSimulator):
25
37
 
26
38
  def arrival(self):
27
39
  """
28
- Действия по прибытию заявки в СМО.
40
+ Actions upon arrival of job to QS
29
41
  """
30
42
 
31
43
  p = np.random.random()
@@ -163,17 +163,22 @@ class ForkJoinSim(QueueingSystemSimulator):
163
163
  else:
164
164
  self.serving(num_of_server_earlier)
165
165
 
166
- def run(self, total_served, is_real_served=False):
166
+ def run(self, total_served, is_real_served=True):
167
167
 
168
168
  if is_real_served:
169
- served_old = 0
170
- while self.served < total_served:
171
- self.run_one_step()
172
- if (self.served - served_old) % 5000 == 0:
173
- sys.stderr.write(
174
- '\rStart simulation. Job served: %d/%d' % (self.served, total_served))
175
- sys.stderr.flush()
176
- served_old = self.served
169
+
170
+ last_percent = 0
171
+
172
+ with tqdm(total=100, unit='jobs') as pbar:
173
+ while self.served < total_served:
174
+ self.run_one_step()
175
+ percent = int(100*(self.served/total_served))
176
+ if last_percent != percent:
177
+ last_percent = percent
178
+ pbar.update(1)
179
+ pbar.set_description(Fore.MAGENTA + '\rJob served: ' +
180
+ Fore.YELLOW + f'{self.served}/{total_served}' + Fore.LIGHTGREEN_EX)
181
+
177
182
  else:
178
183
  print(Fore.GREEN + '\rStart simulation')
179
184
  print(Style.RESET_ALL)
@@ -6,8 +6,8 @@ import numpy as np
6
6
  from colorama import Fore, Style, init
7
7
  from tqdm import tqdm
8
8
 
9
- from most_queue.sim.priority_queue_sim import PriorityQueueSimulator, Task
10
9
  from most_queue.rand_distribution import Exp_dist
10
+ from most_queue.sim.priority_queue_sim import PriorityQueueSimulator, Task
11
11
 
12
12
  init()
13
13
 
@@ -139,15 +139,22 @@ class PriorityNetwork:
139
139
 
140
140
  self.smos[next_node].arrival(next_node_class, self.ttek, ts)
141
141
 
142
- def run(self, job_served, is_real_served=False):
142
+ def run(self, job_served, is_real_served=True):
143
143
  """
144
144
  Run simulation
145
145
  """
146
146
  if is_real_served:
147
- while sum(self.served) < job_served:
148
- self.run_one_step()
149
- sys.stderr.write(f'\rStart simulation. Job served: {sum(self.served)}/{job_served}')
150
- sys.stderr.flush()
147
+ last_percent = 0
148
+
149
+ with tqdm(total=100, unit='jobs') as pbar:
150
+ while sum(self.served) < job_served:
151
+ self.run_one_step()
152
+ percent = int(100*(sum(self.served)/job_served))
153
+ if last_percent != percent:
154
+ last_percent = percent
155
+ pbar.update(1)
156
+ pbar.set_description(Fore.MAGENTA + '\rJob served: ' +
157
+ Fore.YELLOW + f'{sum(self.served)}/{job_served}' + Fore.LIGHTGREEN_EX)
151
158
  else:
152
159
  print(Fore.GREEN + '\rStart simulation')
153
160
  print(Style.RESET_ALL)
@@ -545,24 +545,29 @@ class PriorityQueueSimulator:
545
545
  if self.is_next_calc:
546
546
  self.calc_time_to_next_event()
547
547
 
548
- def run(self, total_served, is_real_served=False):
548
+ def run(self, total_served, is_real_served=True):
549
+
550
+ print(Fore.GREEN + '\rStart simulation')
549
551
  if is_real_served:
550
552
 
551
- while sum(self.served) < total_served:
552
- self.run_one_step()
553
- sys.stderr.write('\rStart simulation. Job served: %d/%d' %
554
- (sum(self.served), total_served))
555
- sys.stderr.flush()
553
+ last_percent = 0
556
554
 
557
- else:
558
- print(Fore.GREEN + '\rStart simulation')
559
- print(Style.RESET_ALL)
555
+ with tqdm(total=100, unit='jobs') as pbar:
556
+ while sum(self.served) < total_served:
557
+ self.run_one_step()
558
+ percent = int(100*(sum(self.served)/total_served))
559
+ if last_percent != percent:
560
+ last_percent = percent
561
+ pbar.update(1)
562
+ pbar.set_description(Fore.MAGENTA + '\rJob served: ' +
563
+ Fore.YELLOW + f'{sum(self.served)}/{total_served}' + Fore.LIGHTGREEN_EX)
560
564
 
565
+ else:
561
566
  for i in tqdm(range(total_served)):
562
567
  self.run_one_step()
563
568
 
564
- print(Fore.GREEN + '\rSimulation is finished')
565
- print(Style.RESET_ALL)
569
+ print(Fore.GREEN + '\rSimulation is finished')
570
+ print(Style.RESET_ALL)
566
571
 
567
572
  def refresh_ppnz_stat(self, k, new_a):
568
573
  for i in range(3):