This driver shows how to replace the default stopping test by other termination criteria. It also illustrates how to print the values of several parameters during the course of the iteration. The sample problem used here is the same as in DRIVER1 (the extended Rosenbrock function with bounds on the variables). (Fortran-77 version)
62 parameter(nmax=1024, mmax=17)
70 character*60 task, csave
73 + nbd(nmax), iwa(3*nmax), isave(44)
74 double precision f, factr, pgtol,
75 + x(nmax), l(nmax), u(nmax), g(nmax), dsave(29),
76 + wa(2*mmax*nmax+5*nmax+11*mmax*mmax+8*mmax)
80 double precision t1, t2
129 16
format(/,5x,
'Solving sample problem.',
130 + /,5x,
' (f = 0.0 at the optimal solution.)',/)
142 call setulb(n,m,x,l,u,nbd,f,g,factr,pgtol,wa,iwa,task,iprint,
143 + csave,lsave,isave,dsave)
145 if (task(1:2) .eq.
'FG')
then
151 f=.25d0*(x(1)-1.d0)**2
153 f=f+(x(i)-x(i-1)**2)**2
160 g(1)=2.d0*(x(1)-1.d0)-1.6d1*x(1)*t1
164 g(i)=8.d0*t2-1.6d1*x(i)*t1
172 if (task(1:5) .eq.
'NEW_X')
then
188 if (isave(34) .ge. 99)
189 + task=
'STOP: TOTAL NO. of f AND g EVALUATIONS EXCEEDS LIMIT'
194 if (dsave(13) .le. 1.d-10*(1.0d0 + abs(f)))
195 + task=
'STOP: THE PROJECTED GRADIENT IS SUFFICIENTLY SMALL'
208 write (6,
'(2(a,i5,4x),a,1p,d12.5,4x,a,1p,d12.5)')
'Iterate'
209 + ,isave(30),
'nfg =',isave(34),
'f =',f,
'|proj g| =',dsave(13)
214 if (task(1:4) .eq.
'STOP')
then
216 write (6,*)
'Final X='
217 write (6,
'((1x,1p, 6(1x,d11.4)))') (x(i),i = 1,n)
subroutine setulb(n, m, x, l, u, nbd, f, g, factr, pgtol, wa, iwa, task, iprint, csave, lsave, isave, dsave)
This subroutine partitions the working arrays wa and iwa, and then uses the limited memory BFGS metho...