private void Button_AddPoint_Click(object sender, RoutedEventArgs e)
        {
            bool parseComing     = double.TryParse(TextBox_PointComing.Text, out double lambdaComing);
            bool parseProcessing = double.TryParse(TextBox_PointProcessing.Text, out double lambdaProcessing);

            if (parseComing && parseProcessing)
            {
                n++;
                double x0  = 1;
                double x1  = ConvertValueToFactor(minLambdaComing, maxLambdaComing, lambdaComing);
                double x2  = ConvertValueToFactor(minLambdaProcessing, maxLambdaProcessing, lambdaProcessing);
                double x12 = x1 * x2;

                var comingDistribution      = new Rayleigh(Rayleigh.ConvertLambdaToSigma(lambdaComing));
                var proecssingDisctribution = new Rayleigh(Rayleigh.ConvertLambdaToSigma(lambdaProcessing));

                double y = 0;
                for (int exp = 0; exp < countIterationExperiments; ++exp)
                {
                    ModelResult result = CalculateModel(comingDistribution, proecssingDisctribution, count);
                    y += result.AverageTime;
                }
                y = Math.Round(y / (double)countIterationExperiments, 5);

                double yl  = Math.Round(b0 + x1 * b1 + x2 * b2, 5);
                double ycn = Math.Round(b0 + x1 * b1 + x2 * b2 + x12 * b12, 5);

                yl  = Math.Abs(yl);
                ycn = Math.Abs(ycn);

                ListView_TableParameters.Items.Add(new EquationCoefffcients(
                                                       n,
                                                       x0,
                                                       x1,
                                                       x2,
                                                       x12,
                                                       y,
                                                       yl,
                                                       ycn,
                                                       Math.Round(Math.Abs(y - yl), 5),
                                                       Math.Round(Math.Abs(y - ycn), 5)
                                                       ));
            }
            else
            {
                MessageBox.Show(
                    "Введите вещественные числа с разделителем запятая.",
                    "Ошибка",
                    MessageBoxButton.OK,
                    MessageBoxImage.Error
                    );
            }
        }
        private void Button_Calculate_Click(object sender, RoutedEventArgs e)
        {
            bool generatorParsed = double.TryParse(TextBox_SigmaGenerator.Text, out double lambdaComing);
            bool timeParsed      = double.TryParse(TextBox_SigmaTime.Text, out double lambdaProcessing);

            if (generatorParsed && timeParsed)
            {
                try
                {
                    int    count          = 1000;
                    double sigmaGenerator = Rayleigh.ConvertLambdaToSigma(lambdaComing);
                    double sigmaTime      = Rayleigh.ConvertLambdaToSigma(lambdaProcessing);

                    double loading = lambdaComing / lambdaProcessing;

                    var         generatorDistribution = new Rayleigh(sigmaGenerator);
                    var         timeDistribytion      = new Rayleigh(sigmaTime);
                    ModelResult result = CalculateModel(generatorDistribution, timeDistribytion, count);

                    double time    = result.Time;
                    double avgTime = result.AverageTime;

                    Label_Loading.Content = $"Загрузка системы: {loading}";
                    Label_Time.Content    = $"Время работы: {time}";
                    Label_AvgTime.Content = $"Среднее время ожидания: {avgTime}";
                    Label_Count.Content   = $"Количество обработанных заявок: {count}";
                }
                catch (ArgumentException ex)
                {
                    MessageBox.Show(
                        ex.Message,
                        "Ошибка",
                        MessageBoxButton.OK,
                        MessageBoxImage.Error
                        );
                }
            }
            else
            {
                MessageBox.Show(
                    "Введите два вещественных числа с разделителем запятая.",
                    "Ошибка",
                    MessageBoxButton.OK,
                    MessageBoxImage.Error
                    );
            }
        }
        private void MakeGraph()
        {
            int count = 10000;

            double lambdaProcessing = 10.0;
            double sigmaTime        = Rayleigh.ConvertLambdaToSigma(lambdaProcessing);
            var    timeDistribytion = new Rayleigh(sigmaTime);

            var points = new List <DataPoint>();

            for (double lambdaComing = 0.1; lambdaComing <= lambdaProcessing;)
            {
                double sumExperiments   = 0;
                int    countExperiments = 50;

                for (int i = 0; i < countExperiments; ++i)
                {
                    double sigmaGenerator        = Rayleigh.ConvertLambdaToSigma(lambdaComing);
                    var    generatorDistribution = new Rayleigh(sigmaGenerator);

                    sumExperiments += CalculateModel(generatorDistribution, timeDistribytion, count).AverageTime;
                }

                points.Add(new DataPoint(lambdaComing / lambdaProcessing, sumExperiments / countExperiments));

                if (lambdaComing / lambdaProcessing <= 0.8)
                {
                    lambdaComing += 0.1;
                }
                else
                {
                    lambdaComing += 1;
                }
            }

            LineSeries line = new LineSeries
            {
                ItemsSource = points
            };

            Oxyplot_Output.Series.Clear();
            Oxyplot_Output.Series.Add(line);
            Oxyplot_Output.InvalidatePlot(true);
        }
