most-queue 1.42__tar.gz → 1.44__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 (88) hide show
  1. {most_queue-1.42 → most_queue-1.44}/PKG-INFO +1 -1
  2. {most_queue-1.42 → most_queue-1.44}/most_queue/general_utils/tables.py +19 -8
  3. {most_queue-1.42 → most_queue-1.44}/most_queue/sim/batch_sim.py +15 -3
  4. {most_queue-1.42 → most_queue-1.44}/most_queue/sim/fj_sim.py +1 -3
  5. {most_queue-1.42 → most_queue-1.44}/most_queue/sim/priority_queue_sim.py +12 -10
  6. {most_queue-1.42 → most_queue-1.44}/most_queue/sim/qs_sim.py +10 -12
  7. most_queue-1.44/most_queue/tests/test_batch.py +52 -0
  8. {most_queue-1.42 → most_queue-1.44}/most_queue/tests/test_ek_d_n.py +5 -3
  9. {most_queue-1.42 → most_queue-1.44}/most_queue/tests/test_mg1_calc.py +1 -1
  10. {most_queue-1.42 → most_queue-1.44}/most_queue/tests/test_qs_sim_prty.py +4 -5
  11. {most_queue-1.42 → most_queue-1.44}/most_queue/theory/batch_mm1.py +43 -9
  12. {most_queue-1.42 → most_queue-1.44}/most_queue.egg-info/PKG-INFO +1 -1
  13. {most_queue-1.42 → most_queue-1.44}/pyproject.toml +1 -1
  14. {most_queue-1.42 → most_queue-1.44}/setup.py +11 -11
  15. most_queue-1.42/most_queue/tests/test_batch.py +0 -43
  16. {most_queue-1.42 → most_queue-1.44}/LICENSE +0 -0
  17. {most_queue-1.42 → most_queue-1.44}/README.md +0 -0
  18. {most_queue-1.42 → most_queue-1.44}/most_queue/__init__.py +0 -0
  19. {most_queue-1.42 → most_queue-1.44}/most_queue/general_utils/__init__.py +0 -0
  20. {most_queue-1.42 → most_queue-1.44}/most_queue/general_utils/approx_cdf_make.py +0 -0
  21. {most_queue-1.42 → most_queue-1.44}/most_queue/general_utils/conv.py +0 -0
  22. {most_queue-1.42 → most_queue-1.44}/most_queue/general_utils/vacations_paper_utils.py +0 -0
  23. {most_queue-1.42 → most_queue-1.44}/most_queue/rand_distribution.py +0 -0
  24. {most_queue-1.42 → most_queue-1.44}/most_queue/sim/__init__.py +0 -0
  25. {most_queue-1.42 → most_queue-1.44}/most_queue/sim/fj_delta_sim.py +0 -0
  26. {most_queue-1.42 → most_queue-1.44}/most_queue/sim/flow_sum_sim.py +0 -0
  27. {most_queue-1.42 → most_queue-1.44}/most_queue/sim/impatient_queue_sim.py +0 -0
  28. {most_queue-1.42 → most_queue-1.44}/most_queue/sim/priority_network.py +0 -0
  29. {most_queue-1.42 → most_queue-1.44}/most_queue/sim/queue_finite_source_sim.py +0 -0
  30. {most_queue-1.42 → most_queue-1.44}/most_queue/sim/utils/__init__.py +0 -0
  31. {most_queue-1.42 → most_queue-1.44}/most_queue/sim/utils/distribution_utils.py +0 -0
  32. {most_queue-1.42 → most_queue-1.44}/most_queue/sim/utils/exceptions.py +0 -0
  33. {most_queue-1.42 → most_queue-1.44}/most_queue/sim/utils/phase.py +0 -0
  34. {most_queue-1.42 → most_queue-1.44}/most_queue/sim/utils/qs_queue.py +0 -0
  35. {most_queue-1.42 → most_queue-1.44}/most_queue/sim/utils/servers.py +0 -0
  36. {most_queue-1.42 → most_queue-1.44}/most_queue/sim/utils/tasks.py +0 -0
  37. {most_queue-1.42 → most_queue-1.44}/most_queue/tests/__init__.py +0 -0
  38. {most_queue-1.42 → most_queue-1.44}/most_queue/tests/test_engset.py +0 -0
  39. {most_queue-1.42 → most_queue-1.44}/most_queue/tests/test_fj_delta.py +0 -0
  40. {most_queue-1.42 → most_queue-1.44}/most_queue/tests/test_fj_im.py +0 -0
  41. {most_queue-1.42 → most_queue-1.44}/most_queue/tests/test_gi_m_1_calc.py +0 -0
  42. {most_queue-1.42 → most_queue-1.44}/most_queue/tests/test_gi_m_n_calc.py +0 -0
  43. {most_queue-1.42 → most_queue-1.44}/most_queue/tests/test_impatience.py +0 -0
  44. {most_queue-1.42 → most_queue-1.44}/most_queue/tests/test_m_d_n_calc.py +0 -0
  45. {most_queue-1.42 → most_queue-1.44}/most_queue/tests/test_m_h2_h2warm.py +0 -0
  46. {most_queue-1.42 → most_queue-1.44}/most_queue/tests/test_m_ph_n_prty.py +0 -0
  47. {most_queue-1.42 → most_queue-1.44}/most_queue/tests/test_mgn_tt.py +0 -0
  48. {most_queue-1.42 → most_queue-1.44}/most_queue/tests/test_mgn_with_h2_delay_cold_warm.py +0 -0
  49. {most_queue-1.42 → most_queue-1.44}/most_queue/tests/test_mmn3_pnz_cox_approx.py +0 -0
  50. {most_queue-1.42 → most_queue-1.44}/most_queue/tests/test_mmn_h2cold_h2warm.py +0 -0
  51. {most_queue-1.42 → most_queue-1.44}/most_queue/tests/test_mmn_prty_pnz_approx.py +0 -0
  52. {most_queue-1.42 → most_queue-1.44}/most_queue/tests/test_network_im_prty.py +0 -0
  53. {most_queue-1.42 → most_queue-1.44}/most_queue/tests/test_qs_sim_test.py +0 -0
  54. {most_queue-1.42 → most_queue-1.44}/most_queue/tests/test_queue_types.py +0 -0
  55. {most_queue-1.42 → most_queue-1.44}/most_queue/theory/__init__.py +0 -0
  56. {most_queue-1.42 → most_queue-1.44}/most_queue/theory/ek_d_n_calc.py +0 -0
  57. {most_queue-1.42 → most_queue-1.44}/most_queue/theory/engset_model.py +0 -0
  58. {most_queue-1.42 → most_queue-1.44}/most_queue/theory/fj_calc.py +0 -0
  59. {most_queue-1.42 → most_queue-1.44}/most_queue/theory/gi_m_1_calc.py +0 -0
  60. {most_queue-1.42 → most_queue-1.44}/most_queue/theory/gi_m_n_calc.py +0 -0
  61. {most_queue-1.42 → most_queue-1.44}/most_queue/theory/impatience_calc.py +0 -0
  62. {most_queue-1.42 → most_queue-1.44}/most_queue/theory/m_d_n_calc.py +0 -0
  63. {most_queue-1.42 → most_queue-1.44}/most_queue/theory/m_h2_h2warm.py +0 -0
  64. {most_queue-1.42 → most_queue-1.44}/most_queue/theory/m_ph_n_prty.py +0 -0
  65. {most_queue-1.42 → most_queue-1.44}/most_queue/theory/mg1_calc.py +0 -0
  66. {most_queue-1.42 → most_queue-1.44}/most_queue/theory/mg1_warm_calc.py +0 -0
  67. {most_queue-1.42 → most_queue-1.44}/most_queue/theory/mgn_tt.py +0 -0
  68. {most_queue-1.42 → most_queue-1.44}/most_queue/theory/mgn_with_h2_delay_cold_warm.py +0 -0
  69. {most_queue-1.42 → most_queue-1.44}/most_queue/theory/mmn3_pnz_cox_approx.py +0 -0
  70. {most_queue-1.42 → most_queue-1.44}/most_queue/theory/mmn_prty_pnz_approx.py +0 -0
  71. {most_queue-1.42 → most_queue-1.44}/most_queue/theory/mmn_with_h2_cold_and_h2_warmup.py +0 -0
  72. {most_queue-1.42 → most_queue-1.44}/most_queue/theory/mmnr_calc.py +0 -0
  73. {most_queue-1.42 → most_queue-1.44}/most_queue/theory/network_calc.py +0 -0
  74. {most_queue-1.42 → most_queue-1.44}/most_queue/theory/network_viewer.py +0 -0
  75. {most_queue-1.42 → most_queue-1.44}/most_queue/theory/priority_calc.py +0 -0
  76. {most_queue-1.42 → most_queue-1.44}/most_queue/theory/utils/__init__.py +0 -0
  77. {most_queue-1.42 → most_queue-1.44}/most_queue/theory/utils/binom_probs.py +0 -0
  78. {most_queue-1.42 → most_queue-1.44}/most_queue/theory/utils/diff5dots.py +0 -0
  79. {most_queue-1.42 → most_queue-1.44}/most_queue/theory/utils/flow_sum.py +0 -0
  80. {most_queue-1.42 → most_queue-1.44}/most_queue/theory/utils/passage_time.py +0 -0
  81. {most_queue-1.42 → most_queue-1.44}/most_queue/theory/utils/q_poisson_arrival_calc.py +0 -0
  82. {most_queue-1.42 → most_queue-1.44}/most_queue/theory/utils/student_stat.py +0 -0
  83. {most_queue-1.42 → most_queue-1.44}/most_queue/theory/utils/weibull.py +0 -0
  84. {most_queue-1.42 → most_queue-1.44}/most_queue.egg-info/SOURCES.txt +0 -0
  85. {most_queue-1.42 → most_queue-1.44}/most_queue.egg-info/dependency_links.txt +0 -0
  86. {most_queue-1.42 → most_queue-1.44}/most_queue.egg-info/not-zip-safe +0 -0
  87. {most_queue-1.42 → most_queue-1.44}/most_queue.egg-info/top_level.txt +0 -0
  88. {most_queue-1.42 → most_queue-1.44}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: most_queue
