most-queue 2.1__py3-none-any.whl → 2.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of most-queue might be problematic. Click here for more details.
- most_queue/distr_utils/__init__.py +0 -0
- most_queue/{general/interfaces.py → distr_utils/base_distribution.py} +2 -2
- most_queue/{general → distr_utils}/distribution_fitting.py +17 -22
- most_queue/{rand_distribution.py → distributions.py} +28 -28
- most_queue/misc/approx_cdf_make.py +3 -3
- most_queue/misc/calc_v_pls.py +1 -1
- most_queue/misc/flow_sum.py +11 -11
- most_queue/misc/run_mgn_with_h2_delay_cold_warm.py +66 -66
- most_queue/misc/test_fj_delta.py +3 -3
- most_queue/misc/test_network_opt_approx.py +1 -1
- most_queue/misc/test_network_opt_plus.py +1 -1
- most_queue/misc/vacations_paper_utils.py +5 -5
- most_queue/sim/base.py +1 -1
- most_queue/sim/flow_sum.py +6 -6
- most_queue/sim/fork_join_delta.py +1 -1
- most_queue/sim/negative.py +1 -1
- most_queue/sim/networks/base_network_sim.py +1 -1
- most_queue/sim/networks/network.py +1 -1
- most_queue/sim/networks/priority_network.py +1 -1
- most_queue/sim/priority.py +1 -1
- most_queue/sim/utils/distribution_utils.py +1 -1
- most_queue/sim/utils/servers.py +2 -2
- most_queue/sim/vacations.py +1 -1
- most_queue/theory/batch/mm1.py +1 -1
- most_queue/theory/closed/engset.py +1 -1
- most_queue/theory/fifo/ek_d_n.py +2 -2
- most_queue/theory/fifo/gi_m_1.py +4 -4
- most_queue/theory/fifo/gi_m_n.py +4 -4
- most_queue/theory/fifo/m_d_n.py +1 -1
- most_queue/theory/fifo/mg1.py +2 -2
- most_queue/theory/fifo/mgn_takahasi.py +2 -2
- most_queue/theory/fifo/mmnr.py +2 -2
- most_queue/theory/fork_join/m_m_n.py +1 -1
- most_queue/theory/fork_join/split_join.py +1 -1
- most_queue/theory/impatience/mm1.py +1 -1
- most_queue/theory/negative/mg1_disasters.py +2 -2
- most_queue/theory/negative/mg1_rcs.py +2 -2
- most_queue/theory/negative/mgn_disaster.py +2 -2
- most_queue/theory/negative/mgn_rcs.py +2 -2
- most_queue/theory/networks/base_network_calc.py +1 -1
- most_queue/theory/networks/open_network.py +1 -1
- most_queue/theory/networks/open_network_prty.py +1 -1
- most_queue/theory/priority/mgn_invar_approx.py +1 -1
- most_queue/theory/priority/non_preemptive/mg1.py +2 -2
- most_queue/theory/priority/preemptive/m_ph_n_busy_approx.py +10 -10
- most_queue/theory/priority/preemptive/mg1.py +1 -1
- most_queue/theory/priority/preemptive/mm2_3cls_busy_approx.py +5 -5
- most_queue/theory/priority/preemptive/mmn_2cls_pr_busy_approx.py +5 -5
- most_queue/theory/utils/busy_periods.py +1 -1
- most_queue/theory/utils/conditional.py +2 -2
- most_queue/theory/utils/flow_sum.py +6 -6
- most_queue/theory/utils/max_dist.py +1 -1
- most_queue/theory/utils/q_poisson_arrival_calc.py +1 -1
- most_queue/theory/utils/transforms.py +1 -1
- most_queue/theory/vacations/m_h2_h2warm.py +2 -2
- most_queue/theory/vacations/mg1_warm_calc.py +2 -2
- most_queue/theory/vacations/mgn_with_h2_delay_cold_warm.py +4 -4
- most_queue/theory/vacations/mmn_with_h2_cold_and_h2_warmup.py +2 -2
- {most_queue-2.1.dist-info → most_queue-2.2.dist-info}/METADATA +59 -3
- most_queue-2.2.dist-info/RECORD +110 -0
- most_queue-2.1.dist-info/RECORD +0 -109
- /most_queue/{general → distr_utils}/distribution_params.py +0 -0
- /most_queue/{structs.py → general/results_structs.py} +0 -0
- {most_queue-2.1.dist-info → most_queue-2.2.dist-info}/WHEEL +0 -0
- {most_queue-2.1.dist-info → most_queue-2.2.dist-info}/licenses/LICENSE +0 -0
|
File without changes
|
|
@@ -55,10 +55,10 @@ class Distribution(ABC):
|
|
|
55
55
|
|
|
56
56
|
@staticmethod
|
|
57
57
|
@abstractmethod
|
|
58
|
-
def
|
|
58
|
+
def get_params_by_mean_and_cv(f1: float, cv: float):
|
|
59
59
|
"""
|
|
60
60
|
:param f1: mean of the distribution.
|
|
61
|
-
:param
|
|
61
|
+
:param cv: coefficient of variation (std_dev / mean).
|
|
62
62
|
:return: Parameters for the distribution that correspond
|
|
63
63
|
to the given mean and coefficient of variation.
|
|
64
64
|
"""
|
|
@@ -8,7 +8,7 @@ from dataclasses import dataclass
|
|
|
8
8
|
|
|
9
9
|
import numpy as np
|
|
10
10
|
|
|
11
|
-
from most_queue.
|
|
11
|
+
from most_queue.distr_utils.distribution_params import (
|
|
12
12
|
Cox2Params,
|
|
13
13
|
ErlangParams,
|
|
14
14
|
GammaParams,
|
|
@@ -102,27 +102,22 @@ def fit_h2_clx(moments: list[float], fitting_params: FittingParams | None = None
|
|
|
102
102
|
|
|
103
103
|
if fitting_params.is_fitting:
|
|
104
104
|
# проверка на близость распределения к экспоненциальному
|
|
105
|
-
|
|
106
|
-
if math.fabs(
|
|
105
|
+
cv = cmath.sqrt(moments[1] - moments[0] ** 2) / moments[0]
|
|
106
|
+
if math.fabs(cv.real - 1.0) < fitting_params.ee:
|
|
107
107
|
if fitting_params.verbose:
|
|
108
|
-
print(
|
|
109
|
-
f"H2 is close to Exp. Multiply moments to (1+je)"
|
|
110
|
-
f"coev = {coev:5.3f}, e = {fitting_params.e:5.3f}."
|
|
111
|
-
)
|
|
108
|
+
print(f"H2 is close to Exp. Multiply moments to (1+je)" f"cv = {cv:5.3f}, e = {fitting_params.e:5.3f}.")
|
|
112
109
|
f = []
|
|
113
110
|
for i, mom in enumerate(moments):
|
|
114
111
|
f.append(mom * complex(1, (i + 1) * fitting_params.e))
|
|
115
112
|
|
|
116
113
|
return fit_h2_clx(f, fitting_params=fitting_params)
|
|
117
114
|
|
|
118
|
-
|
|
115
|
+
cv = cmath.sqrt(moments[1] - moments[0] ** 2) / moments[0]
|
|
119
116
|
|
|
120
117
|
# проверка на близость распределения к Эрланга 2-го порядка
|
|
121
|
-
if math.fabs(
|
|
118
|
+
if math.fabs(cv.real - 1.0 / math.sqrt(2.0)) < fitting_params.ee:
|
|
122
119
|
if fitting_params.verbose:
|
|
123
|
-
print(
|
|
124
|
-
f"H2 is close to E2. Multiply moments to (1+je)" f"coev = {coev:5.3f}, e = {fitting_params.e:5.3f}."
|
|
125
|
-
)
|
|
120
|
+
print(f"H2 is close to E2. Multiply moments to (1+je)" f"cv = {cv:5.3f}, e = {fitting_params.e:5.3f}.")
|
|
126
121
|
f = []
|
|
127
122
|
for i, mom in enumerate(moments):
|
|
128
123
|
f.append(mom * complex(1, (i + 1) * fitting_params.e))
|
|
@@ -151,23 +146,23 @@ def fit_cox(moments: list[float], fitting_params: FittingParams | None = None) -
|
|
|
151
146
|
|
|
152
147
|
if fitting_params.is_fitting:
|
|
153
148
|
# проверка на близость распределения к экспоненциальному
|
|
154
|
-
|
|
149
|
+
cv = cmath.sqrt(moments[1] - moments[0] ** 2) / moments[0]
|
|
155
150
|
if abs(moments[1] - moments[0] * moments[0]) < fitting_params.ee:
|
|
156
151
|
if fitting_params.verbose:
|
|
157
|
-
print(f"Cox special 1. Multiply moments to (1+je)" f"
|
|
152
|
+
print(f"Cox special 1. Multiply moments to (1+je)" f"cv = {cv:5.3f} e = {fitting_params.e:5.3f}.")
|
|
158
153
|
f = []
|
|
159
154
|
for i, mom in enumerate(moments):
|
|
160
155
|
f.append(mom * complex(1, (i + 1) * fitting_params.e))
|
|
161
156
|
|
|
162
157
|
return fit_cox(f, fitting_params=fitting_params)
|
|
163
158
|
|
|
164
|
-
|
|
159
|
+
cv = cmath.sqrt(moments[1] - moments[0] ** 2) / moments[0]
|
|
165
160
|
|
|
166
161
|
# проверка на близость распределения к Эрланга 2-го порядка
|
|
167
162
|
if abs(moments[1] - (3.0 / 4) * moments[0] * moments[0]) < fitting_params.ee:
|
|
168
163
|
if fitting_params.verbose:
|
|
169
164
|
print("Cox special 2. Multiply moments to (1+je)")
|
|
170
|
-
print(f"\
|
|
165
|
+
print(f"\tcv = {cv:5.3f}, e = {fitting_params.e:5.3f}")
|
|
171
166
|
f = []
|
|
172
167
|
for i, mom in enumerate(moments):
|
|
173
168
|
f.append(mom * complex(1, (i + 1) * fitting_params.e))
|
|
@@ -198,13 +193,13 @@ def fit_pareto_moments(moments: list[float]):
|
|
|
198
193
|
return ParetoParams(alpha=a, K=k)
|
|
199
194
|
|
|
200
195
|
|
|
201
|
-
def
|
|
196
|
+
def fit_pareto_by_mean_and_cv(f1: float, cv: float):
|
|
202
197
|
"""
|
|
203
198
|
Get parameters of the distribution by mean and coefficient of variation.
|
|
204
199
|
:param f1: float, mean value of the distribution
|
|
205
|
-
:param
|
|
200
|
+
:param cv: float, coefficient of variation (mean / std)
|
|
206
201
|
"""
|
|
207
|
-
d = pow(f1 *
|
|
202
|
+
d = pow(f1 * cv, 2)
|
|
208
203
|
c = pow(f1, 2) / d
|
|
209
204
|
disc = 4 * (1 + c)
|
|
210
205
|
a = (2 + math.sqrt(disc)) / 2
|
|
@@ -319,14 +314,14 @@ def fit_weibull(moments: list[float]) -> WeibullParams:
|
|
|
319
314
|
return WeibullParams(k=k, W=big_w)
|
|
320
315
|
|
|
321
316
|
|
|
322
|
-
def
|
|
317
|
+
def gamma_moments_by_mean_and_cv(mean: float, cv: float) -> list[float]:
|
|
323
318
|
"""
|
|
324
319
|
Calculate the first three moments of a gamma distribution
|
|
325
320
|
given the mean and coefficient of variation.
|
|
326
321
|
"""
|
|
327
322
|
f = [0, 0, 0]
|
|
328
|
-
alpha = 1 / (
|
|
323
|
+
alpha = 1 / (cv**2)
|
|
329
324
|
f[0] = mean
|
|
330
|
-
f[1] = pow(f[0], 2) * (pow(
|
|
325
|
+
f[1] = pow(f[0], 2) * (pow(cv, 2) + 1)
|
|
331
326
|
f[2] = f[1] * f[0] * (1.0 + 2 / alpha)
|
|
332
327
|
return f
|
|
@@ -9,7 +9,8 @@ import numpy as np
|
|
|
9
9
|
import scipy.special as sp
|
|
10
10
|
from scipy import stats
|
|
11
11
|
|
|
12
|
-
from most_queue.
|
|
12
|
+
from most_queue.distr_utils.base_distribution import Distribution
|
|
13
|
+
from most_queue.distr_utils.distribution_fitting import (
|
|
13
14
|
FittingParams,
|
|
14
15
|
calc_gamma_func,
|
|
15
16
|
fit_cox,
|
|
@@ -17,12 +18,12 @@ from most_queue.general.distribution_fitting import (
|
|
|
17
18
|
fit_gamma,
|
|
18
19
|
fit_h2,
|
|
19
20
|
fit_h2_clx,
|
|
20
|
-
|
|
21
|
+
fit_pareto_by_mean_and_cv,
|
|
21
22
|
fit_pareto_moments,
|
|
22
23
|
fit_weibull,
|
|
23
|
-
|
|
24
|
+
gamma_moments_by_mean_and_cv,
|
|
24
25
|
)
|
|
25
|
-
from most_queue.
|
|
26
|
+
from most_queue.distr_utils.distribution_params import (
|
|
26
27
|
Cox2Params,
|
|
27
28
|
ErlangParams,
|
|
28
29
|
GammaParams,
|
|
@@ -32,7 +33,6 @@ from most_queue.general.distribution_params import (
|
|
|
32
33
|
UniformParams,
|
|
33
34
|
WeibullParams,
|
|
34
35
|
)
|
|
35
|
-
from most_queue.general.interfaces import Distribution
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
class Weibull(Distribution):
|
|
@@ -99,17 +99,17 @@ class Weibull(Distribution):
|
|
|
99
99
|
return fit_weibull(moments)
|
|
100
100
|
|
|
101
101
|
@staticmethod
|
|
102
|
-
def
|
|
102
|
+
def get_params_by_mean_and_cv(f1: float, cv: float) -> WeibullParams:
|
|
103
103
|
"""
|
|
104
104
|
Subselect parameters of Weibull distribution by the given mean and coefficient of variation.
|
|
105
105
|
Args:
|
|
106
106
|
f1 (float): The first parameter of the Weibull distribution.
|
|
107
|
-
|
|
107
|
+
cv (float): The coefficient of variation.
|
|
108
108
|
Returns:
|
|
109
109
|
WeibullParams
|
|
110
110
|
"""
|
|
111
111
|
|
|
112
|
-
f =
|
|
112
|
+
f = gamma_moments_by_mean_and_cv(f1, cv)
|
|
113
113
|
|
|
114
114
|
return Weibull.get_params(f)
|
|
115
115
|
|
|
@@ -202,15 +202,15 @@ class NormalDistribution(Distribution):
|
|
|
202
202
|
return GaussianParams(mean, std_dev)
|
|
203
203
|
|
|
204
204
|
@staticmethod
|
|
205
|
-
def
|
|
205
|
+
def get_params_by_mean_and_cv(f1: float, cv: float):
|
|
206
206
|
"""
|
|
207
207
|
:param f1: mean of the distribution.
|
|
208
|
-
:param
|
|
208
|
+
:param cv: coefficient of variation (std_dev / mean).
|
|
209
209
|
:return: Parameters for the distribution that correspond
|
|
210
210
|
to the given mean and coefficient of variation.
|
|
211
211
|
"""
|
|
212
212
|
mean = f1
|
|
213
|
-
std_dev =
|
|
213
|
+
std_dev = cv * mean
|
|
214
214
|
return GaussianParams(mean, std_dev)
|
|
215
215
|
|
|
216
216
|
|
|
@@ -276,13 +276,13 @@ class UniformDistribution(Distribution):
|
|
|
276
276
|
return UniformParams(mean=mean, half_interval=half_interval)
|
|
277
277
|
|
|
278
278
|
@staticmethod
|
|
279
|
-
def
|
|
279
|
+
def get_params_by_mean_and_cv(f1: float, cv: float) -> UniformParams:
|
|
280
280
|
"""
|
|
281
281
|
Get parameters of the uniform distribution by mean and coefficient of variation.
|
|
282
282
|
Returns mean and half interval.
|
|
283
283
|
"""
|
|
284
284
|
|
|
285
|
-
D = pow(
|
|
285
|
+
D = pow(cv * f1, 2)
|
|
286
286
|
half_interval = math.sqrt(3 * D)
|
|
287
287
|
|
|
288
288
|
return UniformParams(mean=f1, half_interval=half_interval)
|
|
@@ -414,12 +414,12 @@ class H2Distribution(Distribution):
|
|
|
414
414
|
return fit_h2_clx(moments, fitting_params=fitting_params)
|
|
415
415
|
|
|
416
416
|
@staticmethod
|
|
417
|
-
def
|
|
417
|
+
def get_params_by_mean_and_cv(f1: float, cv: float, is_clx=False) -> H2Params:
|
|
418
418
|
"""
|
|
419
419
|
Get parameters of the H2 distribution by mean and coefficient of variation.
|
|
420
420
|
"""
|
|
421
421
|
|
|
422
|
-
f =
|
|
422
|
+
f = gamma_moments_by_mean_and_cv(f1, cv)
|
|
423
423
|
|
|
424
424
|
if is_clx:
|
|
425
425
|
return H2Distribution.get_params_clx(f)
|
|
@@ -535,12 +535,12 @@ class CoxDistribution(Distribution):
|
|
|
535
535
|
return fit_cox(moments, fitting_params=fitting_params)
|
|
536
536
|
|
|
537
537
|
@staticmethod
|
|
538
|
-
def
|
|
538
|
+
def get_params_by_mean_and_cv(f1: float, cv: float) -> Cox2Params:
|
|
539
539
|
"""
|
|
540
540
|
Get parameters of C2 distribution by mean and coefficient of variation
|
|
541
541
|
"""
|
|
542
542
|
|
|
543
|
-
f =
|
|
543
|
+
f = gamma_moments_by_mean_and_cv(f1, cv)
|
|
544
544
|
|
|
545
545
|
return CoxDistribution.get_params(f)
|
|
546
546
|
|
|
@@ -589,10 +589,10 @@ class DeterministicDistribution(Distribution):
|
|
|
589
589
|
return moments[0]
|
|
590
590
|
|
|
591
591
|
@staticmethod
|
|
592
|
-
def
|
|
592
|
+
def get_params_by_mean_and_cv(f1: float, cv: float):
|
|
593
593
|
"""
|
|
594
594
|
:param f1: mean of the distribution.
|
|
595
|
-
:param
|
|
595
|
+
:param cv: coefficient of variation (std_dev / mean).
|
|
596
596
|
:return: Parameters for the distribution that correspond
|
|
597
597
|
to the given mean and coefficient of variation.
|
|
598
598
|
"""
|
|
@@ -694,14 +694,14 @@ class ParetoDistribution(Distribution):
|
|
|
694
694
|
return fit_pareto_moments(moments)
|
|
695
695
|
|
|
696
696
|
@staticmethod
|
|
697
|
-
def
|
|
697
|
+
def get_params_by_mean_and_cv(f1: float, cv: float):
|
|
698
698
|
"""
|
|
699
699
|
Get parameters of the distribution by mean and coefficient of variation.
|
|
700
700
|
:param f1: float, mean value of the distribution
|
|
701
|
-
:param
|
|
701
|
+
:param cv: float, coefficient of variation (mean / std)
|
|
702
702
|
"""
|
|
703
703
|
|
|
704
|
-
return
|
|
704
|
+
return fit_pareto_by_mean_and_cv(f1, cv)
|
|
705
705
|
|
|
706
706
|
|
|
707
707
|
class ErlangDistribution(Distribution):
|
|
@@ -787,14 +787,14 @@ class ErlangDistribution(Distribution):
|
|
|
787
787
|
return fit_erlang(moments)
|
|
788
788
|
|
|
789
789
|
@staticmethod
|
|
790
|
-
def
|
|
790
|
+
def get_params_by_mean_and_cv(f1: float, cv: float) -> ErlangParams:
|
|
791
791
|
"""
|
|
792
792
|
Method selects the parameters of the Erlang distribution
|
|
793
793
|
by mean and coefficient of variation.
|
|
794
794
|
"""
|
|
795
795
|
f = [0, 0]
|
|
796
796
|
f[0] = f1
|
|
797
|
-
f[1] = (math.pow(
|
|
797
|
+
f[1] = (math.pow(cv, 2) + 1) * math.pow(f[0], 2)
|
|
798
798
|
return ErlangDistribution.get_params(f)
|
|
799
799
|
|
|
800
800
|
|
|
@@ -845,11 +845,11 @@ class ExpDistribution(Distribution):
|
|
|
845
845
|
return ErlangDistribution.get_params(moments).mu
|
|
846
846
|
|
|
847
847
|
@staticmethod
|
|
848
|
-
def
|
|
848
|
+
def get_params_by_mean_and_cv(f1: float, cv: float) -> float:
|
|
849
849
|
"""
|
|
850
850
|
Get parameters of the exponential distribution from mean and coefficient of variation.
|
|
851
851
|
:param f1: mean value
|
|
852
|
-
:param
|
|
852
|
+
:param cv: coefficient of variation (coefficient of dispersion)
|
|
853
853
|
"""
|
|
854
854
|
return 1 / f1
|
|
855
855
|
|
|
@@ -877,11 +877,11 @@ class GammaDistribution(Distribution):
|
|
|
877
877
|
return fit_gamma(moments)
|
|
878
878
|
|
|
879
879
|
@staticmethod
|
|
880
|
-
def
|
|
880
|
+
def get_params_by_mean_and_cv(f1: float, cv: float) -> GammaParams:
|
|
881
881
|
"""
|
|
882
882
|
Get parameters of gamma distribution by mean and coefficient of variation.
|
|
883
883
|
"""
|
|
884
|
-
d = pow(f1 *
|
|
884
|
+
d = pow(f1 * cv, 2)
|
|
885
885
|
mu = f1 / d
|
|
886
886
|
alpha = mu * f1
|
|
887
887
|
return GammaParams(mu=mu, alpha=alpha)
|
|
@@ -4,21 +4,21 @@ import matplotlib.pyplot as plt
|
|
|
4
4
|
import numpy as np
|
|
5
5
|
from tqdm import tqdm
|
|
6
6
|
|
|
7
|
-
from most_queue.
|
|
7
|
+
from most_queue.distributions import GammaDistribution, H2Distribution
|
|
8
8
|
|
|
9
9
|
if __name__ == "__main__":
|
|
10
10
|
|
|
11
11
|
# Входные данные
|
|
12
12
|
|
|
13
13
|
b1 = 3 # мат. ожидание
|
|
14
|
-
|
|
14
|
+
cv = 1.2 # коэффициент вариации
|
|
15
15
|
a_s = 4 # ассиметрия
|
|
16
16
|
|
|
17
17
|
# задаем начальные моменты распределения
|
|
18
18
|
|
|
19
19
|
b = [0, 0, 0]
|
|
20
20
|
b[0] = b1
|
|
21
|
-
b[1] = pow(b[0], 2) * (1 + pow(
|
|
21
|
+
b[1] = pow(b[0], 2) * (1 + pow(cv, 2))
|
|
22
22
|
|
|
23
23
|
# дисперсия
|
|
24
24
|
D = b[1] - pow(b[0], 2)
|
most_queue/misc/calc_v_pls.py
CHANGED
|
@@ -9,7 +9,7 @@ from functools import lru_cache
|
|
|
9
9
|
import numpy as np
|
|
10
10
|
from scipy.misc import derivative
|
|
11
11
|
|
|
12
|
-
from most_queue.
|
|
12
|
+
from most_queue.distributions import H2Distribution, H2Params
|
|
13
13
|
from most_queue.theory.fifo.mgn_takahasi import MGnCalc, TakahashiTakamiParams
|
|
14
14
|
from most_queue.theory.utils.conv import conv_moments
|
|
15
15
|
from most_queue.theory.utils.transforms import lst_exp
|
most_queue/misc/flow_sum.py
CHANGED
|
@@ -5,7 +5,7 @@ Test summation of flows.
|
|
|
5
5
|
|
|
6
6
|
import matplotlib.pyplot as plt
|
|
7
7
|
|
|
8
|
-
from most_queue.
|
|
8
|
+
from most_queue.distributions import GammaDistribution
|
|
9
9
|
from most_queue.sim.flow_sum import FlowSumSim
|
|
10
10
|
from most_queue.theory.utils.flow_sum import SummatorNumeric
|
|
11
11
|
|
|
@@ -17,7 +17,7 @@ def test():
|
|
|
17
17
|
|
|
18
18
|
# Задаем следующие параметры:
|
|
19
19
|
n_nums = 10 # число суммируемых потоков
|
|
20
|
-
|
|
20
|
+
cv = 0.74 # коэффициент вариации каждого потока
|
|
21
21
|
mean = 1 # среднее каждого потока
|
|
22
22
|
num_of_jobs = 400000 # количество заявок для ИМ
|
|
23
23
|
is_semi = False # True, если необходимо использовать метод семиинвариантов вместо H2
|
|
@@ -30,7 +30,7 @@ def test():
|
|
|
30
30
|
# одинаково распределены
|
|
31
31
|
a = []
|
|
32
32
|
for i in range(n_nums):
|
|
33
|
-
params1 = GammaDistribution.
|
|
33
|
+
params1 = GammaDistribution.get_params_by_mean_and_cv(mean, cv)
|
|
34
34
|
a1 = GammaDistribution.calc_theory_moments(params1, 4)
|
|
35
35
|
a.append(a1)
|
|
36
36
|
|
|
@@ -47,14 +47,14 @@ def test():
|
|
|
47
47
|
# i - кол-во суммируемых потоков, j - номер начального момента
|
|
48
48
|
|
|
49
49
|
# Расчет ошибок и отображение результатов
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
cvs_sim = s_sim.cvs
|
|
51
|
+
cvs_num = s.cvs
|
|
52
52
|
errors1 = []
|
|
53
53
|
errors2 = []
|
|
54
|
-
|
|
54
|
+
errors_cv = []
|
|
55
55
|
|
|
56
56
|
str_f = "{0:^18s}|{1:^10.3f}|{2:^10.3f}|{3:^10.3f}|{4:^10.3f}|{5:^10.3f}"
|
|
57
|
-
print("{0:^18s}|{1:^10s}|{2:^10s}|{3:^10s}|{4:^10s}|{5:^10s}".format("-", "a1", "a2", "a3", "a4", "
|
|
57
|
+
print("{0:^18s}|{1:^10s}|{2:^10s}|{3:^10s}|{4:^10s}|{5:^10s}".format("-", "a1", "a2", "a3", "a4", "cv"))
|
|
58
58
|
print("-" * 80)
|
|
59
59
|
|
|
60
60
|
for i in range(n_nums - 1):
|
|
@@ -67,7 +67,7 @@ def test():
|
|
|
67
67
|
s_sim.flows_[i][1],
|
|
68
68
|
s_sim.flows_[i][2],
|
|
69
69
|
s_sim.flows_[i][3],
|
|
70
|
-
|
|
70
|
+
cvs_num[i],
|
|
71
71
|
)
|
|
72
72
|
)
|
|
73
73
|
print("-" * 80)
|
|
@@ -78,13 +78,13 @@ def test():
|
|
|
78
78
|
s.flows_[i][1].real,
|
|
79
79
|
s.flows_[i][2].real,
|
|
80
80
|
s.flows_[i][3].real,
|
|
81
|
-
|
|
81
|
+
cvs_sim[i],
|
|
82
82
|
)
|
|
83
83
|
)
|
|
84
84
|
print("-" * 80)
|
|
85
85
|
errors1.append(SummatorNumeric.get_error(s.flows_[i][0].real, s_sim.flows_[i][0]))
|
|
86
86
|
errors2.append(SummatorNumeric.get_error(s.flows_[i][1].real, s_sim.flows_[i][1]))
|
|
87
|
-
|
|
87
|
+
errors_cv.append(SummatorNumeric.get_error(cvs_num[i], cvs_sim[i]))
|
|
88
88
|
|
|
89
89
|
fig, ax = plt.subplots()
|
|
90
90
|
linestyles = ["solid", "dotted", "dashed", "dashdot"]
|
|
@@ -104,7 +104,7 @@ def test():
|
|
|
104
104
|
fig, ax = plt.subplots()
|
|
105
105
|
ax.plot(ns, errors1, label="error a1", linestyle=linestyles[0])
|
|
106
106
|
ax.plot(ns, errors2, label="error a2", linestyle=linestyles[1])
|
|
107
|
-
ax.plot(ns,
|
|
107
|
+
ax.plot(ns, errors_cv, label="error cv", linestyle=linestyles[2])
|
|
108
108
|
|
|
109
109
|
plt.legend()
|
|
110
110
|
str_title = "Отн. ошибка от числа сумм-х потоков, %"
|