Exemple #4
0
        private void AddPoint(double lambdaComing1, double lambdaComing2, double lambdaProcessing1, double lambdaProcessing2)
        {
            n++;
            double x0    = 1;
            double x1    = ConvertValueToFactor(minLambdaComing1, maxLambdaComing1, lambdaComing1);
            double x2    = ConvertValueToFactor(minLambdaComing2, maxLambdaComing2, lambdaComing2);
            double x3    = ConvertValueToFactor(minLambdaProcessing1, maxLambdaProcessing1, lambdaProcessing1);
            double x4    = ConvertValueToFactor(minLambdaProcessing2, maxLambdaProcessing2, lambdaProcessing2);
            double x12   = x1 * x2;
            double x13   = x1 * x3;
            double x14   = x1 * x4;
            double x23   = x2 * x3;
            double x24   = x2 * x4;
            double x34   = x3 * x4;
            double x123  = x1 * x2 * x3;
            double x124  = x1 * x2 * x4;
            double x134  = x1 * x3 * x4;
            double x234  = x2 * x3 * x4;
            double x1234 = x1 * x2 * x3 * x4;
            double x11   = x1 * x1 - S;
            double x22   = x2 * x2 - S;
            double x33   = x3 * x3 - S;
            double x44   = x4 * x4 - S;

            var comingDistribution1      = new Rayleigh(Rayleigh.ConvertLambdaToSigma(lambdaComing1));
            var comingDistribution2      = new Rayleigh(Rayleigh.ConvertLambdaToSigma(lambdaComing2));
            var proecssingDisctribution1 = new Rayleigh(Rayleigh.ConvertLambdaToSigma(lambdaProcessing1));
            var proecssingDisctribution2 = new Rayleigh(Rayleigh.ConvertLambdaToSigma(lambdaProcessing2));

            double y = 0;

            for (int exp = 0; exp < countIterationExperiments; ++exp)
            {
                ModelResult result = CalculateModel(comingDistribution1, comingDistribution2, proecssingDisctribution1, proecssingDisctribution2, count);
                y += result.AverageTime;
            }
            y = Math.Round(y / (double)countIterationExperiments, 5);

            var x = new List <double> {
                x0, x1, x2, x3, x4, x12, x13, x14, x23, x24, x34, x123, x124, x134, x234, x1234, x11, x22, x33, x44
            };
            var b = new List <double> {
                b0, b1, b2, b3, b4, b12, b13, b14, b23, b24, b34, b123, b124, b134, b234, b1234, b11, b22, b33, b44
            };

            double yn = CalculateY(b, x);

            ListView_TableParameters.Items.Add(new EquationCoefffcients(
                                                   n,
                                                   Math.Round(x0, 5),
                                                   Math.Round(x1, 5),
                                                   Math.Round(x2, 5),
                                                   Math.Round(x3, 5),
                                                   Math.Round(x4, 5),
                                                   Math.Round(x12, 5),
                                                   Math.Round(x13, 5),
                                                   Math.Round(x14, 5),
                                                   Math.Round(x23, 5),
                                                   Math.Round(x24, 5),
                                                   Math.Round(x34, 5),
                                                   Math.Round(x123, 5),
                                                   Math.Round(x124, 5),
                                                   Math.Round(x134, 5),
                                                   Math.Round(x234, 5),
                                                   Math.Round(x1234, 5),
                                                   Math.Round(x11, 5),
                                                   Math.Round(x22, 5),
                                                   Math.Round(x33, 5),
                                                   Math.Round(x44, 5),
                                                   Math.Round(y, 5),
                                                   Math.Round(yn, 5),
                                                   Math.Round(Math.Abs(y - yn), 5)
                                                   ));
        }
