L-BFGS-B  3.0
Large-scale Bound-constrained Optimization
matupd.f
Go to the documentation of this file.
1 c> \file matupd.f
2 
3 c> \brief This subroutine updates matrices WS and WY, and forms the
4 c> middle matrix in B.
5 c>
6 c> This subroutine updates matrices WS and WY, and forms the
7 c> middle matrix in B.
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 m On entry m is the maximum number of variable metric
13 c> corrections allowed in the limited memory matrix.<br/>
14 c> On exit m is unchanged.
15 c>
16 c> @param ws On entry this stores S, a set of s-vectors, that defines the
17 c> limited memory BFGS matrix.<br/>
18 c> On exit this array is unchanged.
19 c>
20 c> @param wy On entry this stores Y, a set of y-vectors, that defines the
21 c> limited memory BFGS matrix.<br/>
22 c> On exit this array is unchanged.
23 c>
24 c> @param sy On entry this stores S'Y, that defines the
25 c> limited memory BFGS matrix.<br/>
26 c> On exit this array is unchanged.
27 c>
28 c> @param ss On entry this stores S'S, that defines the
29 c> limited memory BFGS matrix.<br/>
30 c> On exit this array is unchanged.
31 c> @param d Search direction at the current iteration. After the line
32 c> search, the new s-vector is stp*d; matupd stores it as a
33 c> column of WS (writing d directly, since the stp scaling is
34 c> folded into the stored ss diagonal entry below).
35 c> @param r The accepted gradient difference y = g_{k+1} - g_k. Stored as
36 c> a column of WY.
37 c> @param itail On entry the column index in WS/WY that the previous
38 c> update wrote. On exit the column index this update wrote;
39 c> advances cyclically modulo m.
40 c> @param iupdat Total number of L-BFGS updates performed so far
41 c> (incremented by mainlb before each matupd call). When
42 c> iupdat <= m, col simply grows; when iupdat > m, the
43 c> history wraps and the oldest column is discarded.
44 c> @param col On entry col is the actual number of variable metric
45 c> corrections stored so far.<br/>
46 c> On exit col is unchanged.
47 c>
48 c> @param head On entry head is the location of the first s-vector (or y-vector)
49 c> in S (or Y).<br/>
50 c> On exit col is unchanged.
51 c>
52 c> @param theta On entry theta is the scaling factor specifying B_0 = theta I.<br/>
53 c> On exit theta is unchanged.
54 c> @param rr Squared 2-norm of r (i.e. ||y||^2 = y'y). Used to set
55 c> theta := rr/dr = y'y / (s'y), the standard initial Hessian
56 c> scaling for the next L-BFGS update.
57 c> @param dr Inner product d'r = s'y / stp (the curvature condition; must
58 c> be positive for the update to be safely accepted -- mainlb
59 c> checks this and skips matupd if dr <= eps*rr).
60 c> @param stp Line-search step length. Used to recover the s-vector from
61 c> d (s = stp*d) when computing ss(col,col) = stp^2 * d'd.
62 c> @param dtd Squared 2-norm of d (i.e. d'd). Combined with stp to form
63 c> ss(col,col) = stp^2 * dtd = ||s||^2 for the new column.
64  subroutine matupd(n, m, ws, wy, sy, ss, d, r, itail,
65  + iupdat, col, head, theta, rr, dr, stp, dtd)
66 
67  integer n, m, itail, iupdat, col, head
68  double precision theta, rr, dr, stp, dtd, d(n), r(n),
69  + ws(n, m), wy(n, m), sy(m, m), ss(m, m)
70 
71 c
72 c * * *
73 c
74 c NEOS, November 1994. (Latest revision June 1996.)
75 c Optimization Technology Center.
76 c Argonne National Laboratory and Northwestern University.
77 c Written by
78 c Ciyou Zhu
79 c in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
80 c
81 c
82 c ************
83 
84  integer j,pointr
85  double precision ddot
86  double precision one
87  parameter(one=1.0d0)
88 
89 c Set pointers for matrices WS and WY.
90 
91  if (iupdat .le. m) then
92  col = iupdat
93  itail = mod(head+iupdat-2,m) + 1
94  else
95  itail = mod(itail,m) + 1
96  head = mod(head,m) + 1
97  endif
98 
99 c Update matrices WS and WY.
100 
101  call dcopy(n,d,1,ws(1,itail),1)
102  call dcopy(n,r,1,wy(1,itail),1)
103 
104 c Set theta=yy/ys.
105 
106  theta = rr/dr
107 
108 c Form the middle matrix in B.
109 
110 c update the upper triangle of SS,
111 c and the lower triangle of SY:
112  if (iupdat .gt. m) then
113 c move old information
114  do 50 j = 1, col - 1
115  call dcopy(j,ss(2,j+1),1,ss(1,j),1)
116  call dcopy(col-j,sy(j+1,j+1),1,sy(j,j),1)
117  50 continue
118  endif
119 c add new information: the last row of SY
120 c and the last column of SS:
121  pointr = head
122  do 51 j = 1, col - 1
123  sy(col,j) = ddot(n,d,1,wy(1,pointr),1)
124  ss(j,col) = ddot(n,ws(1,pointr),1,d,1)
125  pointr = mod(pointr,m) + 1
126  51 continue
127  if (stp .eq. one) then
128  ss(col,col) = dtd
129  else
130  ss(col,col) = stp*stp*dtd
131  endif
132  sy(col,col) = dr
133 
134  return
135 
136  end
subroutine matupd(n, m, ws, wy, sy, ss, d, r, itail, iupdat, col, head, theta, rr, dr, stp, dtd)
This subroutine updates matrices WS and WY, and forms the middle matrix in B.
Definition: matupd.f:66