This simple driver demonstrates how to call the L-BFGS-B code to solve a sample problem (the extended Rosenbrock function subject to bounds on the variables). The dimension n of this problem is variable. (Fortran-77 version)
204 parameter(nmax=1024, mmax=17)
212 character*60 task, csave
214 integer n, m, iprint,
215 + nbd(nmax), iwa(3*nmax), isave(44)
216 double precision f, factr, pgtol,
217 + x(nmax), l(nmax), u(nmax), g(nmax), dsave(29),
218 + wa(2*mmax*nmax + 5*nmax + 11*mmax*mmax + 8*mmax)
222 double precision t1, t2
268 16
format(/,5x,
'Solving sample problem.',
269 + /,5x,
' (f = 0.0 at the optimal solution.)',/)
281 call setulb(n,m,x,l,u,nbd,f,g,factr,pgtol,wa,iwa,task,iprint,
282 + csave,lsave,isave,dsave)
284 if (task(1:2) .eq.
'FG')
then
290 f=.25d0*(x(1)-1.d0)**2
292 f=f+(x(i)-x(i-1)**2)**2
299 g(1)=2.d0*(x(1)-1.d0)-1.6d1*x(1)*t1
303 g(i)=8.d0*t2-1.6d1*x(i)*t1
311 if (task(1:5) .eq.
'NEW_X')
goto 111
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...