L-BFGS-B  3.0
Large-scale Bound-constrained Optimization
setulb.f
Go to the documentation of this file.
1 c> \file setulb.f
2 
3 c> \example driver1.f
4 c> This simple driver demonstrates how to call the L-BFGS-B code to
5 c> solve a sample problem (the extended Rosenbrock function
6 c> subject to bounds on the variables).
7 c> The dimension n of this problem is variable.
8 c> (Fortran-77 version)
9 
10 c> \example driver1.f90
11 c> This simple driver demonstrates how to call the L-BFGS-B code to
12 c> solve a sample problem (the extended Rosenbrock function
13 c> subject to bounds on the variables).
14 c> The dimension n of this problem is variable.
15 c> (Fortran-90 version)
16 
17 c> \example driver2.f
18 c> This driver shows how to replace the default stopping test
19 c> by other termination criteria. It also illustrates how to
20 c> print the values of several parameters during the course of
21 c> the iteration. The sample problem used here is the same as in
22 c> DRIVER1 (the extended Rosenbrock function with bounds on the variables).
23 c> (Fortran-77 version)
24 
25 c> \example driver2.f90
26 c> This driver shows how to replace the default stopping test
27 c> by other termination criteria. It also illustrates how to
28 c> print the values of several parameters during the course of
29 c> the iteration. The sample problem used here is the same as in
30 c> DRIVER1 (the extended Rosenbrock function with bounds on the variables).
31 c> (Fortran-90 version)
32 
33 c> \example driver3.f
34 c> This time-controlled driver shows that it is possible to terminate
35 c> a run by elapsed CPU time, and yet be able to print all desired
36 c> information. This driver also illustrates the use of two
37 c> stopping criteria that may be used in conjunction with a limit
38 c> on execution time. The sample problem used here is the same as in
39 c> driver1 and driver2 (the extended Rosenbrock function with bounds
40 c> on the variables).
41 c> (Fortran-77 version)
42 
43 c> \example driver3.f90
44 c> This time-controlled driver shows that it is possible to terminate
45 c> a run by elapsed CPU time, and yet be able to print all desired
46 c> information. This driver also illustrates the use of two
47 c> stopping criteria that may be used in conjunction with a limit
48 c> on execution time. The sample problem used here is the same as in
49 c> driver1 and driver2 (the extended Rosenbrock function with bounds
50 c> on the variables).
51 c> (Fortran-90 version)
52 
53 c> \brief This subroutine partitions the working arrays wa and iwa, and
54 c> then uses the limited memory BFGS method to solve the bound
55 c> constrained optimization problem by calling mainlb.
56 c>
57 c> This subroutine partitions the working arrays wa and iwa, and
58 c> then uses the limited memory BFGS method to solve the bound
59 c> constrained optimization problem by calling mainlb.
60 c> (The direct method will be used in the subspace minimization.)
61 c>
62 c> @param n On entry n is the dimension of the problem.<br/>
63 c> On exit n is unchanged.
64 c>
65 c> @param m On entry m is the maximum number of variable metric corrections
66 c> used to define the limited memory matrix.<br/>
67 c> On exit m is unchanged.
68 c>
69 c> @param x On entry x is an approximation to the solution.<br/>
70 c> On exit x is the current approximation.
71 c>
72 c> @param l On entry l is the lower bound on x.<br/>
73 c> On exit l is unchanged.
74 c>
75 c> @param u On entry u is the upper bound on x.<br/>
76 c> On exit u is unchanged.
77 c>
78 c> @param nbd On entry nbd represents the type of bounds imposed on the
79 c> variables, and must be specified as follows:
80 c> nbd(i)=<ul><li>0 if x(i) is unbounded,</li>
81 c> <li>1 if x(i) has only a lower bound,</li>
82 c> <li>2 if x(i) has both lower and upper bounds, and</li>
83 c> <li>3 if x(i) has only an upper bound.</li></ul>
84 c> On exit nbd is unchanged.
85 c>
86 c> @param f On first entry f is unspecified.<br/>
87 c> On final exit f is the value of the function at x.
88 c>
89 c> @param g On first entry g is unspecified.<br/>
90 c> On final exit g is the value of the gradient at x.
91 c>
92 c> @param factr On entry factr >= 0 is specified by the user. The iteration
93 c> will stop when<br/>
94 c> (f^k - f^{k+1})/max{|f^k|,|f^{k+1}|,1} <= factr*epsmch<br/>
95 c> where epsmch is the machine precision, which is automatically
96 c> generated by the code.<br/>
97 c> Typical values for factr:<ul>
98 c> <li>1.d+12 for low accuracy;</li>
99 c> <li>1.d+7 for moderate accuracy;</li>
100 c> <li>1.d+1 for extremely high accuracy.</li></ul>
101 c> On exit factr is unchanged.
102 c>
103 c> @param pgtol On entry pgtol >= 0 is specified by the user. The iteration
104 c> will stop when<br/>
105 c> max{|proj g_i | i = 1, ..., n} <= pgtol<br/>
106 c> where pg_i is the ith component of the projected gradient.<br/>
107 c> On exit pgtol is unchanged.
108 c>
109 c> @param wa working array
110 c>
111 c> @param iwa working array
112 c>
113 c> @param task working string indicating
114 c> the current job when entering and quitting this subroutine.
115 c>
116 c> @param iprint Must be set by the user.
117 c> It controls the frequency and type of output generated:<ul>
118 c> <li>iprint<0 no output is generated;</li>
119 c> <li>iprint=0 print only one line at the last iteration;</li>
120 c> <li>0<iprint<99 print also f and |proj g| every iprint iterations;</li>
121 c> <li>iprint=99 print details of every iteration except n-vectors;</li>
122 c> <li>iprint=100 print also the changes of active set and final x;</li>
123 c> <li>iprint>100 print details of every iteration including x and g;</li></ul>
124 c> When iprint > 0, the file iterate.dat will be created to
125 c> summarize the iteration.
126 c>
127 c> @param csave working string
128 c>
129 c> @param lsave working array;
130 c> On exit with 'task' = NEW_X, the following information is
131 c> available:<ul>
132 c> <li>If lsave(1) = .true. then the initial X has been replaced by
133 c> its projection in the feasible set;</li>
134 c> <li>If lsave(2) = .true. then the problem is constrained;</li>
135 c> <li>If lsave(3) = .true. then each variable has upper and lower
136 c> bounds;</li></ul>
137 c>
138 c> @param isave working array;
139 c> On exit with 'task' = NEW_X, the following information is
140 c> available:<ul>
141 c> <li>isave(22) = the total number of intervals explored in the
142 c> search of Cauchy points;</li>
143 c> <li>isave(26) = the total number of skipped BFGS updates before
144 c> the current iteration;</li>
145 c> <li>isave(30) = the number of current iteration;</li>
146 c> <li>isave(31) = the total number of BFGS updates prior the current
147 c> iteration;</li>
148 c> <li>isave(33) = the number of intervals explored in the search of
149 c> Cauchy point in the current iteration;</li>
150 c> <li>isave(34) = the total number of function and gradient
151 c> evaluations;</li>
152 c> <li>isave(36) = the number of function value or gradient
153 c> evaluations in the current iteration;</li>
154 c> <li>if isave(37) = 0 then the subspace argmin is within the box;</li>
155 c> <li>if isave(37) = 1 then the subspace argmin is beyond the box;</li>
156 c> <li>isave(38) = the number of free variables in the current
157 c> iteration;</li>
158 c> <li>isave(39) = the number of active constraints in the current
159 c> iteration;</li>
160 c> <li>n + 1 - isave(40) = the number of variables leaving the set of
161 c> active constraints in the current iteration;</li>
162 c> <li>isave(41) = the number of variables entering the set of active
163 c> constraints in the current iteration.</li></ul>
164 c>
165 c> @param dsave working array;
166 c> On exit with 'task' = NEW_X, the following information is
167 c> available:<ul>
168 c> <li>dsave(1) = current 'theta' in the BFGS matrix;</li>
169 c> <li>dsave(2) = f(x) in the previous iteration;</li>
170 c> <li>dsave(3) = factr*epsmch;</li>
171 c> <li>dsave(4) = 2-norm of the line search direction vector;</li>
172 c> <li>dsave(5) = the machine precision epsmch generated by the code;</li>
173 c> <li>dsave(7) = the accumulated time spent on searching for
174 c> Cauchy points;</li>
175 c> <li>dsave(8) = the accumulated time spent on
176 c> subspace minimization;</li>
177 c> <li>dsave(9) = the accumulated time spent on line search;</li>
178 c> <li>dsave(11) = the slope of the line search function at
179 c> the current point of line search;</li>
180 c> <li>dsave(12) = the maximum relative step length imposed in
181 c> line search;</li>
182 c> <li>dsave(13) = the infinity norm of the projected gradient;</li>
183 c> <li>dsave(14) = the relative step length in the line search;</li>
184 c> <li>dsave(15) = the slope of the line search function at
185 c> the starting point of the line search;</li>
186 c> <li>dsave(16) = the square of the 2-norm of the line search
187 c> direction vector.</li></ul>
188  subroutine setulb(n, m, x, l, u, nbd, f, g, factr, pgtol, wa, iwa,
189  + task, iprint, csave, lsave, isave, dsave)
190 
191  character*60 task, csave
192  logical lsave(4)
193  integer n, m, iprint,
194  + nbd(n), iwa(3*n), isave(44)
195  double precision f, factr, pgtol, x(n), l(n), u(n), g(n),
196 c
197 c-jlm-jn
198  + wa(2*m*n + 5*n + 11*m*m + 8*m), dsave(29)
199 
200 c ************
201 c
202 c References:
203 c
204 c [1] R. H. Byrd, P. Lu, J. Nocedal and C. Zhu, ``A limited
205 c memory algorithm for bound constrained optimization'',
206 c SIAM J. Scientific Computing 16 (1995), no. 5, pp. 1190--1208.
207 c
208 c [2] C. Zhu, R.H. Byrd, P. Lu, J. Nocedal, ``L-BFGS-B: a
209 c limited memory FORTRAN code for solving bound constrained
210 c optimization problems'', Tech. Report, NAM-11, EECS Department,
211 c Northwestern University, 1994.
212 c
213 c (Postscript files of these papers are available via anonymous
214 c ftp to eecs.nwu.edu in the directory pub/lbfgs/lbfgs_bcm.)
215 c
216 c * * *
217 c
218 c NEOS, November 1994. (Latest revision June 1996.)
219 c Optimization Technology Center.
220 c Argonne National Laboratory and Northwestern University.
221 c Written by
222 c Ciyou Zhu
223 c in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
224 c
225 c
226 c ************
227 c-jlm-jn
228  integer lws,lr,lz,lt,ld,lxp,lwa,
229  + lwy,lsy,lss,lwt,lwn,lsnd
230 
231  if (task .eq. 'START') then
232  isave(1) = m*n
233  isave(2) = m**2
234  isave(3) = 4*m**2
235  isave(4) = 1 ! ws m*n
236  isave(5) = isave(4) + isave(1) ! wy m*n
237  isave(6) = isave(5) + isave(1) ! wsy m**2
238  isave(7) = isave(6) + isave(2) ! wss m**2
239  isave(8) = isave(7) + isave(2) ! wt m**2
240  isave(9) = isave(8) + isave(2) ! wn 4*m**2
241  isave(10) = isave(9) + isave(3) ! wsnd 4*m**2
242  isave(11) = isave(10) + isave(3) ! wz n
243  isave(12) = isave(11) + n ! wr n
244  isave(13) = isave(12) + n ! wd n
245  isave(14) = isave(13) + n ! wt n
246  isave(15) = isave(14) + n ! wxp n
247  isave(16) = isave(15) + n ! wa 8*m
248  endif
249  lws = isave(4)
250  lwy = isave(5)
251  lsy = isave(6)
252  lss = isave(7)
253  lwt = isave(8)
254  lwn = isave(9)
255  lsnd = isave(10)
256  lz = isave(11)
257  lr = isave(12)
258  ld = isave(13)
259  lt = isave(14)
260  lxp = isave(15)
261  lwa = isave(16)
262 
263  call mainlb(n,m,x,l,u,nbd,f,g,factr,pgtol,
264  + wa(lws),wa(lwy),wa(lsy),wa(lss), wa(lwt),
265  + wa(lwn),wa(lsnd),wa(lz),wa(lr),wa(ld),wa(lt),wa(lxp),
266  + wa(lwa),
267  + iwa(1),iwa(n+1),iwa(2*n+1),task,iprint,
268  + csave,lsave,isave(22),dsave)
269 
270  return
271 
272  end
273 
274 
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...
Definition: mainlb.f:132
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...
Definition: setulb.f:190