L-BFGS-B  3.0
Large-scale Bound-constrained Optimization
projgr.f
Go to the documentation of this file.
1 c> \file projgr.f
2 
3 c> \brief This subroutine computes the infinity norm of the projected
4 c> gradient.
5 c>
6 c> This subroutine computes the infinity norm of the projected
7 c> gradient.
8 c>
9 c> @param n On entry n is the number of variables.<br/>
10 c> On exit n is unchanged.
11 c>
12 c> @param l On entry l is the lower bound of x.<br/>
13 c> On exit l is unchanged.
14 c>
15 c> @param u On entry u is the upper bound of x.<br/>
16 c> On exit u is unchanged.
17 c>
18 c> @param nbd On entry nbd represents the type of bounds imposed on the
19 c> variables, and must be specified as follows:
20 c> nbd(i)=<ul><li>0 if x(i) is unbounded,</li>
21 c> <li>1 if x(i) has only a lower bound,</li>
22 c> <li>2 if x(i) has both lower and upper bounds,</li>
23 c> <li>3 if x(i) has only an upper bound.</li></ul>
24 c> On exit nbd is unchanged.
25 c>
26 c> @param x On entry x is an approximation to the solution.<br/>
27 c> On exit x is unchanged.
28 c>
29 c> @param g On entry g is the gradient.<br/>
30 c> On exit g is unchanged.
31 c>
32 c> @param sbgnrm infinity norm of projected gradient
33  subroutine projgr(n, l, u, nbd, x, g, sbgnrm)
34 
35  integer n, nbd(n)
36  double precision sbgnrm, x(n), l(n), u(n), g(n)
37 
38 c ************
39 c
40 c NEOS, November 1994. (Latest revision June 1996.)
41 c Optimization Technology Center.
42 c Argonne National Laboratory and Northwestern University.
43 c Written by
44 c Ciyou Zhu
45 c in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
46 c
47 c
48 c ************
49 
50  integer i
51  double precision gi
52  double precision one,zero
53  parameter(one=1.0d0,zero=0.0d0)
54 
55  sbgnrm = zero
56  do 15 i = 1, n
57  gi = g(i)
58  if (nbd(i) .ne. 0) then
59  if (gi .lt. zero) then
60  if (nbd(i) .ge. 2) gi = max((x(i)-u(i)),gi)
61  else
62  if (nbd(i) .le. 2) gi = min((x(i)-l(i)),gi)
63  endif
64  endif
65  sbgnrm = max(sbgnrm,abs(gi))
66  15 continue
67 
68  return
69 
70  end
subroutine projgr(n, l, u, nbd, x, g, sbgnrm)
This subroutine computes the infinity norm of the projected gradient.
Definition: projgr.f:34