[Рефераты, сочинения, доклады, презентации ]

Метод Девидона-Флетчера-Пауелла программа C#

 public double[] DFPMethod()

        {

            derF = derFunc(0);

            double normo4ka = Norm(derF);

            if (normo4ka <= eps1)

            {

                FOpt = F(x[0]);

                return x[0];

            }

            k = 0;

            Nu = new double[derF.Length,derF.Length];

            for (int i = 0; i < Nu.GetLength(0); i++)

            {

                for (int j = 0; j < Nu.GetLength(1); j++)

                {

                    if (i == j) Nu[i, j] = 1;

                    else Nu[i, j] = 0;

                }

            }

            p = new List<double[]>();

            do

            {

                p.Add(Ext.VecMat(Ext.BigScalarMultiplay(Nu, -1), derF));

                fib = new Fibonacci();

                fib.F = FuncForOptimization;

                fib.FibFunc(0, 10, eps2);

                Lambda = fib.XOpt;

                megaDerF = megaDerFunc(k);

                normo4ka = Norm(megaDerF);

                if (normo4ka <= eps1) break;

                x.Add(Ext.Plus(x[k], Ext.ScalarMultiplay(p[k], Lambda)));

                deltaG = Ext.Minus(derFunc(k + 1), derF);

                deltaX = Ext.Minus(x[k + 1], x[k]);

 

                double[,] first = Ext.BigScalarMultiplay(Ext.MultiplayColVecOnRowVec(deltaX, deltaX), (1/Ext.Multiplay(deltaX, deltaG)));

                double[,] second = Ext.BigScalarMultiplay(Ext.MultiplayMatrix(Ext.MultiplayColVecOnRowVec(Ext.VecMat(Nu, deltaG), deltaG), Ext.TransMat(Nu)), (1 / Ext.Multiplay(Ext.VecMat(Nu, deltaG), deltaG)));

                Nu = Ext.MinusMatrix(Ext.PlusMatrix(Nu, first), second);

                Console.WriteLine(Lambda + "\t" + normo4ka + "\t" + k);

                k++;            }

            while (normo4ka > eps1);

            Console.WriteLine(k);

            FOpt = F(x[k]);            return x[k];        }