C#, Cálculo numérico: método de cálculo y programa fuente del método iterativo de Powell (Powell)

 

usando Sistema;

espacio de nombres Legalsoft.Truffer
{     clase pública Powell: método de línea     {         iter privado int { get; colocar; }         doble traste privado { get; colocar; }         ftol doble privado { get; colocar; }




        public Powell(función RealValueFun, doble ftoll = 3.0e-8): base(func)
        {             //this.Linemethod < T > = func;             this.ftol = ftol;         }


        público doble[] minimizar(doble[] pp)
        {             int n = pp.Longitud;             doble[,] ximat = nuevo doble[n, n];             for (int i = 0; i < n; i++)             {                 ximat[i, i] = 1.0;             }             retorno (minimizar(pp, ximat));         }







        público doble[] minimizar(doble[] pp, doble[,] ximat)
        {             const int ITMAX = 200;             const doble PEQUEÑO = 1.0e-25;

            doble fptt;
            int n = pp.Longitud;
            //p = páginas;
            p = Globals.CopyFrom(pp);
            doble[] pt = nuevo doble[n];
            doble[] ptt = nuevo doble[n];
            //xi.resize(n);
            xi = nuevo doble[n];
            traste = func.funk(p);
            for (int j = 0; j < n; j++)
            {                 pt[j] = p[j];             }             for (iter = 0; ; ++iter)             {                 double fp = traste;                 int igrande = 0;                 doble eliminación = 0,0;                 para (int i = 0; i < n; i++)








                {                     para (int j = 0; j < n; j++)                     {                         xi[j] = ximat[j, i];                     }                     fptt = traste;                     traste = linmin();                     if (fptt - traste > del)                     {                         del = fptt - traste;                         igrande = i + 1;                     }                 }                 if (2.0 * (fp - traste) <= ftol * (Math.Abs(fp) + Math.Abs(traste)) + TINY)                 {                     return p;                 }                 si (iter == ITMAX)

















                {                     throw new Exception("powell excede el máximo de iteraciones.");                 }                 for (int j = 0; j < n; j++)                 {                     ptt[j] = 2.0 * p[j] - pt[j];                     xi[j] = p[j] - pt[j];                     pto[j] = p[j];                 }                 fptt = func.funk(ptt);                 if (fptt < fp)                 {                     doble t = 2.0 * (fp - 2.0 * traste + fptt) * Globals.SQR(fp - traste - del) - del * Globals.SQR(fp - fptt);                     if (t < 0.0)                     {                         traste = linmin();















                        for (int j = 0; j < n; j++)
                        {                             ximat[j, ibig - 1] = ximat[j, n - 1];                             ximat[j, n - 1] = xi[j];                         }                     }                 }             }         }     } }









 

Supongo que te gusta

Origin blog.csdn.net/beijinghorn/article/details/132286483
Recomendado
Clasificación