L-BFGS-B  3.0
Large-scale Bound-constrained Optimization
lnsrlb.f
Go to the documentation of this file.
1 c> \file lnsrlb.f
2 
3 c> \brief This subroutine calls subroutine dcsrch from the Minpack2 library
4 c> to perform the line search. Subroutine dscrch is safeguarded so
5 c> that all trial points lie within the feasible region.
6 c>
7 c> @param n number of parameters
8 c> @param l lower bounds of parameters
9 c> @param u upper bounds of parameters
10 c> @param nbd On entry nbd represents the type of bounds imposed on the
11 c> variables, and must be specified as follows:
12 c> nbd(i)=<ul><li>0 if x(i) is unbounded,</li>
13 c> <li>1 if x(i) has only a lower bound,</li>
14 c> <li>2 if x(i) has both lower and upper bounds, and</li>
15 c> <li>3 if x(i) has only an upper bound.</li></ul>
16 c> On exit nbd is unchanged.
17 c> @param x position
18 c> @param f function value at x
19 c> @param fold TODO
20 c> @param gd TODO
21 c> @param gdold TODO
22 c> @param g gradient of f at x
23 c> @param d TODO
24 c> @param r TODO
25 c> @param t TODO
26 c> @param z TODO
27 c> @param stp TODO
28 c> @param dnorm TODO
29 c> @param dtd TODO
30 c> @param xstep TODO
31 c> @param stpmx TODO
32 c> @param iter TODO
33 c> @param ifun TODO
34 c> @param iback TODO
35 c> @param nfgv TODO
36 c> @param info TODO
37 c> @param task TODO
38 c> @param boxed TODO
39 c> @param cnstnd TODO
40 c> @param csave working array
41 c> @param isave working array
42 c> @param dsave working array
43  subroutine lnsrlb(n, l, u, nbd, x, f, fold, gd, gdold, g, d, r, t,
44  + z, stp, dnorm, dtd, xstep, stpmx, iter, ifun,
45  + iback, nfgv, info, task, boxed, cnstnd, csave,
46  + isave, dsave)
47 
48  character*60 task, csave
49  logical boxed, cnstnd
50  integer n, iter, ifun, iback, nfgv, info,
51  + nbd(n), isave(2)
52  double precision f, fold, gd, gdold, stp, dnorm, dtd, xstep,
53  + stpmx, x(n), l(n), u(n), g(n), d(n), r(n), t(n),
54  + z(n), dsave(13)
55 c
56 c * * *
57 c
58 c NEOS, November 1994. (Latest revision June 1996.)
59 c Optimization Technology Center.
60 c Argonne National Laboratory and Northwestern University.
61 c Written by
62 c Ciyou Zhu
63 c in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
64 c
65 c
66 c **********
67 
68  integer i
69  double precision ddot,a1,a2
70  double precision one,zero,big
71  parameter(one=1.0d0,zero=0.0d0,big=1.0d+10)
72  double precision ftol,gtol,xtol
73  parameter(ftol=1.0d-3,gtol=0.9d0,xtol=0.1d0)
74 
75  if (task(1:5) .eq. 'FG_LN') goto 556
76 
77  dtd = ddot(n,d,1,d,1)
78  dnorm = sqrt(dtd)
79 
80 c Determine the maximum step length.
81 
82  stpmx = big
83  if (cnstnd) then
84  if (iter .eq. 0) then
85  stpmx = one
86  else
87  do 43 i = 1, n
88  a1 = d(i)
89  if (nbd(i) .ne. 0) then
90  if (a1 .lt. zero .and. nbd(i) .le. 2) then
91  a2 = l(i) - x(i)
92  if (a2 .ge. zero) then
93  stpmx = zero
94  else if (a1*stpmx .lt. a2) then
95  stpmx = a2/a1
96  endif
97  else if (a1 .gt. zero .and. nbd(i) .ge. 2) then
98  a2 = u(i) - x(i)
99  if (a2 .le. zero) then
100  stpmx = zero
101  else if (a1*stpmx .gt. a2) then
102  stpmx = a2/a1
103  endif
104  endif
105  endif
106  43 continue
107  endif
108  endif
109 
110  if (iter .eq. 0 .and. .not. boxed) then
111  stp = min(one/dnorm, stpmx)
112  else
113  stp = one
114  endif
115 
116  call dcopy(n,x,1,t,1)
117  call dcopy(n,g,1,r,1)
118  fold = f
119  ifun = 0
120  iback = 0
121  csave = 'START'
122  556 continue
123  gd = ddot(n,g,1,d,1)
124  if (ifun .eq. 0) then
125  gdold=gd
126  if (gd .ge. zero) then
127 c the directional derivative >=0.
128 c Line search is impossible.
129  write(6,*)' ascent direction in projection gd = ', gd
130  info = -4
131  return
132  endif
133  endif
134 
135  call dcsrch(f,gd,stp,ftol,gtol,xtol,zero,stpmx,csave,isave,dsave)
136 
137  xstep = stp*dnorm
138  if (csave(1:4) .ne. 'CONV' .and. csave(1:4) .ne. 'WARN') then
139  task = 'FG_LNSRCH'
140  ifun = ifun + 1
141  nfgv = nfgv + 1
142  iback = ifun - 1
143  if (stp .eq. one) then
144  call dcopy(n,z,1,x,1)
145  else
146  do 41 i = 1, n
147  x(i) = stp*d(i) + t(i)
148  41 continue
149  endif
150  else
151  task = 'NEW_X'
152  endif
153 
154  return
155 
156  end
subroutine dcsrch(f, g, stp, ftol, gtol, xtol, stpmin, stpmax, task, isave, dsave)
This subroutine finds a step that satisfies a sufficient decrease condition and a curvature condition...
Definition: dcsrch.f:96
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....
Definition: lnsrlb.f:47