L-BFGS-B  3.0
Large-scale Bound-constrained Optimization
freev.f
Go to the documentation of this file.
1 c> \file freev.f
2 
3 c> \brief This subroutine counts the entering and leaving variables when
4 c> iter > 0, and finds the index set of free and active variables
5 c> at the GCP.
6 c>
7 c> This subroutine counts the entering and leaving variables when
8 c> iter > 0, and finds the index set of free and active variables
9 c> at the GCP.
10 c>
11 c> @param n number of parameters
12 c> @param nfree number of free parameters, i.e., those not at their bounds
13 c> @param index for i=1,...,nfree, index(i) are the indices of free variables<br/>
14 c> for i=nfree+1,...,n, index(i) are the indices of bound variables<br/>
15 c> On entry after the first iteration, index gives
16 c> the free variables at the previous iteration.<br/>
17 c> On exit it gives the free variables based on the determination
18 c> in cauchy using the array iwhere.
19 c> @param nenter On exit nenter is the number of variables that entered the
20 c> free set this iteration (were active, now free at the GCP).
21 c> @param ileave On exit indx2(ileave),...,indx2(n) list the variables that
22 c> left the free set this iteration. ileave starts at n+1 and
23 c> is decremented each time a leaving variable is recorded.
24 c> @param indx2 On entry indx2 is unspecified.<br/>
25 c> On exit with iter>0, indx2 indicates which variables
26 c> have changed status since the previous iteration.<br/>
27 c> For i= 1,...,nenter, indx2(i) have changed from bound to free.<br/>
28 c> For i= ileave+1,...,n, indx2(i) have changed from free to bound.
29 c> @param iwhere On entry iwhere(i) classifies each variable's bound status
30 c> (set by cauchy): <=0 means free at GCP, >0 means at-bound.
31 c> Used here to compare against the previous index/nfree to
32 c> detect leaving and entering variables.
33 c> @param wrk On exit .true. if the active-set or L-BFGS bookkeeping has
34 c> changed enough that the workspace WN needs to be rebuilt
35 c> (some variable entered/left, or updatd is .true.).
36 c> @param updatd On entry .true. if the L-BFGS matrix was updated in the
37 c> previous iteration. Combined with the entering/leaving
38 c> counts to set wrk.
39 c> @param cnstnd Whether bounds are present (true if at least one variable
40 c> is bounded). When false, the entering/leaving counting
41 c> loop is skipped.
42 c> @param iprint Console output flag (>=99 prints summary, >=100 prints
43 c> per-variable change records).
44 c> @param iter Current outer iteration number. The entering/leaving
45 c> counting loop only runs when iter > 0 (the first iteration
46 c> has no "previous" set to compare against).
47  subroutine freev(n, nfree, index, nenter, ileave, indx2,
48  + iwhere, wrk, updatd, cnstnd, iprint, iter)
49 
50  integer n, nfree, nenter, ileave, iprint, iter,
51  + index(n), indx2(n), iwhere(n)
52  logical wrk, updatd, cnstnd
53 c
54 c * * *
55 c
56 c NEOS, November 1994. (Latest revision June 1996.)
57 c Optimization Technology Center.
58 c Argonne National Laboratory and Northwestern University.
59 c Written by
60 c Ciyou Zhu
61 c in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
62 c
63 c
64 c ************
65 
66  integer iact,i,k
67 
68  nenter = 0
69  ileave = n + 1
70  if (iter .gt. 0 .and. cnstnd) then
71 c count the entering and leaving variables.
72  do 20 i = 1, nfree
73  k = index(i)
74 
75 c write(6,*) ' k = index(i) ', k
76 c write(6,*) ' index = ', i
77 
78  if (iwhere(k) .gt. 0) then
79  ileave = ileave - 1
80  indx2(ileave) = k
81  if (iprint .ge. 100) write (6,*)
82  + 'Variable ',k,' leaves the set of free variables'
83  endif
84  20 continue
85  do 22 i = 1 + nfree, n
86  k = index(i)
87  if (iwhere(k) .le. 0) then
88  nenter = nenter + 1
89  indx2(nenter) = k
90  if (iprint .ge. 100) write (6,*)
91  + 'Variable ',k,' enters the set of free variables'
92  endif
93  22 continue
94  if (iprint .ge. 99) write (6,*)
95  + n+1-ileave,' variables leave; ',nenter,' variables enter'
96  endif
97  wrk = (ileave .lt. n+1) .or. (nenter .gt. 0) .or. updatd
98 
99 c Find the index set of free and active variables at the GCP.
100 
101  nfree = 0
102  iact = n + 1
103  do 24 i = 1, n
104  if (iwhere(i) .le. 0) then
105  nfree = nfree + 1
106  index(nfree) = i
107  else
108  iact = iact - 1
109  index(iact) = i
110  endif
111  24 continue
112  if (iprint .ge. 99) write (6,*)
113  + nfree,' variables are free at GCP ',iter + 1
114 
115  return
116 
117  end
subroutine freev(n, nfree, index, nenter, ileave, indx2, iwhere, wrk, updatd, cnstnd, iprint, iter)
This subroutine counts the entering and leaving variables when iter > 0, and finds the index set of f...
Definition: freev.f:49