most-queue 1.55__tar.gz → 1.56__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 (144) hide show
  1. {most_queue-1.55 → most_queue-1.56}/.gitignore +2 -0
  2. {most_queue-1.55 → most_queue-1.56}/PKG-INFO +1 -1
  3. {most_queue-1.55 → most_queue-1.56}/most_queue/general/conditional.py +13 -19
  4. {most_queue-1.55 → most_queue-1.56}/most_queue/general/conv.py +0 -0
  5. {most_queue-1.55 → most_queue-1.56}/most_queue/general/distribution_params.py +0 -0
  6. {most_queue-1.55 → most_queue-1.56}/most_queue/general/interfaces.py +0 -0
  7. most_queue-1.56/most_queue/general/plots.py +65 -0
  8. {most_queue-1.55 → most_queue-1.56}/most_queue/general/tables.py +2 -2
  9. {most_queue-1.55 → most_queue-1.56}/most_queue/general/vacations_paper_utils.py +6 -6
  10. {most_queue-1.55 → most_queue-1.56}/most_queue/misc/calc_v_pls.py +1 -1
  11. {most_queue-1.55 → most_queue-1.56}/most_queue/misc/compare_fj_calc.py +37 -32
  12. {most_queue-1.55 → most_queue-1.56}/most_queue/sim/networks/__init__.py +0 -0
  13. {most_queue-1.55 → most_queue-1.56}/most_queue/sim/queueing_systems/__init__.py +0 -0
  14. most_queue-1.55/most_queue/sim/queueing_systems/fifo.py → most_queue-1.56/most_queue/sim/queueing_systems/base.py +376 -538
  15. {most_queue-1.55 → most_queue-1.56}/most_queue/sim/queueing_systems/batch.py +5 -8
  16. {most_queue-1.55 → most_queue-1.56}/most_queue/sim/queueing_systems/finite_source.py +7 -52
  17. {most_queue-1.55 → most_queue-1.56}/most_queue/sim/queueing_systems/fork_join.py +14 -79
  18. {most_queue-1.55 → most_queue-1.56}/most_queue/sim/queueing_systems/fork_join_delta.py +3 -3
  19. {most_queue-1.55 → most_queue-1.56}/most_queue/sim/queueing_systems/impatient.py +3 -8
  20. {most_queue-1.55 → most_queue-1.56}/most_queue/sim/queueing_systems/negative.py +22 -186
  21. most_queue-1.56/most_queue/sim/queueing_systems/vacations.py +290 -0
  22. {most_queue-1.55 → most_queue-1.56}/most_queue/sim/utils/__init__.py +0 -0
  23. {most_queue-1.55 → most_queue-1.56}/most_queue/sim/utils/distribution_utils.py +0 -0
  24. {most_queue-1.55 → most_queue-1.56}/most_queue/sim/utils/exceptions.py +0 -0
  25. {most_queue-1.55 → most_queue-1.56}/most_queue/sim/utils/phase.py +0 -0
  26. {most_queue-1.55 → most_queue-1.56}/most_queue/sim/utils/qs.py +0 -0
  27. {most_queue-1.55 → most_queue-1.56}/most_queue/sim/utils/qs_queue.py +0 -0
  28. {most_queue-1.55 → most_queue-1.56}/most_queue/sim/utils/servers.py +0 -0
  29. {most_queue-1.55 → most_queue-1.56}/most_queue/sim/utils/stats_update.py +0 -0
  30. {most_queue-1.55 → most_queue-1.56}/most_queue/sim/utils/tasks.py +0 -0
  31. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/networks/__init__.py +0 -0
  32. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/batch/__init__.py +0 -0
  33. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/closed/__init__.py +0 -0
  34. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/fifo/__init__.py +0 -0
  35. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/fork_join/__init__.py +0 -0
  36. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/impatience/__init__.py +0 -0
  37. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/negative/mgn_disaster.py +59 -44
  38. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/negative/mgn_rcs.py +101 -16
  39. most_queue-1.56/most_queue/theory/queueing_systems/negative/structs.py +82 -0
  40. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/priority/__init__.py +0 -0
  41. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/priority/mgn_invar_approx.py +0 -0
  42. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/priority/non_preemptive/__init__.py +0 -0
  43. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/priority/non_preemptive/mg1.py +0 -0
  44. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/priority/preemptive/__init__.py +0 -0
  45. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/priority/preemptive/mg1.py +0 -0
  46. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/vacations/__init__.py +0 -0
  47. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/vacations/mmn_with_h2_cold_and_h2_warmup.py +4 -1
  48. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/utils/__init__.py +0 -0
  49. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/utils/busy_periods.py +0 -0
  50. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/utils/transforms.py +0 -0
  51. {most_queue-1.55 → most_queue-1.56}/pyproject.toml +1 -1
  52. {most_queue-1.55 → most_queue-1.56}/setup.py +1 -1
  53. {most_queue-1.55 → most_queue-1.56}/tests/__init__.py +0 -0
  54. {most_queue-1.55 → most_queue-1.56}/tests/n_test/ro_0.700.json +0 -0
  55. {most_queue-1.55 → most_queue-1.56}/tests/ro_test/n_3.json +0 -0
  56. most_queue-1.56/tests/test_base_qs_sim.py +60 -0
  57. most_queue-1.56/tests/test_conditionals.py +110 -0
  58. {most_queue-1.55 → most_queue-1.56}/tests/test_ek_d_n.py +2 -2
  59. {most_queue-1.55 → most_queue-1.56}/tests/test_engset.py +6 -1
  60. {most_queue-1.55 → most_queue-1.56}/tests/test_gi_m_1_calc.py +3 -3
  61. {most_queue-1.55 → most_queue-1.56}/tests/test_gi_m_n_calc.py +3 -3
  62. {most_queue-1.55 → most_queue-1.56}/tests/test_impatience.py +0 -0
  63. {most_queue-1.55 → most_queue-1.56}/tests/test_m_d_n_calc.py +2 -2
  64. {most_queue-1.55 → most_queue-1.56}/tests/test_m_h2_h2warm.py +3 -3
  65. {most_queue-1.55 → most_queue-1.56}/tests/test_mg1_calc.py +4 -4
  66. {most_queue-1.55 → most_queue-1.56}/tests/test_mgn_disaster.py +3 -3
  67. {most_queue-1.55 → most_queue-1.56}/tests/test_mgn_rcs.py +6 -6
  68. {most_queue-1.55 → most_queue-1.56}/tests/test_mgn_tt.py +2 -2
  69. {most_queue-1.55 → most_queue-1.56}/tests/test_mgn_with_h2_delay_cold_warm.py +8 -10
  70. {most_queue-1.55 → most_queue-1.56}/tests/test_mmn_h2cold_h2warm.py +2 -2
  71. most_queue-1.55/tests/test_qs_sim_test.py → most_queue-1.56/tests/test_qs_sim.py +3 -4
  72. {most_queue-1.55 → most_queue-1.56}/tests/test_queue_types.py +2 -2
  73. most_queue-1.56/tests/vacations_ro_0.7.png +0 -0
  74. {most_queue-1.55 → most_queue-1.56}/tutorials/m_h2_h2warm.ipynb +3 -3
  75. {most_queue-1.55 → most_queue-1.56}/tutorials/mgn_takahasi_takami.ipynb +3 -3
  76. {most_queue-1.55 → most_queue-1.56}/tutorials/priority_queue.ipynb +2 -2
  77. most_queue-1.56/tutorials/queue_sim.ipynb +376 -0
  78. most_queue-1.56/works/__init__.py +0 -0
  79. most_queue-1.56/works/negative_queues/__init__.py +0 -0
  80. most_queue-1.56/works/negative_queues/work_mgn_disasters.py +357 -0
  81. most_queue-1.56/works/negative_queues/work_mgn_rcs.py +357 -0
  82. most_queue-1.55/tutorials/queue_sim.ipynb +0 -335
  83. {most_queue-1.55 → most_queue-1.56}/LICENSE +0 -0
  84. {most_queue-1.55 → most_queue-1.56}/README.md +0 -0
  85. {most_queue-1.55 → most_queue-1.56}/assets/queue_long.png +0 -0
  86. {most_queue-1.55 → most_queue-1.56}/deploy.txt +0 -0
  87. {most_queue-1.55 → most_queue-1.56}/docs/Makefile +0 -0
  88. {most_queue-1.55 → most_queue-1.56}/docs/make.bat +0 -0
  89. {most_queue-1.55 → most_queue-1.56}/docs/source/conf.py +0 -0
  90. {most_queue-1.55 → most_queue-1.56}/docs/source/index.rst +0 -0
  91. {most_queue-1.55 → most_queue-1.56}/docs/source/modules.rst +0 -0
  92. {most_queue-1.55 → most_queue-1.56}/docs/source/most_queue.rst +0 -0
  93. {most_queue-1.55 → most_queue-1.56}/docs/source/most_queue.sim.rst +0 -0
  94. {most_queue-1.55 → most_queue-1.56}/docs/source/most_queue.theory.rst +0 -0
  95. {most_queue-1.55 → most_queue-1.56}/googleb31d3dccb40f969f.html +0 -0
  96. {most_queue-1.55 → most_queue-1.56}/most_queue/__init__.py +0 -0
  97. {most_queue-1.55 → most_queue-1.56}/most_queue/general/__init__.py +0 -0
  98. {most_queue-1.55 → most_queue-1.56}/most_queue/general/approx_cdf_make.py +0 -0
  99. {most_queue-1.55 → most_queue-1.56}/most_queue/misc/flow_sum.py +0 -0
  100. {most_queue-1.55 → most_queue-1.56}/most_queue/misc/test_weibull.py +0 -0
  101. {most_queue-1.55 → most_queue-1.56}/most_queue/rand_distribution.py +0 -0
  102. {most_queue-1.55 → most_queue-1.56}/most_queue/sim/__init__.py +0 -0
  103. {most_queue-1.55 → most_queue-1.56}/most_queue/sim/flow_sum.py +0 -0
  104. {most_queue-1.55 → most_queue-1.56}/most_queue/sim/networks/priority_network.py +0 -0
  105. {most_queue-1.55 → most_queue-1.56}/most_queue/sim/queueing_systems/priority.py +0 -0
  106. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/__init__.py +0 -0
  107. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/networks/network_viewer.py +0 -0
  108. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/networks/open_network.py +0 -0
  109. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/__init__.py +0 -0
  110. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/batch/mm1.py +0 -0
  111. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/closed/engset.py +0 -0
  112. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/fifo/ek_d_n.py +0 -0
  113. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/fifo/gi_m_1.py +0 -0
  114. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/fifo/gi_m_n.py +0 -0
  115. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/fifo/m_d_n.py +0 -0
  116. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/fifo/mg1.py +0 -0
  117. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/fifo/mgn_takahasi.py +0 -0
  118. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/fifo/mmnr.py +0 -0
  119. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/fork_join/m_m_n.py +0 -0
  120. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/fork_join/split_join.py +0 -0
  121. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/impatience/mm1.py +0 -0
  122. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/priority/preemptive/m_ph_n_busy_approx.py +0 -0
  123. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/priority/preemptive/mmn_2cls_pr_busy_approx.py +0 -0
  124. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/priority/preemptive/mmn_3cls_busy_approx.py +0 -0
  125. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/vacations/m_h2_h2warm.py +0 -0
  126. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/vacations/mg1_warm_calc.py +0 -0
  127. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/queueing_systems/vacations/mgn_with_h2_delay_cold_warm.py +0 -0
  128. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/r_example.gexf +0 -0
  129. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/utils/binom_probs.py +0 -0
  130. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/utils/diff5dots.py +0 -0
  131. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/utils/flow_sum.py +0 -0
  132. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/utils/passage_time.py +0 -0
  133. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/utils/q_poisson_arrival_calc.py +0 -0
  134. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/utils/student_stat.py +0 -0
  135. {most_queue-1.55 → most_queue-1.56}/most_queue/theory/utils/weibull.py +0 -0
  136. {most_queue-1.55 → most_queue-1.56}/requirements.txt +0 -0
  137. {most_queue-1.55 → most_queue-1.56}/tests/test_batch.py +0 -0
  138. {most_queue-1.55 → most_queue-1.56}/tests/test_fj_delta.py +0 -0
  139. {most_queue-1.55 → most_queue-1.56}/tests/test_fj_im.py +0 -0
  140. {most_queue-1.55 → most_queue-1.56}/tests/test_m_ph_n_prty.py +0 -0
  141. {most_queue-1.55 → most_queue-1.56}/tests/test_mmn3_pnz_cox_approx.py +0 -0
  142. {most_queue-1.55 → most_queue-1.56}/tests/test_mmn_prty_pnz_approx.py +0 -0
  143. {most_queue-1.55 → most_queue-1.56}/tests/test_network_im_prty.py +0 -0
  144. {most_queue-1.55 → most_queue-1.56}/tests/test_qs_sim_prty.py +0 -0