3
- Version: 1.42
3
+ Version: 1.44
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
@@ -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()
@@ -170,9 +170,7 @@ class ForkJoinSim(QueueingSystemSimulator):
170
170
  while self.served < total_served:
171
171
  self.run_one_step()
172
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()
173
+ print(f'\rStart simulation. Job served: {self.served}/{total_served}')
176
174
  served_old = self.served
177
175
  else:
178
176
  print(Fore.GREEN + '\rStart simulation')
@@ -545,24 +545,26 @@ 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):
549
- if is_real_served:
548
+ def run(self, total_served, is_real_served=True):
550
549
 
550
+ print(Fore.GREEN + '\rStart simulation')
551
+ if is_real_served:
552
+ tek = 0
551
553
  while sum(self.served) < total_served:
552
554
  self.run_one_step()
553
- sys.stderr.write('\rStart simulation. Job served: %d/%d' %
554
- (sum(self.served), total_served))
555
- sys.stderr.flush()
555
+ if tek % 5000 == 0:
556
+ print(Fore.MAGENTA + '\rJob served: ' + Fore.YELLOW +
557
+ f'{sum(self.served)}/{total_served}', end='')
558
+ tek += 1
559
+ print(Fore.MAGENTA + '\rJob served: ' + Fore.YELLOW +
560
+ f'{sum(self.served)}/{total_served}')
556
561
 
