private void InternalRun()
        {
            for (NumberOfAdaptedMelt = 0; NumberOfAdaptedMelt < BaseLenth; NumberOfAdaptedMelt++)
            {
                CallCallback(NumberOfAdaptedMelt);
                LoadMeltData(NumberOfAdaptedMelt);
                Params.Tog      = Tube.Сталь.T;
                Tube.Сталь.Si   = 0.003;
                Tube.Шлак.FeO   = 0.701145 * Tube.Шлак.TOTALFeO - 0.586142;
                Tube.Шлак.Fe2O3 = Tube.Шлак.TOTALFeO - Tube.Шлак.FeO;
                Estimation.CALCULATE_TEPLCONSTANTS();

                // Значения диапазонов сканирования.
                Estimation.minGshl[0] = 0.07 * Tube.Сталь.GYield;
                Estimation.maxGshl[0] = 0.2 * Tube.Сталь.GYield;
                minL[0]                   = 0.1;
                maxL[0]                   = 0.3;
                minalfaFe[0]              = 0.005;
                maxalfaFe[0]              = 0.05;
                minTeplFutLoss[0]         = -10000000;
                maxTeplFutLoss[0]         = 60000000;
                Estimation.minGstYield[0] = 0.8 * Tube.Сталь.GYield;
                Estimation.maxGstYield[0] = 1.2 * Tube.Сталь.GYield;
                Estimation.minALFAizv[0]  = 0.2;
                Estimation.maxALFAizv[0]  = 1.0;

                // Расчет шагов сканирования для всех уточнений.
                Estimation.stepGshl[0] = (Estimation.maxGshl[0] - Estimation.minGshl[0]) / 4.0;
                stepL[0]                   = (maxL[0] - minL[0]) / 4.0;
                stepalfaFe[0]              = (maxalfaFe[0] - minalfaFe[0]) / 4.0;
                stepTeplFutLoss[0]         = (maxTeplFutLoss[0] - minTeplFutLoss[0]) / 4.0;
                Estimation.stepGstYield[0] = (Estimation.maxGstYield[0] - Estimation.minGstYield[0]) / 4.0;
                Estimation.stepALFAizv[0]  = (Estimation.maxALFAizv[0] - Estimation.minALFAizv[0]) / 4.0;

                // Расчет для 1 - 5 кругов вычислений.
                for (var i = 1; i < 6; i++)
                {
                    Estimation.stepGshl[i] = Estimation.stepGshl[i - 1] / 2.0;
                    stepL[i]                   = stepL[i - 1] / 2.0;
                    stepalfaFe[i]              = stepalfaFe[i - 1] / 2.0;
                    stepTeplFutLoss[i]         = stepTeplFutLoss[i - 1] / 6.0;
                    Estimation.stepGstYield[i] = Estimation.stepGstYield[i - 1] / 2.0;
                    Estimation.stepALFAizv[i]  = Estimation.stepALFAizv[i - 1] / 2.0;
                }

                adaptCOMPAIR = 100;

                for (adaptROUND = 0; adaptROUND < 6; adaptROUND++)
                {
                    if (_isFixedMass)
                    {
                        Tube.Шлак.G        = Estimation.minGshl[adaptROUND];
                        Params.L           = minL[adaptROUND];
                        Params.alfaFe      = minalfaFe[adaptROUND];
                        Params.TeplFutLoss = minTeplFutLoss[adaptROUND];

                        do
                        {
                            do
                            {
                                do
                                {
                                    do
                                    {
                                        Estimation.Balances_Calc();
                                        adaptMistakeTOTAL = Math.Abs((Estimation.LeftSHL - Estimation.RightSHL) / Estimation.RightSHL) +
                                                            Math.Abs((Estimation.LeftTEPL - Estimation.RightTEPL) / Estimation.RightTEPL) +
                                                            Math.Abs((Estimation.LeftO2 - Estimation.RightO2) / Estimation.RightO2) +
                                                            Math.Abs((Estimation.LeftMAT - Estimation.RightMAT) / Estimation.RightMAT);

                                        if (adaptMistakeTOTAL <= adaptCOMPAIR)
                                        {
                                            adaptCOMPAIR                = adaptMistakeTOTAL;
                                            GshlSAVE[adaptROUND]        = Tube.Шлак.G;
                                            LSAVE[adaptROUND]           = Params.L;
                                            alfaFeSAVE[adaptROUND]      = Params.alfaFe;
                                            TeplFutLossSAVE[adaptROUND] = Params.TeplFutLoss;
                                        }

                                        Params.TeplFutLoss += stepTeplFutLoss[adaptROUND];
                                    } while (Params.TeplFutLoss <= maxTeplFutLoss[adaptROUND]);

                                    Params.TeplFutLoss = minTeplFutLoss[adaptROUND];
                                    Params.alfaFe     += stepalfaFe[adaptROUND];
                                } while (Params.alfaFe <= maxalfaFe[adaptROUND]);

                                Params.alfaFe = minalfaFe[adaptROUND];
                                Params.L     += stepL[adaptROUND];
                            } while (Params.L <= maxL[adaptROUND]);

                            Params.L     = minL[adaptROUND];
                            Tube.Шлак.G += Estimation.stepGshl[adaptROUND];
                        } while (Tube.Шлак.G <= Estimation.maxGshl[adaptROUND]);

                        Tube.Шлак.G = Estimation.minGshl[adaptROUND];

                        Estimation.minGshl[adaptROUND + 1] = GshlSAVE[adaptROUND] - Estimation.stepGshl[adaptROUND];
                        minL[adaptROUND + 1]               = LSAVE[adaptROUND] - stepL[adaptROUND];
                        minalfaFe[adaptROUND + 1]          = alfaFeSAVE[adaptROUND] - stepalfaFe[adaptROUND];
                        minTeplFutLoss[adaptROUND + 1]     = TeplFutLossSAVE[adaptROUND] - stepTeplFutLoss[adaptROUND];
                        Estimation.maxGshl[adaptROUND + 1] = GshlSAVE[adaptROUND] + Estimation.stepGshl[adaptROUND];
                        maxL[adaptROUND + 1]               = LSAVE[adaptROUND] + stepL[adaptROUND];
                        maxalfaFe[adaptROUND + 1]          = alfaFeSAVE[adaptROUND] + stepalfaFe[adaptROUND];
                        maxTeplFutLoss[adaptROUND + 1]     = TeplFutLossSAVE[adaptROUND] + stepTeplFutLoss[adaptROUND];
                    }
                    else
                    {
                        // Расчет при неизвестной(плавающей массе продукта)
                        Tube.Сталь.G       = Estimation.minGstYield[adaptROUND];
                        Tube.Шлак.G        = Estimation.minGshl[adaptROUND];
                        Tube.Известь.ALFA  = Estimation.minALFAizv[adaptROUND];
                        Params.L           = minL[adaptROUND];
                        Params.TeplFutLoss = minTeplFutLoss[adaptROUND];

                        Params.alfaFe = 0.013;

                        do
                        {
                            do
                            {
                                do
                                {
                                    do
                                    {
                                        do
                                        {
                                            Estimation.Balances_Calc();
                                            adaptMistakeTOTAL =
                                                Math.Abs((Estimation.LeftCaOiMgO - Estimation.RightCaOiMgO) / Estimation.RightCaOiMgO) +
                                                Math.Abs((Estimation.LeftSHL - Estimation.RightSHL) / Estimation.RightSHL) +
                                                Math.Abs((Estimation.LeftTEPL - Estimation.RightTEPL) / Estimation.RightTEPL) +
                                                Math.Abs((Estimation.LeftO2 - Estimation.RightO2) / Estimation.RightO2) +
                                                Math.Abs((Estimation.LeftMAT - Estimation.RightMAT) / Estimation.RightMAT) +
                                                Math.Abs((Estimation.LeftSi - Estimation.RightSi) / Estimation.RightSi) +
                                                Math.Abs((Estimation.LeftMn - Estimation.RightMn) / Estimation.RightMn);

                                            if (adaptMistakeTOTAL <= adaptCOMPAIR)
                                            {
                                                adaptCOMPAIR = adaptMistakeTOTAL;
                                                Estimation.GstYieldSAVE[adaptROUND] = Tube.Сталь.GYield;
                                                GshlSAVE[adaptROUND] = Tube.Шлак.G;
                                                LSAVE[adaptROUND]    = Params.L;
                                                Estimation.ALFAizvSAVE[adaptROUND] = Tube.Известь.ALFA;
                                                TeplFutLossSAVE[adaptROUND]        = Params.TeplFutLoss;
                                            }

                                            Params.TeplFutLoss += stepTeplFutLoss[adaptROUND];
                                        } while (Params.TeplFutLoss <= maxTeplFutLoss[adaptROUND]);

                                        Params.TeplFutLoss = minTeplFutLoss[adaptROUND];
                                        Tube.Известь.ALFA += Estimation.stepALFAizv[adaptROUND];
                                    } while (Tube.Известь.ALFA <= Estimation.maxALFAizv[adaptROUND]);

                                    Tube.Известь.ALFA = Estimation.minALFAizv[adaptROUND];
                                    Params.L         += stepL[adaptROUND];
                                } while (Params.L <= maxL[adaptROUND]);

                                Params.L     = minL[adaptROUND];
                                Tube.Шлак.G += Estimation.stepGshl[adaptROUND];
                            } while (Tube.Шлак.G <= Estimation.maxGshl[adaptROUND]);

                            Tube.Шлак.G        = Estimation.minGshl[adaptROUND];
                            Tube.Сталь.GYield += Estimation.stepGstYield[adaptROUND];
                        } while (Tube.Сталь.GYield <= Estimation.maxGstYield[adaptROUND]);

                        Tube.Сталь.GYield = Estimation.minGstYield[adaptROUND];

                        Estimation.minGstYield[adaptROUND + 1] = Estimation.GstYieldSAVE[adaptROUND] - Estimation.stepGstYield[adaptROUND];
                        Estimation.minGshl[adaptROUND + 1]     = GshlSAVE[adaptROUND] - Estimation.stepGshl[adaptROUND];
                        minL[adaptROUND + 1] = LSAVE[adaptROUND] - stepL[adaptROUND];
                        Estimation.minALFAizv[adaptROUND + 1] = Estimation.ALFAizvSAVE[adaptROUND] - Estimation.stepALFAizv[adaptROUND];
                        minTeplFutLoss[adaptROUND + 1]        = TeplFutLossSAVE[adaptROUND] - stepTeplFutLoss[adaptROUND];

                        // Верхняя граница
                        Estimation.maxGstYield[adaptROUND + 1] = Estimation.GstYieldSAVE[adaptROUND] + Estimation.stepGstYield[adaptROUND];
                        Estimation.maxGshl[adaptROUND + 1]     = GshlSAVE[adaptROUND] + Estimation.stepGshl[adaptROUND];
                        maxL[adaptROUND + 1] = LSAVE[adaptROUND] + stepL[adaptROUND];
                        Estimation.maxALFAizv[adaptROUND + 1] = Estimation.ALFAizvSAVE[adaptROUND] + Estimation.stepALFAizv[adaptROUND];
                        maxTeplFutLoss[adaptROUND + 1]        = TeplFutLossSAVE[adaptROUND] + stepTeplFutLoss[adaptROUND];

                        // Проверка нижней границы на неотрицательность
                        if (Estimation.minGstYield[adaptROUND + 1] < Estimation.minGstYield[0])
                        {
                            Estimation.minGstYield[adaptROUND + 1] = Estimation.minGstYield[0];
                            Estimation.maxGstYield[adaptROUND + 1] = Estimation.minGstYield[adaptROUND + 1] +
                                                                     2 * Estimation.stepGstYield[adaptROUND];
                        }

                        if (Estimation.minGshl[adaptROUND + 1] < Estimation.minGshl[0])
                        {
                            Estimation.minGshl[adaptROUND + 1] = Estimation.minGshl[0];
                            Estimation.maxGshl[adaptROUND + 1] = Estimation.minGshl[adaptROUND + 1] + 2 * Estimation.stepGshl[adaptROUND];
                        }

                        if (minL[adaptROUND + 1] < minL[0])
                        {
                            minL[adaptROUND + 1] = minL[0];
                            maxL[adaptROUND + 1] = minL[adaptROUND + 1] + 2 * stepL[adaptROUND];
                        }

                        if (Estimation.minALFAizv[adaptROUND + 1] < Estimation.minALFAizv[0])
                        {
                            Estimation.minALFAizv[adaptROUND + 1] = Estimation.minALFAizv[0];
                            Estimation.maxALFAizv[adaptROUND + 1] = Estimation.minALFAizv[adaptROUND + 1] +
                                                                    2 * Estimation.stepALFAizv[adaptROUND];
                        }

                        if (minTeplFutLoss[adaptROUND + 1] < minTeplFutLoss[0])
                        {
                            minTeplFutLoss[adaptROUND + 1] = minTeplFutLoss[0];
                            maxTeplFutLoss[adaptROUND + 1] = minTeplFutLoss[adaptROUND + 1] + 2 * stepTeplFutLoss[adaptROUND];
                        }

                        Tube.Шлак.P2O5 = (Tube.Чугун.G * Tube.Чугун.P + Tube.Лом.G * Tube.Лом.P +
                                          Tube.Известь.ALFA * Tube.Известь.G * Tube.Известь.P2O5 * 62.0 / 142.0 +
                                          Tube.Известняк.ALFA * Tube.Известняк.G * Tube.Известняк.P2O5 * 62.0 / 142.0 +
                                          Tube.Окалина.ALFA * Tube.Окалина.G * Tube.Окалина.P + Tube.уда.ALFA * Tube.уда.G * Tube.уда.P +
                                          Tube.Футеровка.G * Tube.Футеровка.P2O5 * 62.0 / 142.0 +
                                          Tube.ОставленныйШлак.G * Tube.ОставленныйШлак.P2O5 * 62.0 / 142.0 +
                                          Tube.МиксерныйШлак.G * Tube.МиксерныйШлак.P2O5 * 62.0 / 142.0 +
                                          Tube.Ферросплав.ALFA * Tube.Ферросплав.G * Tube.Ферросплав.P -
                                          (Estimation.GstYieldSAVE[adaptROUND] / (1 - Tube.Ферросплав.ALFA - Params.StAndShlLoss)) *
                                          Tube.Сталь.P) /
                                         (GshlSAVE[adaptROUND] * 62.0 / 142.0);
                    }
                }

                // Выполняются только при первом варианте адаптации
                if (_isFixedMass)
                {
                    // Расчет основности шлака
                    TempLeft =
                        Tube.Известь.ALFA * Tube.Известь.G * (Tube.Известь.CaO + Tube.Известь.MgO) +
                        Tube.Известняк.ALFA * Tube.Известняк.G * 56 / 100 * Tube.Известняк.CaCO3 +
                        Tube.Доломит.ALFA * Tube.Доломит.G * (Tube.Доломит.CaO + Tube.Доломит.MgO) +
                        Tube.Шпат.ALFA * Tube.Шпат.G * Tube.Шпат.CaO + Tube.Окалина.ALFA * Tube.Окалина.G * Tube.Окалина.MgO +
                        Tube.ВлажныйДоломит.ALFA * Tube.ВлажныйДоломит.G * (Tube.ВлажныйДоломит.CaO + Tube.ВлажныйДоломит.MgO) +
                        Tube.Имф.ALFA * Tube.Имф.G * (Tube.Имф.CaO + Tube.Имф.MgO) +
                        Tube.Футеровка.G * (Tube.Футеровка.CaO + Tube.Футеровка.MgO) +
                        Tube.Агломерат.ALFA * Tube.Агломерат.G * Tube.Агломерат.CaO + Tube.уда.ALFA * Tube.уда.G * Tube.уда.CaO +
                        Tube.ОставленныйШлак.G * (Tube.ОставленныйШлак.CaO + Tube.ОставленныйШлак.MgO) +
                        Tube.МиксерныйШлак.G * (Tube.МиксерныйШлак.CaO + Tube.МиксерныйШлак.MgO);

                    TempRight =
                        60 / 28 *
                        (Tube.Чугун.G * Tube.Чугун.Si + Tube.Лом.G * Tube.Лом.Si +
                         Tube.Ферросплав.ALFA * Tube.Ферросплав.G * Tube.Ферросплав.Si -
                         (Tube.Сталь.GYield / (1 - alfaFeSAVE[adaptROUND - 1] - Params.StAndShlLoss)) * Tube.Сталь.Si) +
                        Tube.ОставленныйШлак.G * Tube.ОставленныйШлак.SiO2 + Tube.МиксерныйШлак.G * Tube.МиксерныйШлак.SiO2 +
                        (Tube.Доломит.ALFA * Tube.Доломит.G * Tube.Доломит.SiO2 +
                         Tube.ВлажныйДоломит.ALFA * Tube.ВлажныйДоломит.G * Tube.ВлажныйДоломит.SiO2 +
                         Tube.Имф.ALFA * Tube.Имф.G * Tube.Имф.SiO2) +
                        (Tube.Шпат.ALFA * Tube.Шпат.G * Tube.Шпат.SiO2 + Tube.Известь.ALFA * Tube.Известь.G * Tube.Известь.SiO2 +
                         Tube.Известняк.ALFA * Tube.Известняк.G * Tube.Известняк.SiO2 + Tube.Футеровка.G * Tube.Футеровка.SiO2) +
                        (Tube.Окатыши.ALFA * Tube.Окатыши.G * Tube.Окатыши.SiO2 + Tube.уда.ALFA * Tube.уда.G * Tube.уда.SiO2 +
                         Tube.Окалина.ALFA * Tube.Окалина.G * Tube.Окалина.SiO2 + Tube.Песок.ALFA * Tube.Песок.G * Tube.Песок.SiO2);

                    Tube.Шлак.B = TempLeft / TempRight;

                    P2O5_calc();

                    if (adaptCOMPAIR * 100 < 2)
                    {
                        GoodMeltsQuant  = GoodMeltsQuant + 1;
                        SummGshl        = SummGshl + GshlSAVE[adaptROUND - 1];
                        SummL           = SummL + LSAVE[adaptROUND - 1];
                        SummAlfaFe      = SummAlfaFe + alfaFeSAVE[adaptROUND - 1];
                        SummTeplFutLoss = SummTeplFutLoss + TeplFutLossSAVE[adaptROUND - 1];
                    }
                }

                SaveMeltResults();
            }

            // Step11
        }