@@ -161,3 +161,5 @@ cython_debug/
161
161
  #.idea/
162
162
 
163
163
  .vscode
164
+
165
+ /works/results/
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: most_queue
3
- Version: 1.55
3
+ Version: 1.56
4
4
  Summary: Software package for calculation and simulation of queuing systems
5
5
  Project-URL: Homepage, https://github.com/xabarov/most-queue
6
6
  Author-email: Xabarov Roman <xabarov1985@gmail.com>
@@ -1,3 +1,6 @@
1
+ """
2
+ Conditional moments of random variables.
3
+ """
1
4
  import math
2
5
 
3
6
  import numpy as np
@@ -5,7 +8,7 @@ import numpy as np
5
8
  from most_queue.general.distribution_params import H2Params
6
9
 
7
10
 
8
- def moments_H2_less_than_exp(gamma:float, h2_params:H2Params):
11
+ def moments_h2_less_than_exp(gamma: float, h2_params: H2Params):
9
12
  """
10
13
  Compute the initial moments mean of Y given Y < X,
11
14
  where Y is a hyperexponential random variable with parameters p1, mu1, and mu2.
@@ -14,15 +17,16 @@ def moments_H2_less_than_exp(gamma:float, h2_params:H2Params):
14
17
  y = [h2_params.p1, 1-h2_params.p1]
15
18
  mu = [h2_params.mu1, h2_params.mu2]
16
19
  ps = [y[i]*mu[i] for i in range(2)]
17
-
20
+
18
21
  coef = sum([y[i]*mu[i]/(mu[i]+gamma) for i in range(2)])
19
22
 
20
23
  b = [sum([math.factorial(k+1)*ps[i]/pow(mu[i]+gamma, k+2)
21
- for i in range(2)])/coef for k in range(3)]
22
-
24
+ for i in range(2)])/coef for k in range(3)]
25
+
23
26
  return np.array([mom.real for mom in b])
24
27
 
25
- def moments_exp_less_than_H2(gamma:float, h2_params:H2Params):
28
+
29
+ def moments_exp_less_than_h2(gamma: float, h2_params: H2Params):
26
30
  """