557
562
  else:
558
- print(Fore.GREEN + '\rStart simulation')
559
- print(Style.RESET_ALL)
560
-
561
563
  for i in tqdm(range(total_served)):
562
564
  self.run_one_step()
563
565
 
564
- print(Fore.GREEN + '\rSimulation is finished')
565
- print(Style.RESET_ALL)
566
+ print(Fore.GREEN + '\rSimulation is finished')
567
+ print(Style.RESET_ALL)
566
568
 
567
569
  def refresh_ppnz_stat(self, k, new_a):
568
570
  for i in range(3):
@@ -501,30 +501,28 @@ class QueueingSystemSimulator:
501
501
  # конец задержки начала охлаждения
502
502
  self.on_end_cold_delay()
503
503
 
504
- def run(self, total_served, is_real_served=False):
504
+ def run(self, total_served, is_real_served=True):
505
505
  """
506
506
  Run simulation process
507
507
  """
508
508
  start = time.process_time()
509
+
510
+ print(Fore.GREEN + '\rStart simulation')
509
511
 
510
512
  if is_real_served:
511
- served_old = 0
513
+ tek = 0
512
514
  while self.served < total_served:
513
515
  self.run_one_step()
514
- if (self.served - served_old) % 5000 == 0:
515
- sys.stderr.write(
516
- f'\rStart simulation. Job served: {self.served}/{total_served}')
517
- sys.stderr.flush()
518
- served_old = self.served
516
+ if tek % 5000 == 0:
517
+ print(Fore.MAGENTA + '\rJob served: ' + Fore.YELLOW + f'{self.served}/{total_served}', end='')
518
+ tek += 1
519
+ print(Fore.MAGENTA + '\rJob served: ' + Fore.YELLOW + f'{self.served}/{total_served}')
519
520
  else:
