128 subroutine mainlb(n, m, x, l, u, nbd, f, g, factr, pgtol, ws, wy,
129 + sy, ss, wt, wn, snd, z, r, d, t, xp, wa,
130 + index, iwhere, indx2, task,
131 + iprint, csave, lsave, isave, dsave)
133 character*60 task, csave
135 integer n, m, iprint, nbd(n), index(n),
136 + iwhere(n), indx2(n), isave(23)
137 double precision f, factr, pgtol,
138 + x(n), l(n), u(n), g(n), z(n), r(n), d(n), t(n),
142 + ws(n, m), wy(n, m), sy(m, m), ss(m, m),
143 + wt(m, m), wn(2*m, 2*m), snd(2*m, 2*m), dsave(29)
175 logical prjctd,cnstnd,boxed,updatd,wrk
177 integer i,k,nintol,itfile,iback,nskip,
178 + head,col,iter,itail,iupdat,
179 + nseg,nfgv,info,ifun,
180 + iword,nfree,nact,ileave,nenter
181 double precision theta,fold,ddot,dr,rr,tol,
182 + xstep,sbgnrm,ddum,dnorm,dtd,epsmch,
183 + cpu1,cpu2,cachyt,sbtime,lnscht,time1,time2,
184 + gd,gdold,stp,stpmx,time
185 double precision one,zero
186 parameter (one=1.0d0,zero=0.0d0)
188 if (task .eq.
'START')
then
190 epsmch = epsilon(one)
241 if (iprint .ge. 1)
then
243 open (itfile, file =
'iterate.dat', status =
'unknown')
248 call errclb(n,m,factr,l,u,nbd,task,info,k)
249 if (task(1:5) .eq.
'ERROR')
then
250 call prn3lb(n,x,f,task,iprint,info,itfile,
251 + iter,nfgv,nintol,nskip,nact,sbgnrm,
252 + zero,nseg,word,iback,stp,xstep,k,
253 + cachyt,sbtime,lnscht)
257 call prn1lb(n,m,l,u,x,iprint,itfile,epsmch)
261 call active(n,l,u,nbd,x,iwhere,iprint,prjctd,cnstnd,boxed)
312 if (task(1:5) .eq.
'FG_LN')
goto 666
313 if (task(1:5) .eq.
'NEW_X')
goto 777
314 if (task(1:5) .eq.
'FG_ST')
goto 111
315 if (task(1:4) .eq.
'STOP')
then
316 if (task(7:9) .eq.
'CPU')
then
318 call dcopy(n,t,1,x,1)
319 call dcopy(n,r,1,g,1)
336 call projgr(n,l,u,nbd,x,g,sbgnrm)
338 if (iprint .ge. 1)
then
339 write (6,1002) iter,f,sbgnrm
340 write (itfile,1003) iter,nfgv,sbgnrm,f
342 if (sbgnrm .le. pgtol)
then
344 task =
'CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL'
351 if (iprint .ge. 99)
write (6,1001) iter + 1
354 if (.not. cnstnd .and. col .gt. 0)
then
356 call dcopy(n,x,1,z,1)
369 call cauchy(n,x,l,u,nbd,g,indx2,iwhere,t,d,z,
370 + m,wy,ws,sy,wt,theta,col,head,
371 + wa(1),wa(2*m+1),wa(4*m+1),wa(6*m+1),nseg,
372 + iprint, sbgnrm, epsmch)
374 cachyt = cachyt + cpu2 - cpu1
375 nintol = nintol + nseg
380 call freev(n,nfree,index,nenter,ileave,indx2,
381 + iwhere,wrk,updatd,cnstnd,iprint,iter)
389 if (nfree .eq. 0 .or. col .eq. 0)
goto 555
405 if (wrk)
call formk(n,nfree,index,nenter,ileave,indx2,iupdat,
406 + updatd,wn,snd,m,ws,wy,sy,theta,col,head,info)
407 if (info .ne. 0)
then
410 if(iprint .ge. 1)
write (6, 1006)
418 sbtime = sbtime + cpu2 - cpu1
424 call cmprlb(n,m,x,g,ws,wy,sy,wt,z,r,wa,index,
425 + theta,col,head,nfree,cnstnd)
429 call subsm( n, m, nfree, index, l, u, nbd, z, r, xp, ws, wy,
430 + theta, x, g, col, head, iword, wa, wn, iprint)
433 sbtime = sbtime + cpu2 - cpu1
449 call lnsrlb(n,l,u,nbd,x,f,fold,gd,gdold,g,d,r,t,z,stp,dnorm,
450 + dtd,xstep,stpmx,iter,ifun,iback,nfgv,info,task,
451 + boxed,cnstnd,csave,isave(22),dsave(17))
452 if (info .ne. 0 .or. iback .ge. 20)
then
454 call dcopy(n,t,1,x,1)
455 call dcopy(n,r,1,g,1)
459 if (info .eq. 0)
then
466 task =
'ABNORMAL_TERMINATION_IN_LNSRCH'
471 if(iprint .ge. 1)
write (6, 1008)
472 if (info .eq. 0) nfgv = nfgv - 1
479 task =
'RESTART_FROM_LNSRCH'
481 lnscht = lnscht + cpu2 - cpu1
484 else if (task(1:5) .eq.
'FG_LN')
then
490 lnscht = lnscht + cpu2 - cpu1
495 call projgr(n,l,u,nbd,x,g,sbgnrm)
499 call prn2lb(n,x,f,g,iprint,itfile,iter,nfgv,nact,
500 + sbgnrm,nseg,word,iword,iback,stp,xstep)
507 if (sbgnrm .le. pgtol)
then
509 task =
'CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL'
513 ddum = max(abs(fold), abs(f), one)
514 if ((fold - f) .le. tol*ddum)
then
516 task =
'CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH'
517 if (iback .ge. 10) info = -5
528 if (stp .eq. one)
then
532 dr = (gd - gdold)*stp
533 call dscal(n,stp,d,1)
537 if (dr .le. epsmch*ddum)
then
541 if (iprint .ge. 1)
write (6,1004) dr, ddum
556 call matupd(n,m,ws,wy,sy,ss,d,r,itail,
557 + iupdat,col,head,theta,rr,dr,stp,dtd)
564 call formt(m,wt,sy,ss,col,theta,info)
566 if (info .ne. 0)
then
569 if(iprint .ge. 1)
write (6, 1007)
592 call prn3lb(n,x,f,task,iprint,info,itfile,
593 + iter,nfgv,nintol,nskip,nact,sbgnrm,
594 + time,nseg,word,iback,stp,xstep,k,
595 + cachyt,sbtime,lnscht)
641 1001
format (//,
'ITERATION ',i5)
643 + (/,
'At iterate',i5,4x,
'f= ',1p,d12.5,4x,
'|proj g|= ',1p,d12.5)
644 1003
format (2(1x,i4),5x,
'-',5x,
'-',3x,
'-',5x,
'-',5x,
'-',8x,
'-',3x,
646 1004
format (
' ys=',1p,e10.3,
' -gs=',1p,e10.3,
' BFGS update SKIPPED')
648 +
' Nonpositive definiteness in Cholesky factorization in formk;',/,
649 +
' refresh the lbfgs memory and restart the iteration.')
651 +
' Nonpositive definiteness in Cholesky factorization in formt;',/,
652 +
' refresh the lbfgs memory and restart the iteration.')
654 +
' Bad direction in the line search;',/,
655 +
' refresh the lbfgs memory and restart the iteration.')
subroutine active(n, l, u, nbd, x, iwhere, iprint, prjctd, cnstnd, boxed)
This subroutine initializes iwhere and projects the initial x to the feasible set if necessary.
subroutine cauchy(n, x, l, u, nbd, g, iorder, iwhere, t, d, xcp, m, wy, ws, sy, wt, theta, col, head, p, c, wbp, v, nseg, iprint, sbgnrm, epsmch)
Compute the Generalized Cauchy Point along the projected gradient direction.
subroutine cmprlb(n, m, x, g, ws, wy, sy, wt, z, r, wa, index, theta, col, head, nfree, cnstnd)
This subroutine computes r=-Z'B(xcp-xk)-Z'g by using wa(2m+1)=W'(xcp-x) from subroutine cauchy.
subroutine errclb(n, m, factr, l, u, nbd, task, info, k)
This subroutine checks the validity of the input data.
subroutine freev(n, nfree, index, nenter, ileave, indx2, iwhere, wrk, updatd, cnstnd, iprint, iter)
This subroutine counts the entering and leaving variables when iter > 0, and finds the index set of f...
subroutine lnsrlb(n, l, u, nbd, x, f, fold, gd, gdold, g, d, r, t, z, stp, dnorm, dtd, xstep, stpmx, iter, ifun, iback, nfgv, info, task, boxed, cnstnd, csave, isave, dsave)
This subroutine calls subroutine dcsrch from the Minpack2 library to perform the line search....
subroutine mainlb(n, m, x, l, u, nbd, f, g, factr, pgtol, ws, wy, sy, ss, wt, wn, snd, z, r, d, t, xp, wa, index, iwhere, indx2, task, iprint, csave, lsave, isave, dsave)
This subroutine solves bound constrained optimization problems by using the compact formula of the li...
subroutine matupd(n, m, ws, wy, sy, ss, d, r, itail, iupdat, col, head, theta, rr, dr, stp, dtd)
This subroutine updates matrices WS and WY, and forms the middle matrix in B.
subroutine prn1lb(n, m, l, u, x, iprint, itfile, epsmch)
This subroutine prints the input data, initial point, upper and lower bounds of each variable,...
subroutine prn2lb(n, x, f, g, iprint, itfile, iter, nfgv, nact, sbgnrm, nseg, word, iword, iback, stp, xstep)
This subroutine prints out new information after a successful line search.
subroutine prn3lb(n, x, f, task, iprint, info, itfile, iter, nfgv, nintol, nskip, nact, sbgnrm, time, nseg, word, iback, stp, xstep, k, cachyt, sbtime, lnscht)
This subroutine prints out information when either a built-in convergence test is satisfied or when a...
subroutine projgr(n, l, u, nbd, x, g, sbgnrm)
This subroutine computes the infinity norm of the projected gradient.
subroutine subsm(n, m, nsub, ind, l, u, nbd, x, d, xp, ws, wy, theta, xx, gg, col, head, iword, wv, wn, iprint)
Performs the subspace minimization.
subroutine timer(ttime)
This routine computes cpu time in double precision.