27
31
  Compute the initial moments mean of X given X < Y,
28
32
  where X is exponentially distributed with rate gamma.
@@ -38,21 +42,11 @@ def moments_exp_less_than_H2(gamma:float, h2_params:H2Params):
38
42
  mu = [mu1, mu2]
39
43
  denominator = np.sum([y[i]/(mu[i]+gamma) for i in range(2)])
40
44
  b = []
41
-
45
+
42
46
  # Step 2: Compute the Numerator
43
47
  for k in range(3):
44
- numerator = math.factorial(k+1) * np.sum([y[i] / (mu[i]+gamma)**(k+2) for i in range(2)])
48
+ numerator = math.factorial(
49
+ k+1) * np.sum([y[i] / (mu[i]+gamma)**(k+2) for i in range(2)])
45
50
  b.append(numerator / denominator)
46
-
47
- return np.array([mom.real for mom in b])
48
-
49
- if __name__ == "__main__":
50
-
51
- # Example usage:
52
- gamma = 1.0
53
- p1 = 0.5
54
- mu1 = 2.0
55
- mu2 = 3.0
56
51
 
57
- result = moments_exp_less_than_H2(gamma, H2Params(p1=p1, mu1=mu1, mu2=mu2))
58
- print(f"The mean of Y given X < Y is: {result}")
52
+ return np.array([mom.real for mom in b])
@@ -0,0 +1,65 @@
1
+ from enum import Enum
2
+
3
+ import matplotlib.pyplot as plt
4
+
5
+ class DependsType(Enum):
6
+ """
7
+ Enum to specify the type of dependency for plotting.
8
+ """
9
+ NONE = 0
10
+ UTILIZATION_FACTOR = 1
11
+ CHANNELS_NUMBER = 2
12
+ COEFFICIENT_OF_VARIATION = 3
13
+
14
+
15
+ def plot_sim_vs_calc_moments(xs: list[float], sim_results: list[float],
16
+ calc_results: list[float],
17
+ depends_on: DependsType = DependsType.CHANNELS_NUMBER,
18
+ is_errors=False, is_waiting_time=True, save_path=None):
19
+ """
20
+ Plots the simulation and calculated moments for a given list of x values.
21
+ :param xs: A list of x values (e.g., utilization factors or number of channels).
22
+ :type xs: list[float]
23
+ :param sim_results: A list of simulated results.
24
+ :type sim_results: list[float]
25
+ :param calc_results: A list of calculated results using some analytical or numerical method.
26
+ :param depends_on: The type of dependency for plotting (utilization factor, number of channels, etc.).
27
+ :type depends_on: DependsType
28
+ :param is_errors: If True, plots the percentage error between simulation and calculation results.
29
+ :type is_errors: bool
30
+ :param is_waiting_time: If True, labels the y-axis as waiting time; otherwise, as soujourn time.
31
+ :type is_waiting_time: bool
32
+ :param save_path: The path where the plot should be saved. If None, the plot will not be saved.
33
+ :type save_path: str or NoneType
34
+ :return: None
35
+ """
36
+ _fig, ax = plt.subplots()
37
+ if is_errors:
38
+ errors = [100 * (w_sim - w_tt) / w_tt for w_sim,
39
+ w_tt in zip(sim_results, calc_results)]
40
+
41
+ ax.plot(xs, errors)
42
+ ax.set_ylabel(r"$\varepsilon$, %")
43
+ else:
44
+ ax.plot(xs, sim_results, label="Sim")
45
+ ax.plot(xs, calc_results, label="Calc")
46
+ if is_waiting_time:
47
+ ax.set_ylabel(r"$\omega_{1}$")
48
+ else:
49
+ ax.set_ylabel(r"$\upsilon_{1}$")
50
+ plt.legend()
51
+
52
+ if depends_on == DependsType.UTILIZATION_FACTOR:
53
+ ax.set_xlabel(r"$\rho$")
54
+ elif depends_on == DependsType.COEFFICIENT_OF_VARIATION:
55
+ ax.set_xlabel(r"$\nu$")
56
+ else:
57
+ ax.set_xlabel("n")
58
+ plt.xticks(range(1, len(xs) + 1))
59
+
60
+ if save_path is not None:
61
+ plt.savefig(save_path, dpi=300)
62
+ else:
63
+ plt.show()
64
+
65
+ plt.close(_fig)
@@ -25,8 +25,8 @@ def times_print(sim_moments, calc_moments, is_w=True, header=None):
25
25
  spec = 'soujorn'