520
- print(Fore.GREEN + '\rStart simulation')
521
- print(Style.RESET_ALL)
522
-
523
521
  for i in tqdm(range(total_served)):
524
522
  self.run_one_step()
525
523
 
526
- print(Fore.GREEN + '\rSimulation is finished')
527
- print(Style.RESET_ALL)
524
+ print(Fore.GREEN + '\rSimulation is finished')
525
+ print(Style.RESET_ALL)
528
526
 
529
527
  self.time_spent = time.process_time() - start
530
528
 
@@ -0,0 +1,52 @@
1
+ from most_queue.general_utils.tables import times_print
2
+ from most_queue.sim.batch_sim import QueueingSystemBatchSim
3
+ from most_queue.theory.batch_mm1 import BatchMM1
4
+
5
+
6
+ def calc_mean_batch_size(batch_probs):
7
+ """
8
+ Calc mean batch size
9
+ batch_probs - probs of batch size 1, 2, .. len(batch_probs)
10
+ """
11
+ mean = 0
12
+ for i, prob in enumerate(batch_probs):
13
+ mean += (i + 1)*prob
14
+ return mean
15
+
16
+
17
+ def test_batch_mm1():
18
+ """
19
+ Test QS Mx/M/1/infinite with batch arrivals
20
+ """
21
+
22
+ # probs of batch size 1, 2, .. 5
23
+ batch_probs = [0.2, 0.3, 0.1, 0.2, 0.2]
24
+ mean_batch_size = calc_mean_batch_size(batch_probs)
25
+
26
+ n = 1 # one channel
27
+ lam = 0.7 # arrival intensity
28
+ ro = 0.7 # QS utilization factor
29
+ mu = lam * mean_batch_size / ro # serving intensity
30
+ n_jobs = 500000 # jobs to serve in QS simulation
31
+
32
+ batch_calc = BatchMM1(lam, mu, batch_probs)
33
+
34
+ v1 = batch_calc.get_v1()
35
+
36
+ qs = QueueingSystemBatchSim(n, batch_probs)
37
+
38
+ qs.set_sources(lam, 'M')
39
+ qs.set_servers(mu, 'M')
40
+
41
+ qs.run(n_jobs, is_real_served=True)
42
+
43
+ v1_im = qs.v[0]
44
+
45
+ times_print(v1_im, v1, False) # prints 2.6556 and approx 2.5-2.7
46
+
47
+ assert v1 - v1_im < 0.2
48
+
49
+
50
+ if __name__ == "__main__":
51
+
52
+ test_batch_mm1()
@@ -16,9 +16,9 @@ def test_EkDn():
16
16
 
