L-BFGS-B  3.0
Large-scale Bound-constrained Optimization
active.f
Go to the documentation of this file.
1 c> \file active.f
2 
3 c> \brief This subroutine initializes iwhere and projects the initial x to
4 c> the feasible set if necessary.
5 c>
6 c> This subroutine initializes iwhere and projects the initial x to
7 c> the feasible set if necessary.
8 c>
9 c> @param n number of parameters
10 c> @param l lower bounds on parameters
11 c> @param u upper bounds on parameters
12 c> @param nbd indicates which bounds are present
13 c> @param x position
14 c> @param iwhere On entry iwhere is unspecified.<br/>
15 c> On exit: iwhere(i)=<ul><li>-1 if x(i) has no bounds</li>
16 c> <li> 3 if l(i)=u(i),</li>
17 c> <li> 0 otherwise.</li></ul>
18 c> In cauchy, iwhere is given finer gradations.
19 c> @param iprint console output flag
20 c> @param prjctd On exit .true. if any input x(i) had to be clipped onto its
21 c> bound (the user supplied an infeasible starting point).
22 c> @param cnstnd On exit .true. if any variable has at least one bound
23 c> (any nbd(i) /= 0); .false. for purely unconstrained problems.
24 c> @param boxed On exit .true. iff every variable has both lower and upper
25 c> bounds (every nbd(i) == 2); .false. otherwise.
26 c
27 c * * *
28 c
29 c NEOS, November 1994. (Latest revision June 1996.)
30 c Optimization Technology Center.
31 c Argonne National Laboratory and Northwestern University.
32 c Written by
33 c Ciyou Zhu
34 c in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
35  subroutine active(n, l, u, nbd, x, iwhere, iprint,
36  + prjctd, cnstnd, boxed)
37 
38  logical prjctd, cnstnd, boxed
39  integer n, iprint, nbd(n), iwhere(n)
40  double precision x(n), l(n), u(n)
41 
42 c ************
43 
44  integer nbdd,i
45  double precision zero
46  parameter(zero=0.0d0)
47 
48 c Initialize nbdd, prjctd, cnstnd and boxed.
49 
50  nbdd = 0
51  prjctd = .false.
52  cnstnd = .false.
53  boxed = .true.
54 
55 c Project the initial x to the feasible set if necessary.
56 
57  do 10 i = 1, n
58  if (nbd(i) .gt. 0) then
59  if (nbd(i) .le. 2 .and. x(i) .le. l(i)) then
60  if (x(i) .lt. l(i)) then
61  prjctd = .true.
62  x(i) = l(i)
63  endif
64  nbdd = nbdd + 1
65  else if (nbd(i) .ge. 2 .and. x(i) .ge. u(i)) then
66  if (x(i) .gt. u(i)) then
67  prjctd = .true.
68  x(i) = u(i)
69  endif
70  nbdd = nbdd + 1
71  endif
72  endif
73  10 continue
74 
75 c Initialize iwhere and assign values to cnstnd and boxed.
76 
77  do 20 i = 1, n
78  if (nbd(i) .ne. 2) boxed = .false.
79  if (nbd(i) .eq. 0) then
80 c this variable is always free
81  iwhere(i) = -1
82 
83 c otherwise set x(i)=mid(x(i), u(i), l(i)).
84  else
85  cnstnd = .true.
86  if (nbd(i) .eq. 2 .and. u(i) - l(i) .le. zero) then
87 c this variable is always fixed
88  iwhere(i) = 3
89  else
90  iwhere(i) = 0
91  endif
92  endif
93  20 continue
94 
95  if (iprint .ge. 0) then
96  if (prjctd) write (6,*)
97  + 'The initial X is infeasible. Restart with its projection.'
98  if (.not. cnstnd)
99  + write (6,*) 'This problem is unconstrained.'
100  endif
101 
102  if (iprint .gt. 0) write (6,1001) nbdd
103 
104  1001 format (/,'At X0 ',i9,' variables are exactly at the bounds')
105 
106  return
107 
108  end
subroutine active(n, l, u, nbd, x, iwhere, iprint, prjctd, cnstnd, boxed)
This subroutine initializes iwhere and projects the initial x to the feasible set if necessary.
Definition: active.f:37