26
26
  header = f'Initial moments of {spec} time in the system'
27
27
 
28
- print(Fore.CYAN + f'\r{header}')
29
-
28
+ print(Fore.CYAN + f'\n{header:^45}')
29
+ print("-" * 45)
30
30
  print("{0:^15s}|{1:^15s}|{2:^15s}".format("#", "Num", "Sim"))
31
31
  print("-" * 45)
32
32
  if isinstance(sim_moments, list):
@@ -1,11 +1,8 @@
1
1
  import json
2
2
  import math
3
3
 
4
- import matplotlib
5
4
  import matplotlib.pyplot as plt
6
5
 
7
- matplotlib.use('TkAgg')
8
-
9
6
 
10
7
  def print_table(experiments_stat):
11
8
  """
@@ -84,7 +81,7 @@ def calc_moments_by_mean_and_coev(mean, coev):
84
81
 
85
82
 
86
83
  def make_plot(experiments_stat, w_moments_num=0,
87
- param_name="ro", mode='error'):
84
+ param_name="ro", mode='error', save_path=None):
88
85
  """
89
86
  Build plot for wait times initial moments
90
87
  :param experiments_stat: list of experiment statistics
@@ -93,7 +90,7 @@ def make_plot(experiments_stat, w_moments_num=0,
93
90
  :param mode: 'error' or 'mass' - whether to plot errors or mass values
94
91
  :return: figure and axis objects
95
92
  """
96
- fig, ax = plt.subplots()
93
+ _fig, ax = plt.subplots()
97
94
  w_sim_mass = []
98
95
  w_tt_mass = []
99
96
  xs = []
@@ -132,4 +129,7 @@ def make_plot(experiments_stat, w_moments_num=0,
132
129
  elif param_name == "delay_mean":
133
130
  ax.set_xlabel("t, с")
134
131
 
135
- plt.show()
132
+ if save_path:
133
+ plt.savefig(save_path, dpi=300)
134
+ else:
135
+ plt.show()
@@ -58,7 +58,7 @@ class MGnNegativeRCSCalc(MGnCalc):
58
58
  for i in range(3):
59
59
  w[i] = derivative(self._calc_w_pls, 0,
60
60
  dx=1e-3 / self.b[0], n=i + 1, order=9)
61
- return np.array([-w[0].real, w[1].real, -w[2].real])
61
+ return np.array([-w[0], w[1].real, -w[2]])
62
62
 
63
63
  for j in range(1, len(self.p) - self.n):
64
64
  w[0] += j * self.p[self.n + j]
@@ -1,29 +1,35 @@
1
- import matplotlib
1
+ """
2
+ Test approximation for Fork-Join queues
3
+ """
2
4
  import matplotlib.pyplot as plt
3
5
 
4
6
  from most_queue.sim.queueing_systems.fork_join import ForkJoinSim
5
- from most_queue.theory.fork_join.m_m_n import (
6
- get_v1_fj_nelson_tantawi,
7
- get_v1_fj_varki_merchant,
8
- get_v1_fj_varma,
9
- )
7
+ from most_queue.theory.queueing_systems.fork_join.m_m_n import \
8
+ ForkJoinMarkovianCalc
10
9
 
11
- matplotlib.use('TkAgg')
10
+
11
+ def calc_error(calc:float, sim:float)->float:
12
+ """
13
+ Вычисление относительной ошибки аппроксимации
14
+ :param calc: объект класса ForkJoinMarkovianCalc
15
+ :param sim: объект класса ForkJoinSim
16
+ :return:
17
+ """
18
+ return 100*(calc-sim)/calc
12
19
 
13
20
 
14
21
  def test_fj_calc():
15
22
  """
16
23
  Тестирование аппроксимаций для системы Fork-Join
17
- В пакете theory.fj_calc модержатся следующие методы:
24
+ - R. D. Nelson and A. N. Tantawi, “Approximate analysis of fork/join
25
+ synchronization in parallel queues.” IEEE Trans. Computers, vol. 37,
26
+ no. 6, pp. 739–743, 1988.
18
27
 
19
- get_v1_fj_nelson_tantawi - R. D. Nelson and A. N. Tantawi, “Approximate analysis of fork/join
20
- synchronization in parallel queues.” IEEE Trans. Computers, vol. 37, no. 6, pp. 739–743, 1988.
28
+ - S. Varma and A. M. Makowski, “Interpolation approximations for
29
+ symmetric fork-join queues.” Perform. Eval., vol. 20, no. 1, pp. 245–265, 1994.
21
30
 
22
- get_v1_fj_varma - S. Varma and A. M. Makowski, “Interpolation approximations for
23
- symmetric fork-join queues.” Perform. Eval., vol. 20, no. 1, pp. 245–265, 1994.
24
-
25
- get_v1_fj_varki_merchant - E. Varki, “Response time analysis of parallel computer and storage
26
- systems.” IEEE Trans. Parallel Distrib. Syst., 2001.
31
+ - E. Varki, “Response time analysis of parallel computer and storage
32
+ systems.” IEEE Trans. Parallel Distrib. Syst., 2001.
27
33
 
28
34
  Для верификации используем имитационное моделирование (ИМ).
29
35
 
@@ -56,10 +62,12 @@ def test_fj_calc():
56
62
 
57
63
  qs = ForkJoinSim(nn, nn, False)
58
64
 
59
- # задаем входной поток. Методу нужно передать параметры распределения и тип распределения. М - экспоненциальное
65
+ # задаем входной поток. Методу нужно передать параметры распределения и тип распределения.
66
+ # М - экспоненциальное
60
67
  qs.set_sources(l, 'M')
61
68
 
62
- # задаем каналы обслуживания. Методу нужно передать параметры распределения и тип распределения. М - экспоненциальное
69
+ # задаем каналы обслуживания. Методу нужно передать параметры распределения и тип распределения.
70
+ # М - экспоненциальное
63
71
  qs.set_servers(mu, 'M')
64
72
 
65
73
  # запускаем ИМ
@@ -73,15 +81,17 @@ def test_fj_calc():
73
81
  # расчет средних времен пребывания с помощью аппроксимаций. \
74
82
  # На вход каждого из методов - l, mu, nn (число каналов СМО)
75
83
 
76
- v_varki.append(get_v1_fj_varki_merchant(l, mu, nn))
77
- v_varma.append(get_v1_fj_varma(l, mu, nn))
78
- v_nelson.append(get_v1_fj_nelson_tantawi(l, mu, nn))
84
+ calcs = ForkJoinMarkovianCalc(l, mu, nn)
85
+
86
+ v_varki.append(calcs.get_v1_fj_varki_merchant())
87
+ v_varma.append(calcs.get_v1_fj_varma())
88
+ v_nelson.append(calcs.get_v1_fj_nelson_tantawi())
79
89
 
80
90
  print(str_f_v.format(v_sim[i], v_varki[i], v_varma[i], v_nelson[i]))
81
91
 
82
92
  # строим графики и сохраняем в текущую директорию:
83
93
 
84
- fig, ax = plt.subplots()
94
+ _fig, ax = plt.subplots()
85
95
 
86
96
  linestyles = ["solid", "dotted", "dashed", "dashdot"]
87
97
 
@@ -94,19 +104,14 @@ def test_fj_calc():
94
104
  ax.set_xlabel("n")
95
105
 
96
106
  plt.legend()
97
- plt.savefig("v1_from_n_with_ro = {0:^4.2f}.png".format(ro), dpi=300)
107
+ plt.savefig(f"v1_from_n_with_ro = {ro:^4.2f}.png", dpi=300)
98
108
 
99
109
  # errors
100
- v_nelson_err = []
101
- v_varma_err = []
102
- v_varki_err = []
103
-
104
- for i in range(len(v_sim)):
105
- v_varma_err.append(100 * (v_varma[i] - v_sim[i]) / v_sim[i])
106
- v_varki_err.append(100 * (v_varki[i] - v_sim[i]) / v_sim[i])
107
- v_nelson_err.append(100 * (v_nelson[i] - v_sim[i]) / v_sim[i])
110
+ v_varma_err = [calc_error(v, s) for v, s in zip(v_varma, v_sim)]
111
+ v_varki_err = [calc_error(v, s) for v, s in zip(v_varki, v_sim)]
112
+ v_nelson_err = [calc_error(v, s) for v, s in zip(v_nelson, v_sim)]
108
113
 
109
- fig, ax = plt.subplots()
114
+ _fig, ax = plt.subplots()
110
115
  ax.plot(n, v_varki_err, label="Varki", linestyle=linestyles[0])
111
116
  ax.plot(n, v_varma_err, label="Varma", linestyle=linestyles[1])
112
117
  ax.plot(n, v_nelson_err, label="Nelson", linestyle=linestyles[2])
@@ -115,7 +120,7 @@ def test_fj_calc():
115
120
  ax.set_xlabel("n")
116
121
 
117
122
  plt.legend()
118
- plt.savefig("error_from_n_with_ro = {0:^4.2f}.png".format(ro), dpi=300)
123
+ plt.savefig(f"error_from_n_with_ro = {ro:^4.2f}.png", dpi=300)
119
124
 
120
125
 
121
126
  if __name__ == "__main__":