17
17
  """
18
18
 
19
- ro = 0.8 # коэффициент загрузки СМО
19
+ ro = 0.7 # коэффициент загрузки СМО
20
20
  num_of_jobs = 300000 # количество заявок для ИМ. Чем больше, тем выше точночть ИМ
21
- n = 4 # число каналов
21
+ n = 2 # число каналов
22
22
 
23
23
  # при создании экземпляра класса Ek_D_n нужно передать 4 параметра:
24
24
  # - l , k - параметры распределения Эрланга вх потока
@@ -63,7 +63,9 @@ def test_EkDn():
63
63
  # выводим полученные значения:
64
64
  probs_print(p_sim, p_ch, 10)
65
65
 
66
- assert np.allclose(np.array(p_sim[:10]), np.array(p_ch[:10]), atol=1e-2)
66
+ # probs of zero jobs in queue are 0.084411 | 0.084...
67
+
68
+ assert abs(p_sim[0] - p_ch[0]) < 0.001
67
69
 
68
70
 
69
71
  if __name__ == "__main__":
@@ -3,7 +3,7 @@ import numpy as np
3
3
  from most_queue.general_utils.tables import probs_print, times_print
4
4
  from most_queue.rand_distribution import H2_dist, Pareto_dist, Uniform_dist
5
5
  from most_queue.sim.qs_sim import QueueingSystemSimulator
6
- from most_queue.theory.mg1_calc import get_w, get_v, get_p
6
+ from most_queue.theory.mg1_calc import get_p, get_v, get_w
7
7
 
8
8
 
9
9
  def test_mg1():
@@ -1,10 +1,9 @@
1
+ import numpy as np
2
+
3
+ from most_queue.general_utils.tables import probs_print, times_print_with_classes
4
+ from most_queue.rand_distribution import Gamma
1
5
  from most_queue.sim.priority_queue_sim import PriorityQueueSimulator
2
6
  from most_queue.theory import priority_calc
3
- from most_queue.rand_distribution import Gamma
4
- from most_queue.general_utils.tables import probs_print, times_print_with_classes
5
-
6
-
7
- import numpy as np
8
7
 
9
8
 
10
9
  def test_sim():
@@ -1,16 +1,25 @@
1
1
  import math
2
2
 
3
3
  """
