亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? asa_cg.cpp

?? 數學計算程序
?? CPP
?? 第 1 頁 / 共 5 頁
字號:
/* =========================================================================   ============================== ASA_CG ===================================   =========================================================================       ________________________________________________________________      | A Conjugate Gradient (cg_descent) based Active Set Algorithm   |      |                                                                |      |                  Version 1.0  (May 18, 2008)                   |      |                                                                |      |        William W. Hager    and      Hongchao Zhang             |      |        hager@math.ufl.edu         hzhang@math.ufl.edu          |      |  Department of Mathematics      Department of Mathematics      |      |     University of Florida       Louisiana State University     |      |  Gainesville, Florida 32611      Baton Rouge, Louisiana        |      |     352-392-0281 x 244                                         |      |                                                                |      |      Copyright by William W. Hager and Hongchao Zhang          |      |                                                                |      |          http://www.math.ufl.edu/~hager/papers/CG              |      |________________________________________________________________|       ________________________________________________________________      |This program is free software; you can redistribute it and/or   |      |modify it under the terms of the GNU General Public License as  |      |published by the Free Software Foundation; either version 2 of  |      |the License, or (at your option) any later version.             |      |This program is distributed in the hope that it will be useful, |      |but WITHOUT ANY WARRANTY; without even the implied warranty of  |      |MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   |      |GNU General Public License for more details.                    |      |                                                                |      |You should have received a copy of the GNU General Public       |      |License along with this program; if not, write to the Free      |      |Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, |      |MA  02110-1301  USA                                             |      |________________________________________________________________|*/#include "asa_user.h"#include <iostream>#include "asa_cg.h"using namespace std;static int iii = 1;int asa_cg /*  return:                      -2 (function value became nan in cg)                      -1 (starting function value is nan in cg)                       0 (convergence tolerance satisfied)                       1 (change in func <= feps*|f| in cg)                       2 (cg iterations in all passes or                          in one pass exceeded their limit)                       3 (slope always negative in line search in cg)                       4 (number secant iterations exceed nsecant in cg)                       5 (search direction not a descent direction in cg)                       6 (line search fails in initial interval in cg)                       7 (line search fails during bisection in cg)                       8 (line search fails during interval update in cg)                       9 (debugger is on and the function value increases in cg)                      10 (out of memory)                      11 (cbb iterations in all passes or                          in one pass exceeded their limit)                      12 (line search failed in cbb iteration)                      13 (search direction in cbb is not descent direction)                      14 (function value became nan in cbb) */(    double            *x, /* input: starting guess, output: the solution */    double           *lo, /* lower bounds */    double           *hi, /* upper bounds */    INT32                n, /* problem dimension */    asa_stat       *Stat, /* structure with statistics (can be NULL) */    asacg_parm    *CParm, /* user parameters, NULL = use default parameters */    asa_parm      *AParm, /* user parameters, NULL = use default parameters */    double      grad_tol, /* |Proj (x_k - g_k) - x_k|_inf <= grad_tol */    double      (*value) (double *, INT32),/* f = value (x, n) */    void         (*grad) (double *, double *, INT32),/* grad (g, x, n) */    double    (*valgrad) (double *, double *, INT32),/* f = valgrad (g, x, n),                          NULL = compute value & gradient using value & grad */    double        *Work  /* either work array of size 7n + memory (m) or NULL */){    int gp, ident, j, nfree, status, *ifree ;    INT32 cbb_totit, cg_totit ;    double alpha, gj, pert_lo, pert_hi, t, tl, th, gnorm, ginorm, pgnorm, xnorm,           xj, xg, xp, *work, *d, *g, *xtemp, *gtemp, *pg ;    asacg_parm *cgParm, cgParmStruc ;    asa_parm *asaParm, asaParmStruc ;    asa_com Com ;/* initialize the parameters */    if ( CParm == NULL )    {        cgParm = &cgParmStruc ;        asa_cg_default (cgParm) ;    }    else cgParm = CParm ;    if ( cgParm->PrintParms ) asa_printcgParms (cgParm) ;    if ( AParm == NULL )    {        asaParm = &asaParmStruc ;        asa_default (asaParm) ;    }    else asaParm = AParm ;    if ( asaParm->PrintParms ) asa_printParms (asaParm) ;    /* abort after maxit iterations of cbb in one pass */    if ( asaParm->maxit_fac == INF ) Com.pgmaxit = INT_INF ;    else Com.pgmaxit = (INT32) (((double) n)*asaParm->maxit_fac) ;    /* abort after totit iterations of cbb in all passes */    if ( asaParm->totit_fac == INF ) cbb_totit = INT_INF ;    else cbb_totit = (INT32) (((double) n)*asaParm->totit_fac) ;    /* abort after maxfunc function evaluation in one pass of cbb */    if ( asaParm->maxfunc_fac == INF ) Com.pgmaxfunc = INT_INF ;    else Com.pgmaxfunc = (INT32) (((double) n)*asaParm->maxfunc_fac) ;    /* abort after totit iterations of cg in all passes */    if ( cgParm->totit_fac == INF ) cg_totit = INT_INF ;    else cg_totit = (INT32) (((double) n)*cgParm->totit_fac) ;    pert_lo = asaParm->pert_lo ;    pert_hi = asaParm->pert_hi ;    Com.tau1 = asaParm->tau1 ;    Com.tau2 = asaParm->tau2 ;    Com.cgParm = cgParm ;    Com.asaParm = asaParm ;    Com.x = x ;    Com.n = n ;             /* problem dimension */    Com.n5 = n % 5 ;    Com.nf = (INT32) 0 ;      /* number of function evaluations */    Com.ng = (INT32) 0 ;      /* number of gradient evaluations */    Com.cbbiter = (INT32) 0 ; /* number of cbb iterations evaluations */    Com.cgiter = (INT32) 0 ;  /* number of cg iterations */    Com.AWolfe = cgParm->AWolfe ; /* do not touch user's AWolfe */    Com.AArmijo = asaParm->AArmijo ; /* do not touch user's AArmijo */    Com.value = value ;    Com.grad = grad ;    Com.valgrad = valgrad ;    Com.DimReduce = FALSE ;    ifree = Com.ifree = (int*)malloc (n*sizeof (int)) ;    if ( Work == NULL ) work = (double*)malloc ((5*n+asaParm->m)*sizeof (double)) ;    else                work = Work ;    if ( work == NULL )    {        printf ("Insufficient memory for specified problem dimension %e\n",                 (double) n) ;        status = 10 ;        return (status) ;    }    d = Com.d = work ;    g = Com.g = d+n ;    xtemp = Com.xtemp = g+n ;    gtemp = Com.gtemp = xtemp+n ;    pg = Com.pg = gtemp+n ;    Com.lastfvalues = pg+n ; /* size asaParm->m */    Com.lo = lo ;    Com.hi = hi ;    Com.cbbiter = 0 ;    Com.cbbfunc = 0 ;    Com.cbbgrad = 0 ;    Com.cgiter = 0 ;    Com.cgfunc = 0 ;    Com.cggrad = 0 ;    ident = FALSE ;    xnorm = ZERO ;    for (j = 0; j < n; j++)    {        t = x [j] ;        if      ( t > hi [j] ) t = hi [j] ;        else if ( t < lo [j] ) t = lo [j] ;        x [j] = t ;        if ( xnorm < fabs (t) ) xnorm = fabs (t) ;    }    Com.f = asa_fg (g, x, &Com) ;    pgnorm = ZERO ;    gnorm = ZERO ;    for (j = 0; j < n; j++)    {        xj = x [j] ;        gj = g [j] ;        xg = xj - gj ;        if      ( xg > hi [j] ) xp = hi [j] - xj ;        else if ( xg < lo [j] ) xp = lo [j] - xj ;        else                    xp = -gj ;        pg [j] = xp ;        pgnorm = MAX (pgnorm, fabs (xp)) ;        gnorm = MAX (gnorm, fabs (gj)) ;    }    if ( asaParm->StopRule ) Com.tol = MAX (pgnorm*asaParm->StopFac, grad_tol) ;    else                     Com.tol = grad_tol ;    Com.pgnorm = Com.pgnorm_start = pgnorm ;    if ( asa_tol (pgnorm, &Com) )    {        status = 0 ;        goto Exit ;    }    if ( xnorm != ZERO ) Com.alpha = alpha = xnorm/gnorm ;    else                 Com.alpha = alpha = ONE/gnorm ;    /* compute gradient norm for inactive variables */    ginorm = ZERO ;    nfree = 0 ;    gp = FALSE ;    for (j = 0; j < n; j++)    {        xj = x [j] ;        tl = lo [j] ;        th = hi [j] ;        gj = g [j] ;        xg = xj - alpha*gj ;        if      ( (xg >= th) && (th-xj > pert_hi) ) gp = TRUE ;        else if ( (xg <= tl) && (xj-tl > pert_lo) ) gp = TRUE ;        if ( (xj-tl > pert_lo) && (th - xj > pert_hi) )        {            ginorm = MAX (ginorm, fabs (gj)) ;            ifree [nfree] = j ;            nfree++ ;        }    }    Com.ginorm = ginorm ;    Com.nfree = nfree ;    if ( asaParm->PrintLevel >= 1 )    {        printf ("\ninitial f = %14.6e pgnorm = %14.6e ginorm = %14.6e\n",                 Com.f, pgnorm, ginorm) ;        printf ("            nfree = %i xnorm = %14.6e gp = %i\n",                 nfree, xnorm, gp) ;    }    if ( (ginorm < Com.tau1*pgnorm) || gp || asaParm->GradProjOnly )    {        Com.cbbfunc = 1 ;        Com.cbbgrad = 1 ;        goto Grad_proj ;    }    else    {        Com.cgfunc = 1 ;        Com.cggrad = 1 ;        goto CG_descent ;    }    Grad_proj:    if ( asaParm->PrintLevel >= 1 ) printf ("\nGradProj:\n") ;    Com.DimReduce = FALSE ;    status = asa_grad_proj(&Com) ;    if ( asaParm->PrintLevel >= 1 )    {        printf ("exit Grad_proj\n") ;    }    if ( Com.cbbiter >= cbb_totit ) status = 11 ;    if ( status >= 0 ) goto Exit ;    /* extract free variable */    nfree = 0 ;    for (j = 0; j < n; j++)    {        xj = x [j] ;        if ( (xj-lo [j] > pert_lo) && (hi [j] - xj > pert_hi) )        {            ifree [nfree] = j ;            nfree++ ;        }    }    Com.nfree = nfree ;    CG_descent:    if ( nfree != n )    {       asa_shrink_all (&Com) ;       asa_copy (xtemp+nfree, x+nfree, n-nfree) ;       Com.DimReduce = TRUE ;    }    else Com.DimReduce = FALSE ;    if ( asaParm->PrintLevel >= 1 ) printf ("\nCG:\n") ;    status = asa_descent (&Com) ;    if ( asaParm->PrintLevel >= 1 )    {        printf ("exit the CG subroutine\n") ;    }    if ( Com.DimReduce ) asa_expand_all (&Com) ;    if ( Com.cgiter >= cg_totit ) status = 2 ;    if ( status >= -2 ) goto Exit ;    /* ginorm < tau2* pgnorm without hitting boundary */    if ( status == -5 )    {        Com.alpha = asa_init_bbstep (&Com) ;        goto Grad_proj ;    }    /* ginorm >= tau2* pgnorm and many components of x hit boundary  */    else if ( status == -4 )    {        ginorm = ZERO ;        nfree = 0 ;        for (j = 0 ; j < n; j++)        {            xj = x [j] ;            if ( (xj-lo [j] > pert_lo) && (hi [j] - xj > pert_hi) )            {                t = fabs (g [j]) ;                ginorm = MAX (ginorm, t) ;                ifree [nfree] = j ;                nfree++ ;            }        }        Com.nfree = nfree ;        Com.ginorm = ginorm ;        if ( ginorm >= Com.tau1*Com.pgnorm ) goto CG_descent ;        else        {           if ( asaParm->PrintLevel >= 1 ) printf ("ginorm < tau1* pgnorm\n") ;           Com.alpha = asa_init_bbstep (&Com) ;           goto Grad_proj ;        }    }    /* ginorm >= tau2* pgnorm and only one component of x hits boundary */    else if ( status == -3 )    {        if ( pgnorm < asaParm->pgdecay*MAX (Com.pgnorm_start, ONE) )        {            ident = asa_identify (x, g, Com.pgnorm, &Com) ;        }        if ( ident )        {            ident = FALSE ;            ginorm = ZERO ;            nfree = 0 ;            for (j = 0 ; j < n; j++)            {                xj = x [j] ;                if ( (xj-lo [j] > pert_lo) && (hi [j] - xj > pert_hi) )                {                    t = fabs (g [j]) ;                    ginorm = MAX (ginorm, t) ;                    ifree [nfree] = j ;                    nfree++ ;                }            }            Com.nfree = nfree ;            Com.ginorm = ginorm ;            if ( ginorm >= Com.tau1*Com.pgnorm ) goto CG_descent ;            else            {               if ( asaParm->PrintLevel >= 1 )                   printf ("ginorm < tau1* pgnorm\n" ) ;               Com.alpha = asa_init_bbstep (&Com) ;               goto Grad_proj ;            }        }        else        {            Com.alpha = asa_init_bbstep (&Com) ;            goto Grad_proj ;        }    }    Exit:    if ( (asaParm->PrintFinal) || (asaParm->PrintLevel >= 1) )    {        const char mess1 [] = "Possible causes of this error message:" ;        const char mess2 [] = "   - your tolerance may be too strict: "                              "grad_tol = " ;        const char mess4 [] = "   - your gradient routine has an error" ;        const char mess5 [] = "   - the parameter epsilon in "                              "asa_descent_c.parm is too small" ;        printf ("\nFinal convergence status = %d\n", status);        if ( status == -2 )        {            printf ("Function value became nan at cg iteration %10.0e\n",                     (double) Com.cgiter) ;        }        else if ( status == -1 )        {            printf ("Function value of starting point is nan at "                     "cg iteration %10.0f\n", (double) Com.cgiter) ;        }        else if ( status == 0 )        {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
天天做天天摸天天爽国产一区| 国产麻豆视频一区二区| 精品一区二区在线看| 色综合婷婷久久| 久久视频一区二区| 午夜国产精品影院在线观看| 菠萝蜜视频在线观看一区| 欧美午夜理伦三级在线观看| 国产亚洲成aⅴ人片在线观看 | 欧美韩国日本不卡| 久久久久久久综合日本| 91精品久久久久久久99蜜桃| 国产精品久久三| 激情都市一区二区| 日韩欧美国产系列| 日韩制服丝袜av| 欧美日韩一区 二区 三区 久久精品| 国产欧美一区二区精品性色| 免费看日韩a级影片| 欧美日韩成人激情| 亚洲一区在线电影| 色综合天天狠狠| 国产精品国产三级国产aⅴ无密码| 久久99这里只有精品| 91国偷自产一区二区三区成为亚洲经典 | 欧美亚日韩国产aⅴ精品中极品| 2020国产精品自拍| 激情综合五月婷婷| 日韩一区二区视频| 久久精品国产一区二区三| 欧美日韩国产综合视频在线观看 | 亚洲国产精品成人综合| 久久精品国产亚洲5555| 欧美成人精品1314www| 美国欧美日韩国产在线播放| 欧美高清一级片在线| 午夜精品福利在线| 欧美精品xxxxbbbb| 日本不卡123| 精品日韩99亚洲| 激情综合色播五月| 久久久久久日产精品| 国产高清不卡一区| 国产精品嫩草影院com| 色综合夜色一区| 午夜精品久久久久久久| 91精品国产入口| 久久成人精品无人区| 精品国产一二三| 国产美女主播视频一区| 国产精品美女久久福利网站| 99riav一区二区三区| 亚洲国产精品欧美一二99| 欧美三级韩国三级日本三斤| 亚洲成av人片一区二区三区| 日韩午夜激情免费电影| 国产一二精品视频| 日韩码欧中文字| 制服.丝袜.亚洲.另类.中文| 黑人精品欧美一区二区蜜桃| 国产精品入口麻豆九色| 在线视频中文字幕一区二区| 日本特黄久久久高潮| 日本一区二区三区四区在线视频 | 日韩精品久久理论片| 正在播放亚洲一区| 国产mv日韩mv欧美| 亚洲激情图片qvod| 精品国产区一区| 色综合天天综合狠狠| 天天免费综合色| 欧美韩国日本综合| 51久久夜色精品国产麻豆| 国产成人免费av在线| 一级特黄大欧美久久久| 日韩精品一区二区三区视频| 99精品在线观看视频| 久久精品国产在热久久| 亚洲精品成a人| 国产亚洲欧洲997久久综合 | 亚洲午夜久久久久久久久久久 | 欧美tickling网站挠脚心| 亚洲午夜久久久久| 国产精品色一区二区三区| 91麻豆精品国产91久久久资源速度 | 欧美在线看片a免费观看| 免费视频一区二区| 亚洲人被黑人高潮完整版| 精品国产一区二区三区久久影院| 91在线观看下载| 国产一区二区三区高清播放| 亚洲美女精品一区| 成人av电影免费在线播放| 秋霞影院一区二区| 一区二区成人在线| 国产精品区一区二区三区| 日韩欧美中文字幕制服| 色av成人天堂桃色av| 不卡大黄网站免费看| 国产成人综合在线播放| 秋霞av亚洲一区二区三| 亚洲一区二区三区自拍| 亚洲欧洲日韩女同| 欧美国产精品中文字幕| 国产成人精品午夜视频免费| 日韩极品在线观看| 国产精品第四页| 久久久久久久久免费| 成人免费看视频| 国产一区二区不卡在线| 国产一区二区三区免费观看| 日本视频一区二区三区| 免费观看成人av| 免费高清在线一区| 麻豆精品视频在线观看免费| 琪琪一区二区三区| 久久99久久精品| 精品影视av免费| 国产一区视频网站| 成人午夜精品一区二区三区| 国产精品一二三| 国产精品一区二区x88av| 九一九一国产精品| 日韩精品久久理论片| 午夜国产精品一区| 亚洲bt欧美bt精品| 麻豆视频一区二区| 亚洲一区二区三区影院| 亚洲品质自拍视频| 国产精品久99| 国产毛片精品国产一区二区三区| 日韩美女视频一区二区| 国产精品妹子av| 中文字幕免费一区| 夜夜精品视频一区二区| 成人欧美一区二区三区白人| 国产精品大尺度| 中文字幕日韩欧美一区二区三区| 精品美女被调教视频大全网站| 国产欧美日韩在线| 国产精品素人一区二区| 亚洲天堂网中文字| 一区二区三区免费| 日本不卡高清视频| 狠狠色综合色综合网络| 岛国一区二区在线观看| av福利精品导航| 在线观看免费一区| 7777精品伊人久久久大香线蕉完整版 | 欧美一级片在线看| 色久综合一二码| 4438亚洲最大| 日韩一区二区三区av| 欧美精品一区二区三区蜜桃| 国产精品久久久久影院老司| 1024国产精品| 久久av资源网| 在线看国产一区| 欧美一级二级三级蜜桃| 久久色.com| 亚洲自拍偷拍综合| 激情综合一区二区三区| 成人精品视频.| 日韩视频一区二区在线观看| 国产亚洲综合色| 老司机精品视频在线| 成人av动漫网站| 久久久一区二区三区| 日韩国产在线一| 欧美色电影在线| 日本中文在线一区| 91蜜桃婷婷狠狠久久综合9色| 7777精品伊人久久久大香线蕉完整版| 丁香婷婷综合网| 99国产精品久久| 国产精品久久久一本精品 | 亚洲欧美在线视频| 久草在线在线精品观看| 色老汉av一区二区三区| 国产日产欧美一区二区视频| 亚洲五码中文字幕| 99天天综合性| 日韩精品一区二区三区老鸭窝| 一区二区三区在线视频免费| 国产肉丝袜一区二区| 蜜桃视频在线观看一区二区| 91久久国产最好的精华液| 国产午夜精品久久久久久免费视 | 国产精品电影院| 成人黄色777网| 2021中文字幕一区亚洲| 国产专区欧美精品| 久久先锋影音av| 极品美女销魂一区二区三区| 日韩精品中文字幕一区| 一区二区三区波多野结衣在线观看| 成人高清视频在线| 国产农村妇女精品| 成人性色生活片| 国产精品欧美一区二区三区|