Exemple #5
0
        private void CalculateModel()
        {
            ListView_TableParameters.Items.Clear();

            var listX0    = new List <double>();
            var listX1    = new List <double>();
            var listX2    = new List <double>();
            var listX3    = new List <double>();
            var listX4    = new List <double>();
            var listX12   = new List <double>();
            var listX13   = new List <double>();
            var listX14   = new List <double>();
            var listX23   = new List <double>();
            var listX24   = new List <double>();
            var listX34   = new List <double>();
            var listX123  = new List <double>();
            var listX124  = new List <double>();
            var listX134  = new List <double>();
            var listX234  = new List <double>();
            var listX1234 = new List <double>();
            var listX11   = new List <double>();
            var listX22   = new List <double>();
            var listX33   = new List <double>();
            var listX44   = new List <double>();
            var listY     = new List <double>();
            var listYn    = new List <double>();

            for (int i = 1; i <= countAllExperiments; ++i)
            {
                n = i;
                int x0 = 1;
                listX0.Add(x0);

                int x1 = i % 2 == 0 ? 1 : -1;
                listX1.Add(x1);

                int x2 = (i - 1) / 2 % 2 == 0 ? -1 : 1;
                listX2.Add(x2);

                int x3 = (i - 1) / 4 % 2 == 0 ? -1 : 1;
                listX3.Add(x3);

                int x4 = (i - 1) / 8 % 2 == 0 ? -1 : 1;
                listX4.Add(x4);

                int x12 = x1 * x2;
                listX12.Add(x12);

                int x13 = x1 * x3;
                listX13.Add(x13);

                int x14 = x1 * x4;
                listX14.Add(x14);

                int x23 = x2 * x3;
                listX23.Add(x23);

                int x24 = x2 * x4;
                listX24.Add(x24);

                int x34 = x3 * x4;
                listX34.Add(x34);

                int x123 = x1 * x2 * x3;
                listX123.Add(x123);

                int x124 = x1 * x2 * x4;
                listX124.Add(x124);

                int x134 = x1 * x3 * x4;
                listX134.Add(x134);

                int x234 = x2 * x3 * x4;
                listX234.Add(x234);

                int x1234 = x1 * x2 * x3 * x4;
                listX1234.Add(x1234);

                double x11 = x1 * x1 - S;
                listX11.Add(x11);

                double x22 = x2 * x2 - S;
                listX22.Add(x22);

                double x33 = x3 * x3 - S;
                listX33.Add(x33);

                double x44 = x4 * x4 - S;
                listX44.Add(x44);

                double lambdaComing1     = ConvertFactorToValue(minLambdaComing1, maxLambdaComing1, x1);
                double lambdaComing2     = ConvertFactorToValue(minLambdaComing2, maxLambdaComing2, x2);
                double lambdaProcessing1 = ConvertFactorToValue(minLambdaProcessing1, maxLambdaProcessing1, x3);
                double lambdaProcessing2 = ConvertFactorToValue(minLambdaProcessing2, maxLambdaProcessing2, x4);

                double sigmaComing1     = Rayleigh.ConvertLambdaToSigma(lambdaComing1);
                double sigmaComing2     = Rayleigh.ConvertLambdaToSigma(lambdaComing2);
                double sigmaProcessing1 = Rayleigh.ConvertLambdaToSigma(lambdaProcessing1);
                double sigmaProcessing2 = Rayleigh.ConvertLambdaToSigma(lambdaProcessing2);

                var comingDistribution1      = new Rayleigh(sigmaComing1);
                var comingDistribution2      = new Rayleigh(sigmaComing2);
                var proecssingDisctribution1 = new Rayleigh(sigmaProcessing1);
                var proecssingDisctribution2 = new Rayleigh(sigmaProcessing2);

                double y = 0;
                for (int exp = 0; exp < countIterationExperiments; ++exp)
                {
                    ModelResult result = CalculateModel(comingDistribution1, comingDistribution2, proecssingDisctribution1, proecssingDisctribution2, count);
                    y += result.AverageTime;
                }
                y = Math.Round(y / (double)countIterationExperiments, 5);
                listY.Add(y);
            }

            for (int i = 0; i < 9; ++i)
            {
                n++;

                double x1 = 0;
                double x2 = 0;
                double x3 = 0;
                double x4 = 0;

                switch (i)
                {
                case 0:
                    x1 = alpha;
                    break;

                case 1:
                    x1 = -alpha;
                    break;

                case 2:
                    x2 = alpha;
                    break;

                case 3:
                    x2 = -alpha;
                    break;

                case 4:
                    x3 = alpha;
                    break;

                case 5:
                    x3 = -alpha;
                    break;

                case 6:
                    x4 = alpha;
                    break;

                case 7:
                    x4 = -alpha;
                    break;

                default:
                    break;
                }

                double x0 = 1;

                listX0.Add(x0);
                listX1.Add(x1);
                listX2.Add(x2);
                listX3.Add(x3);
                listX4.Add(x4);

                double x12 = x1 * x2;
                listX12.Add(x12);

                double x13 = x1 * x3;
                listX13.Add(x13);

                double x14 = x1 * x4;
                listX14.Add(x14);

                double x23 = x2 * x3;
                listX23.Add(x23);

                double x24 = x2 * x4;
                listX24.Add(x24);

                double x34 = x3 * x4;
                listX34.Add(x34);

                double x123 = x1 * x2 * x3;
                listX123.Add(x123);

                double x124 = x1 * x2 * x4;
                listX124.Add(x124);

                double x134 = x1 * x3 * x4;
                listX134.Add(x134);

                double x234 = x2 * x3 * x4;
                listX234.Add(x234);

                double x1234 = x1 * x2 * x3 * x4;
                listX1234.Add(x1234);

                double x11 = x1 * x1 - S;
                listX11.Add(x11);

                double x22 = x2 * x2 - S;
                listX22.Add(x22);

                double x33 = x3 * x3 - S;
                listX33.Add(x33);

                double x44 = x4 * x4 - S;
                listX44.Add(x44);

                double lambdaComing1     = ConvertFactorToValue(minLambdaComing1, maxLambdaComing1, x1);
                double lambdaComing2     = ConvertFactorToValue(minLambdaComing2, maxLambdaComing2, x2);
                double lambdaProcessing1 = ConvertFactorToValue(minLambdaProcessing1, maxLambdaProcessing1, x3);
                double lambdaProcessing2 = ConvertFactorToValue(minLambdaProcessing2, maxLambdaProcessing2, x4);

                double sigmaComing1     = Rayleigh.ConvertLambdaToSigma(lambdaComing1);
                double sigmaComing2     = Rayleigh.ConvertLambdaToSigma(lambdaComing2);
                double sigmaProcessing1 = Rayleigh.ConvertLambdaToSigma(lambdaProcessing1);
                double sigmaProcessing2 = Rayleigh.ConvertLambdaToSigma(lambdaProcessing2);

                var comingDistribution1      = new Rayleigh(sigmaComing1);
                var comingDistribution2      = new Rayleigh(sigmaComing2);
                var proecssingDisctribution1 = new Rayleigh(sigmaProcessing1);
                var proecssingDisctribution2 = new Rayleigh(sigmaProcessing2);

                double y = 0;
                for (int exp = 0; exp < countIterationExperiments; ++exp)
                {
                    ModelResult result = CalculateModel(comingDistribution1, comingDistribution2, proecssingDisctribution1, proecssingDisctribution2, count);
                    y += result.AverageTime;
                }
                y = Math.Round(y / (double)countIterationExperiments, 5);
                listY.Add(y);
            }

            double min1 = minLambdaComing1, min2 = minLambdaComing2, min3 = minLambdaProcessing1, min4 = minLambdaProcessing1;
            double max1 = maxLambdaComing1, max2 = maxLambdaComing2, max3 = maxLambdaProcessing1, max4 = maxLambdaProcessing1;

            b0    = CalculateB(0, 1, listX0, listY);
            b1    = CalculateB(min1, max1, listX1, listY);
            b2    = CalculateB(min2, max2, listX2, listY);
            b3    = CalculateB(min3, max3, listX3, listY);
            b4    = CalculateB(min4, max4, listX4, listY);
            b12   = CalculateB(min1 * min2, max1 * max2, listX12, listY);
            b13   = CalculateB(min1 * min3, max1 * max3, listX13, listY);
            b14   = CalculateB(min1 * min4, max1 * max4, listX14, listY);
            b23   = CalculateB(min2 * min3, max2 * max3, listX23, listY);
            b24   = CalculateB(min2 * min4, max2 * max4, listX24, listY);
            b34   = CalculateB(min3 * min4, max3 * max4, listX34, listY);
            b123  = CalculateB(min1 * min2 * min3, max1 * max2 * max3, listX123, listY);
            b124  = CalculateB(min1 * min2 * min4, max1 * max2 * max4, listX124, listY);
            b134  = CalculateB(min1 * min3 * min4, max1 * max3 * max4, listX134, listY);
            b234  = CalculateB(min2 * min3 * min4, max2 * max3 * max4, listX234, listY);
            b1234 = CalculateB(min1 * min2 * min3 * min4, max1 * max2 * max3 * max4, listX1234, listY);
            b11   = CalculateB(min1 * min1, max1 * max1, listX11, listY);
            b22   = CalculateB(min2 * min2, max2 * max2, listX22, listY);
            b33   = CalculateB(min3 * min3, max3 * max3, listX33, listY);
            b44   = CalculateB(min4 * min4, max4 * max4, listX44, listY);
            b0    = b0 - b11 * S - b22 * S - b33 * S - b44 * S;

            for (int i = 0; i < n; ++i)
            {
                List <double> b = new List <double>
                {
                    b0,
                    b1,
                    b2,
                    b3,
                    b4,
                    b12,
                    b13,
                    b14,
                    b23,
                    b24,
                    b34,
                    b123,
                    b124,
                    b134,
                    b234,
                    b1234,
                    b11,
                    b22,
                    b33,
                    b44,
                };

                List <double> x = new List <double>
                {
                    listX0[i],
                    listX1[i],
                    listX2[i],
                    listX3[i],
                    listX4[i],
                    listX12[i],
                    listX13[i],
                    listX14[i],
                    listX23[i],
                    listX24[i],
                    listX34[i],
                    listX123[i],
                    listX124[i],
                    listX134[i],
                    listX234[i],
                    listX1234[i],
                    listX11[i],
                    listX22[i],
                    listX33[i],
                    listX44[i],
                };

                double yn = CalculateY(b, x);

                ListView_TableParameters.Items.Add(new EquationCoefffcients(
                                                       i + 1,
                                                       Math.Round(listX0[i], 5),
                                                       Math.Round(listX1[i], 5),
                                                       Math.Round(listX2[i], 5),
                                                       Math.Round(listX3[i], 5),
                                                       Math.Round(listX4[i], 5),
                                                       Math.Round(listX12[i], 5),
                                                       Math.Round(listX13[i], 5),
                                                       Math.Round(listX14[i], 5),
                                                       Math.Round(listX23[i], 5),
                                                       Math.Round(listX24[i], 5),
                                                       Math.Round(listX34[i], 5),
                                                       Math.Round(listX123[i], 5),
                                                       Math.Round(listX124[i], 5),
                                                       Math.Round(listX134[i], 5),
                                                       Math.Round(listX234[i], 5),
                                                       Math.Round(listX1234[i], 5),
                                                       Math.Round(listX11[i], 5),
                                                       Math.Round(listX22[i], 5),
                                                       Math.Round(listX33[i], 5),
                                                       Math.Round(listX44[i], 5),
                                                       Math.Round(listY[i], 5),
                                                       Math.Round(yn, 5),
                                                       Math.Round(Math.Abs(listY[i] - yn), 5)
                                                       ));
            }

            ListView_TableResults.Items.Clear();
            ListView_TableResults.Items.Add(new EquationResult(
                                                Math.Round(b0, 5),
                                                Math.Round(b1, 5),
                                                Math.Round(b2, 5),
                                                Math.Round(b3, 5),
                                                Math.Round(b4, 5),
                                                Math.Round(b12, 5),
                                                Math.Round(b13, 5),
                                                Math.Round(b14, 5),
                                                Math.Round(b23, 5),
                                                Math.Round(b24, 5),
                                                Math.Round(b34, 5),
                                                Math.Round(b123, 5),
                                                Math.Round(b124, 5),
                                                Math.Round(b134, 5),
                                                Math.Round(b234, 5),
                                                Math.Round(b1234, 5),
                                                Math.Round(b11, 5),
                                                Math.Round(b22, 5),
                                                Math.Round(b33, 5),
                                                Math.Round(b44, 5)
                                                ));
        }
        private void AddPointDFE(double lambdaComing1, double lambdaComing2, double lambdaProcessing1, double lambdaProcessing2)
        {
            n_DFE++;
            double x0    = 1;
            double x1    = ConvertValueToFactor(minLambdaComing1, maxLambdaComing1, lambdaComing1);
            double x2    = ConvertValueToFactor(minLambdaComing2, maxLambdaComing2, lambdaComing2);
            double x3    = ConvertValueToFactor(minLambdaProcessing1, maxLambdaProcessing1, lambdaProcessing1);
            double x4    = ConvertValueToFactor(minLambdaProcessing2, maxLambdaProcessing2, lambdaProcessing2);
            double x12   = x1 * x2;
            double x13   = x1 * x3;
            double x14   = x1 * x4;
            double x23   = x2 * x3;
            double x24   = x2 * x4;
            double x34   = x3 * x4;
            double x123  = x1 * x2 * x3;
            double x124  = x1 * x2 * x4;
            double x134  = x1 * x3 * x4;
            double x234  = x2 * x3 * x4;
            double x1234 = x1 * x2 * x3 * x4;

            var comingDistribution1      = new Rayleigh(Rayleigh.ConvertLambdaToSigma(lambdaComing1));
            var comingDistribution2      = new Rayleigh(Rayleigh.ConvertLambdaToSigma(lambdaComing2));
            var proecssingDisctribution1 = new Rayleigh(Rayleigh.ConvertLambdaToSigma(lambdaProcessing1));
            var proecssingDisctribution2 = new Rayleigh(Rayleigh.ConvertLambdaToSigma(lambdaProcessing2));

            double y = 0;

            for (int exp = 0; exp < countIterationExperiments; ++exp)
            {
                ModelResult result = CalculateModel(comingDistribution1, comingDistribution2, proecssingDisctribution1, proecssingDisctribution2, count);
                y += result.AverageTime;
            }
            y = Math.Round(y / (double)countIterationExperiments, 5);

            List <double> bl = new List <double> {
                b0_DFE, b1_DFE, b2_DFE, b3_DFE, b4_DFE
            };
            List <double> xl = new List <double> {
                x0, x1, x2, x3, x4
            };

            double yl = Math.Round(MultiplyCoefficients(bl, xl), 5);

            List <double> bcn = new List <double>
            {
                b0_DFE,
                b1_DFE,
                b2_DFE,
                b3_DFE,
                b4_DFE,
                b12_DFE,
                b13_DFE,
                b14_DFE,
                b23_DFE,
                b24_DFE,
                b34_DFE,
                b123_DFE,
                b124_DFE,
                b134_DFE,
                b234_DFE,
                b1234_DFE,
            };

            List <double> xcn = new List <double>
            {
                x0,
                x1,
                x2,
                x3,
                x4,
                x12,
                x13,
                x14,
                x23,
                x24,
                x34,
                x123,
                x124,
                x134,
                x234,
                x1234,
            };

            double ycn = Math.Round(MultiplyCoefficients(bcn, xcn), 5);

            yl  = Math.Abs(yl);
            ycn = Math.Abs(ycn);

            ListView_TableParametersDFE.Items.Add(new EquationCoefffcients(
                                                      n_DFE,
                                                      x0,
                                                      x1,
                                                      x2,
                                                      x3,
                                                      x4,
                                                      x12,
                                                      x13,
                                                      x14,
                                                      x23,
                                                      x24,
                                                      x34,
                                                      x123,
                                                      x124,
                                                      x134,
                                                      x234,
                                                      x1234,
                                                      y,
                                                      yl,
                                                      ycn,
                                                      Math.Round(Math.Abs(y - yl), 5),
                                                      Math.Round(Math.Abs(y - ycn), 5)
                                                      ));
        }
        private void ModelDFE()
        {
            ListView_TableParametersDFE.Items.Clear();

            var listX0    = new List <int>();
            var listX1    = new List <int>();
            var listX2    = new List <int>();
            var listX3    = new List <int>();
            var listX4    = new List <int>();
            var listX12   = new List <int>();
            var listX13   = new List <int>();
            var listX14   = new List <int>();
            var listX23   = new List <int>();
            var listX24   = new List <int>();
            var listX34   = new List <int>();
            var listX123  = new List <int>();
            var listX124  = new List <int>();
            var listX134  = new List <int>();
            var listX234  = new List <int>();
            var listX1234 = new List <int>();
            var listY     = new List <double>();
            var listYl    = new List <double>();
            var listYcn   = new List <double>();

            for (int i = 1; i <= countAllExperiments / 2; ++i)
            {
                n_DFE = i;
                int x0 = 1;
                listX0.Add(x0);

                int x1 = i % 2 == 0 ? 1 : -1;
                listX1.Add(x1);

                int x2 = (i - 1) / 2 % 2 == 0 ? -1 : 1;
                listX2.Add(x2);

                int x3 = (i - 1) / 4 % 2 == 0 ? -1 : 1;
                listX3.Add(x3);

                int x4 = x1 * x2 * x3;
                listX4.Add(x4);

                int x12 = x1 * x2;
                listX12.Add(x12);

                int x13 = x1 * x3;
                listX13.Add(x13);

                int x14 = x1 * x4;
                listX14.Add(x14);

                int x23 = x2 * x3;
                listX23.Add(x23);

                int x24 = x2 * x4;
                listX24.Add(x24);

                int x34 = x3 * x4;
                listX34.Add(x34);

                int x123 = x1 * x2 * x3;
                listX123.Add(x123);

                int x124 = x1 * x2 * x4;
                listX124.Add(x124);

                int x134 = x1 * x3 * x4;
                listX134.Add(x134);

                int x234 = x2 * x3 * x4;
                listX234.Add(x234);

                int x1234 = x1 * x2 * x3 * x4;
                listX1234.Add(x1234);

                double lambdaComing1     = ConvertFactorToValue(minLambdaComing1, maxLambdaComing1, x1);
                double lambdaComing2     = ConvertFactorToValue(minLambdaComing2, maxLambdaComing2, x2);
                double lambdaProcessing1 = ConvertFactorToValue(minLambdaProcessing1, maxLambdaProcessing1, x3);
                double lambdaProcessing2 = ConvertFactorToValue(minLambdaProcessing2, maxLambdaProcessing2, x4);

                double sigmaComing1     = Rayleigh.ConvertLambdaToSigma(lambdaComing1);
                double sigmaComing2     = Rayleigh.ConvertLambdaToSigma(lambdaComing2);
                double sigmaProcessing1 = Rayleigh.ConvertLambdaToSigma(lambdaProcessing1);
                double sigmaProcessing2 = Rayleigh.ConvertLambdaToSigma(lambdaProcessing2);

                var comingDistribution1      = new Rayleigh(sigmaComing1);
                var comingDistribution2      = new Rayleigh(sigmaComing2);
                var proecssingDisctribution1 = new Rayleigh(sigmaProcessing1);
                var proecssingDisctribution2 = new Rayleigh(sigmaProcessing2);

                double y = 0;
                for (int exp = 0; exp < countIterationExperiments / 2; ++exp)
                {
                    ModelResult result = CalculateModel(comingDistribution1, comingDistribution2, proecssingDisctribution1, proecssingDisctribution2, count);
                    y += result.AverageTime;
                }
                y = Math.Round(y / (double)countIterationExperiments, 5);
                listY.Add(y);
            }

            double min1 = minLambdaComing1, min2 = minLambdaComing2, min3 = minLambdaProcessing1, min4 = minLambdaProcessing1;
            double max1 = maxLambdaComing1, max2 = maxLambdaComing2, max3 = maxLambdaProcessing1, max4 = maxLambdaProcessing1;

            b0_DFE    = CalculateB_DFE(0, 1, listX0, listY);
            b1_DFE    = CalculateB_DFE(min1, max1, listX1, listY);
            b2_DFE    = CalculateB_DFE(min2, max2, listX2, listY);
            b3_DFE    = CalculateB_DFE(min3, max3, listX3, listY);
            b4_DFE    = CalculateB_DFE(min4, max4, listX4, listY);
            b12_DFE   = CalculateB_DFE(min1 * min2, max1 * max2, listX12, listY);
            b13_DFE   = CalculateB_DFE(min1 * min3, max1 * max3, listX13, listY);
            b14_DFE   = CalculateB_DFE(min1 * min4, max1 * max4, listX14, listY);
            b23_DFE   = CalculateB_DFE(min2 * min3, max2 * max3, listX23, listY);
            b24_DFE   = CalculateB_DFE(min2 * min4, max2 * max4, listX24, listY);
            b34_DFE   = CalculateB_DFE(min3 * min4, max3 * max4, listX34, listY);
            b123_DFE  = CalculateB_DFE(min1 * min2 * min3, max1 * max2 * max3, listX123, listY);
            b124_DFE  = CalculateB_DFE(min1 * min2 * min4, max1 * max2 * max4, listX124, listY);
            b134_DFE  = CalculateB_DFE(min1 * min3 * min4, max1 * max3 * max4, listX134, listY);
            b234_DFE  = CalculateB_DFE(min2 * min3 * min4, max2 * max3 * max4, listX234, listY);
            b1234_DFE = CalculateB_DFE(min1 * min2 * min3 * min4, max1 * max2 * max3 * max4, listX1234, listY);

            for (int i = 0; i < n_DFE; ++i)
            {
                List <double> bl = new List <double> {
                    b0_DFE, b1_DFE, b2_DFE, b3_DFE, b4_DFE
                };
                List <double> xl = new List <double> {
                    listX0[i], listX1[i], listX2[i], listX3[i], listX4[i]
                };

                double yl = Math.Round(MultiplyCoefficients(bl, xl), 5);

                List <double> bcn = new List <double>
                {
                    b0_DFE,
                    b1_DFE,
                    b2_DFE,
                    b3_DFE,
                    b4_DFE,
                    b12_DFE,
                    b13_DFE,
                    b14_DFE,
                    b23_DFE,
                    b24_DFE,
                    b34_DFE,
                    b123_DFE,
                    b124_DFE,
                    b134_DFE,
                    b234_DFE,
                    b1234_DFE,
                };

                List <double> xcn = new List <double>
                {
                    listX0[i],
                    listX1[i],
                    listX2[i],
                    listX3[i],
                    listX4[i],
                    listX12[i],
                    listX13[i],
                    listX14[i],
                    listX23[i],
                    listX24[i],
                    listX34[i],
                    listX123[i],
                    listX124[i],
                    listX134[i],
                    listX234[i],
                    listX1234[i],
                };

                double ycn = Math.Round(MultiplyCoefficients(bcn, xcn), 5);

                yl  = Math.Abs(yl);
                ycn = Math.Abs(ycn);

                ListView_TableParametersDFE.Items.Add(new EquationCoefffcients(
                                                          i + 1,
                                                          listX0[i],
                                                          listX1[i],
                                                          listX2[i],
                                                          listX3[i],
                                                          listX4[i],
                                                          listX12[i],
                                                          listX13[i],
                                                          listX14[i],
                                                          listX23[i],
                                                          listX24[i],
                                                          listX34[i],
                                                          listX123[i],
                                                          listX124[i],
                                                          listX134[i],
                                                          listX234[i],
                                                          listX1234[i],
                                                          listY[i],
                                                          yl,
                                                          ycn,
                                                          Math.Round(Math.Abs(listY[i] - yl), 5),
                                                          Math.Round(Math.Abs(listY[i] - ycn), 5)
                                                          ));
            }

            ListView_TableResultsDFE.Items.Clear();
            ListView_TableResultsDFE.Items.Add(new EquationResult(
                                                   b0_DFE,
                                                   b1_DFE,
                                                   b2_DFE,
                                                   b3_DFE,
                                                   b4_DFE,
                                                   b13_DFE,
                                                   b12_DFE,
                                                   b14_DFE,
                                                   b23_DFE,
                                                   b24_DFE,
                                                   b34_DFE,
                                                   b123_DFE,
                                                   b124_DFE,
                                                   b134_DFE,
                                                   b234_DFE,
                                                   b1234_DFE
                                                   ));
        }
        private void Button_StartExperiment_Click(object sender, RoutedEventArgs e)
        {
            bool parseMinComing     = double.TryParse(TextBox_MinComing.Text, out minLambdaComing);
            bool parseMaxComing     = double.TryParse(TextBox_MaxComing.Text, out maxLambdaComing);
            bool parseMinProcessing = double.TryParse(TextBox_MinProcessing.Text, out minLambdaProcessing);
            bool parseMaxProcessing = double.TryParse(TextBox_MaxProcessing.Text, out maxLambdaProcessing);
            bool parseCount         = int.TryParse(TextBox_Count.Text, out count);

            if (parseMinComing && parseMaxComing && parseMinProcessing && parseMaxProcessing && parseCount)
            {
                ListView_TableParameters.Items.Clear();

                var listX0  = new List <int>();
                var listX1  = new List <int>();
                var listX2  = new List <int>();
                var listX12 = new List <int>();
                var listY   = new List <double>();
                var listYl  = new List <double>();
                var listYcn = new List <double>();

                for (int i = 1; i <= countAllExperiments; ++i)
                {
                    n = i;
                    int x0 = 1;
                    listX0.Add(x0);

                    int x1 = i % 2 == 0 ? 1 : -1;
                    listX1.Add(x1);

                    int x2 = (i - 1) / 2 % 2 == 0 ? -1 : 1;
                    listX2.Add(x2);

                    int x12 = x1 * x2;
                    listX12.Add(x12);

                    double lambdaComing     = ConvertFactorToValue(minLambdaComing, maxLambdaComing, x1);
                    double lambdaProcessing = ConvertFactorToValue(minLambdaProcessing, maxLambdaProcessing, x2);

                    double sigmaComing     = Rayleigh.ConvertLambdaToSigma(lambdaComing);
                    double sigmaProcessing = Rayleigh.ConvertLambdaToSigma(lambdaProcessing);

                    var comingDistribution      = new Rayleigh(sigmaComing);
                    var proecssingDisctribution = new Rayleigh(sigmaProcessing);

                    double y = 0;
                    for (int exp = 0; exp < countIterationExperiments; ++exp)
                    {
                        ModelResult result = CalculateModel(comingDistribution, proecssingDisctribution, count);
                        y += result.AverageTime;
                    }
                    y = Math.Round(y / (double)countIterationExperiments, 5);
                    listY.Add(y);
                }

                b0  = CalculateB(0, 1, listX0, listY);
                b1  = CalculateB(minLambdaComing, maxLambdaComing, listX1, listY);
                b2  = CalculateB(minLambdaProcessing, maxLambdaProcessing, listX2, listY);
                b12 = CalculateB(minLambdaComing * minLambdaProcessing, maxLambdaComing * maxLambdaProcessing, listX12, listY);

                for (int i = 0; i < n; ++i)
                {
                    double yl  = Math.Round(b0 + listX1[i] * b1 + listX2[i] * b2, 5);
                    double ycn = Math.Round(b0 + listX1[i] * b1 + listX2[i] * b2 + listX12[i] * b12, 5);

                    yl  = Math.Abs(yl);
                    ycn = Math.Abs(ycn);

                    ListView_TableParameters.Items.Add(new EquationCoefffcients(
                                                           i + 1,
                                                           listX0[i],
                                                           listX1[i],
                                                           listX2[i],
                                                           listX12[i],
                                                           listY[i],
                                                           yl,
                                                           ycn,
                                                           Math.Round(Math.Abs(listY[i] - yl), 5),
                                                           Math.Round(Math.Abs(listY[i] - ycn), 5)
                                                           ));
                }

                ListView_TableResults.Items.Clear();
                ListView_TableResults.Items.Add(new EquationResult(b0, b1, b2, b12));

                Button_AddPoint.IsEnabled = true;
            }
            else
            {
                MessageBox.Show(
                    "Введите вещественные числа с разделителем запятая.",
                    "Ошибка",
                    MessageBoxButton.OK,
                    MessageBoxImage.Error
                    );
            }
        }