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, info, epsmch)
373 if (info .ne. 0)
then
375 if(iprint .ge. 1)
write (6, 1005)
383 cachyt = cachyt + cpu2 - cpu1
387 cachyt = cachyt + cpu2 - cpu1
388 nintol = nintol + nseg
393 call freev(n,nfree,index,nenter,ileave,indx2,
394 + iwhere,wrk,updatd,cnstnd,iprint,iter)
402 if (nfree .eq. 0 .or. col .eq. 0)
goto 555
418 if (wrk)
call formk(n,nfree,index,nenter,ileave,indx2,iupdat,
419 + updatd,wn,snd,m,ws,wy,sy,theta,col,head,info)
420 if (info .ne. 0)
then
423 if(iprint .ge. 1)
write (6, 1006)
431 sbtime = sbtime + cpu2 - cpu1
437 call cmprlb(n,m,x,g,ws,wy,sy,wt,z,r,wa,index,
438 + theta,col,head,nfree,cnstnd,info)
439 if (info .ne. 0)
goto 444
443 call subsm( n, m, nfree, index, l, u, nbd, z, r, xp, ws, wy,
444 + theta, x, g, col, head, iword, wa, wn, iprint, info)
446 if (info .ne. 0)
then
449 if(iprint .ge. 1)
write (6, 1005)
457 sbtime = sbtime + cpu2 - cpu1
462 sbtime = sbtime + cpu2 - cpu1
478 call lnsrlb(n,l,u,nbd,x,f,fold,gd,gdold,g,d,r,t,z,stp,dnorm,
479 + dtd,xstep,stpmx,iter,ifun,iback,nfgv,info,task,
480 + boxed,cnstnd,csave,isave(22),dsave(17))
481 if (info .ne. 0 .or. iback .ge. 20)
then
483 call dcopy(n,t,1,x,1)
484 call dcopy(n,r,1,g,1)
488 if (info .eq. 0)
then
495 task =
'ABNORMAL_TERMINATION_IN_LNSRCH'
500 if(iprint .ge. 1)
write (6, 1008)
501 if (info .eq. 0) nfgv = nfgv - 1
508 task =
'RESTART_FROM_LNSRCH'
510 lnscht = lnscht + cpu2 - cpu1
513 else if (task(1:5) .eq.
'FG_LN')
then
519 lnscht = lnscht + cpu2 - cpu1
524 call projgr(n,l,u,nbd,x,g,sbgnrm)
528 call prn2lb(n,x,f,g,iprint,itfile,iter,nfgv,nact,
529 + sbgnrm,nseg,word,iword,iback,stp,xstep)
536 if (sbgnrm .le. pgtol)
then
538 task =
'CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL'
542 ddum = max(abs(fold), abs(f), one)
543 if ((fold - f) .le. tol*ddum)
then
545 task =
'CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH'
546 if (iback .ge. 10) info = -5
557 if (stp .eq. one)
then
561 dr = (gd - gdold)*stp
562 call dscal(n,stp,d,1)
566 if (dr .le. epsmch*ddum)
then
570 if (iprint .ge. 1)
write (6,1004) dr, ddum
585 call matupd(n,m,ws,wy,sy,ss,d,r,itail,
586 + iupdat,col,head,theta,rr,dr,stp,dtd)
593 call formt(m,wt,sy,ss,col,theta,info)
595 if (info .ne. 0)
then
598 if(iprint .ge. 1)
write (6, 1007)
621 call prn3lb(n,x,f,task,iprint,info,itfile,
622 + iter,nfgv,nintol,nskip,nact,sbgnrm,
623 + time,nseg,word,iback,stp,xstep,k,
624 + cachyt,sbtime,lnscht)
670 1001
format (//,
'ITERATION ',i5)
672 + (/,
'At iterate',i5,4x,
'f= ',1p,d12.5,4x,
'|proj g|= ',1p,d12.5)
673 1003
format (2(1x,i4),5x,
'-',5x,
'-',3x,
'-',5x,
'-',5x,
'-',8x,
'-',3x,
675 1004
format (
' ys=',1p,e10.3,
' -gs=',1p,e10.3,
' BFGS update SKIPPED')
677 +
' Singular triangular system detected;',/,
678 +
' refresh the lbfgs memory and restart the iteration.')
680 +
' Nonpositive definiteness in Cholesky factorization in formk;',/,
681 +
' refresh the lbfgs memory and restart the iteration.')
683 +
' Nonpositive definiteness in Cholesky factorization in formt;',/,
684 +
' refresh the lbfgs memory and restart the iteration.')
686 +
' Bad direction in the line search;',/,
687 +
' 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, info, 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, info)
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, info)
Performs the subspace minimization.
subroutine timer(ttime)
This routine computes cpu time in double precision.