4
- Расчет СМО М/M/1 с групповым прибытием заявок
4
+ Calculation of M/M/1 QS with batch arrival
5
5
  """
6
6
 
7
7
 
8
8
  class BatchMM1:
9
-
10
- def __init__(self, lam, mu, ls, p_num=100000, tol=1e-12):
9
+ """
10
+ Calculation of M/M/1 QS with batch arrival
11
+ """
12
+ def __init__(self, lam, mu, batch_probs, p_num=100000, tol=1e-12):
13
+ """_
14
+ lam: (float): arrival Exp distribution param
15
+ mu (float): serving Exp distribution param
16
+ batch_probs (list[float]): batch probs
17
+ p_num (int, optional): size of probs to calc. Defaults to 100000.
18
+ tol (float, optional): tol, precision of calcs. Defaults to 1e-12.
19
+ """
11
20
  self.lam = lam
12
21
  self.mu = mu
13
- self.ls = ls
22
+ self.ls = list(batch_probs)
14
23
  self.p_num = p_num
15
24
  self.tol = tol
16
25
  moments = self.calc_l_moments()
@@ -18,26 +27,39 @@ class BatchMM1:
18
27
  self.l2 = moments[1]
19
28
 
20
29
  def calc_l(self):
30
+ """
31
+ Mean batch size
32
+ """
21
33
  return sum(self.ls) / len(self.ls)
22
34
 
23
35
  def calc_l_moments(self):
36
+ """
37
+ Initial moments of the number of jobs in the batch
38
+ """
24
39
  moments = [0.0, 0.0]
25
- for j in range(len(moments)):
26
- for i in range(len(self.ls)):
27
- moments[j] += pow(i + 1, j + 1)*self.ls[i]
40
+ for j, mom in enumerate(moments):
41
+ for i, prob in enumerate(self.ls):
42
+ moments[j] += pow(i + 1, j + 1)*prob
28
43
  return moments
29
44
 
30
45
  def calc_L(self):
46
+ """
47
+ Returns list of probabilities
48
+ of arrival more than i applications in a group
49
+ """
31
50
  Ls = []
32
51
  Ls.append(1)
33
52
  summ = 0
34
- for i in range(len(self.ls)):
35
- summ += self.ls[i]
53
+ for i, prob in enumerate(self.ls):
54
+ summ += prob
36
55
  Ls.append(1.0 - summ)
37
56
 
38
57
  return Ls
39
58
 
40
59
  def get_p(self):
60
+ """
61
+ Probs of QS states
62
+ """
41
63
  ro = self.lam / self.mu
42
64
  p0 = 1.0 - self.l * ro
43
65
  Ls = self.calc_L()
@@ -64,18 +86,30 @@ class BatchMM1:
64
86
  return ps
65
87
 
66
88
  def get_N(self):
89
+ """
90
+ Mean jobs in QS
91
+ """
67
92
  ro = self.l * self.lam / self.mu
68
93
  ro_tilda = self.lam / self.mu
69
94
  return (self.l2 + self.l) * ro_tilda / (2 * (1.0 - ro))
70
95
 
71
96
  def get_Q(self):
97
+ """
98
+ Mean queue length
99
+ """
72
100
  N = self.get_N()
73
101
  ro = self.l * self.lam / self.mu
74
102
  return N - ro
75
103
 
76
104
  def get_w1(self):
105
+ """
106
+ Mean wait time
107
+ """
77
108
  return self.get_Q() / (self.l * self.lam)
78
109
 
79
110
  def get_v1(self):
111
+ """
112
+ Mean sojourn time
113
+ """
80
114
  return self.get_N() / (self.l * self.lam)
81
115
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: most_queue
3
- Version: 1.42
3
+ Version: 1.44
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "most_queue"
3
- version = "1.42"
3
+ version = "1.44"
4
4
  authors = [
5
5
  { name="Xabarov Roman", email="xabarov1985@gmail.com" },
6
6
  ]
@@ -1,26 +1,26 @@
1
1
  from setuptools import setup, find_packages
2
2
 
3
3
  setup(name='most-queue',
4
- version='1.42',
4
+ version='1.44',
5
5
  description='Software package for calculation and simulation of queuing systems',
6
6
  author='Xabarov Roman',
7
7
  author_email='xabarov1985@gmail.com',
8
8
  url='https://github.com/xabarov/most-queue',
9
9
  classifiers=[
10
- 'Development Status :: 3 - Alpha',
11
- 'License :: OSI Approved :: MIT License',
12
- 'Programming Language :: Python :: 3.9',
13
- 'Topic :: Text Processing :: Linguistic',
10
+ 'Development Status :: 3 - Alpha',
11
+ 'License :: OSI Approved :: MIT License',
12
+ 'Programming Language :: Python :: 3.9',
13
+ 'Topic :: Text Processing :: Linguistic',
14
14
  ],
15
15
  license='MIT',
16
16
  packages=find_packages(),
17
17
  install_requires=[
18
- 'matplotlib',
19
- 'numpy',
20
- 'pandas',
21
- 'scipy',
22
- 'tqdm',
23
- 'colorama'
18
+ 'matplotlib',
19
+ 'numpy',
20
+ 'pandas',
21
+ 'scipy',
22
+ 'tqdm',
23
+ 'colorama',
24
24
  ],
25
25
  include_package_data=True,
26
26
  zip_safe=False)
@@ -1,43 +0,0 @@
1
- from most_queue.sim.batch_sim import QueueingSystemBatchSim
2
- from most_queue.theory.batch_mm1 import BatchMM1
3
-
4
-
5
- def test_batch_mm1():
6
- ls = [0.2, 0.3, 0.1, 0.2, 0.2]
7
- moments = [0.0, 0.0]
8
- for j in range(len(moments)):
9
- for i in range(len(ls)):
10
- moments[j] += pow(i + 1, j + 1)
11
- moments[j] /= len(ls)
12
-
13
- n = 1
14
- lam = 0.7
15
- ro = 0.8
16
- mu = lam * moments[0] / ro
17
- n_jobs = 300000
18
-
19
- batch_calc = BatchMM1(lam, mu, ls)
20
-
21
- v1 = batch_calc.get_v1()
22
-
23
- qs = QueueingSystemBatchSim(n, ls)
24
-
25
- qs.set_sources(lam, 'M')
26
- qs.set_servers(mu, 'M')
27
-
28
- qs.run(n_jobs)
29
-
30
- v1_im = qs.v[0]
31
-
32
- print("\nЗначения среднего времени пребывания заявок в системе:\n")
33
-
34
- print("{0:^15s}|{1:^15s}|{2:^15s}".format("№ момента", "Числ", "ИМ"))
35
- print("-" * 45)
36
- print("{0:^16d}|{1:^15.5g}|{2:^15.5g}".format(1, v1, v1_im))
37
-
38
- assert 100*abs(v1 - v1_im)/max(v1, v1_im) < 5.0
39
-
40
-
41
- if __name__ == "__main__":
42
-
43
- test_batch_mm1()
File without changes
File without changes
File without changes