1 C Modification of sdrive.f as retrieved 1997/03/29 from
2 C ftp://ftp.netlib.org/opt/lbfgs_um.shar
4 C This version copyright 2006 by Robert Dodier and released
5 C under the terms of the GNU General Public License.
7 C ---------------- Message from the author ----------------
8 C From: Jorge Nocedal [mailto:nocedal@dario.ece.nwu.edu]
9 C Sent: Friday, August 17, 2001 9:09 AM
11 C Subject: Re: Commercial licensing terms for LBFGS?
14 C The code L-BFGS (for unconstrained problems) is in the public domain.
15 C It can be used in any commercial application.
17 C The code L-BFGS-B (for bound constrained problems) belongs to
18 C ACM. You need to contact them for a commercial license. It is
22 C --------------------- End of message --------------------
24 SUBROUTINE FGCOMPUTE
(F
,G
,X
,N
)
26 DOUBLE PRECISION F
,G
(N
),X
(N
),T1
,T2
30 T2
= 1.D1*
(X
(J
+1)-X
(J
)**2)
32 G
(J
)= -2.D0*
(X
(J
)*G
(J
+1)+T1
)
39 C ***********************
40 C SIMPLE DRIVER FOR LBFGS
41 C ***********************
43 C Example of driver for LBFGS routine, using a
44 C simple test problem. The solution point is at
45 C X=(1,...,1) and the optimal function value of 0.
51 C Change NFEVALMAX to some workable number like 100.
52 C It is currently assigned a small value to ensure that we'll
53 C terminate in the middle of a line search; that tests the
54 C solution cache code.
55 PARAMETER(NDIM
=2000,MSAVE
=7,NWORK
=NDIM*
(2*MSAVE
+1)+2*MSAVE
,
57 DOUBLE PRECISION X
(NDIM
),G
(NDIM
),DIAG
(NDIM
),W
(NWORK
),SCACHE
(NDIM
)
58 DOUBLE PRECISION F
,EPS
,XTOL
,GTOL
,T1
,T2
,STPMIN
,STPMAX
59 INTEGER IPRINT
(2),IFLAG
,ICALL
,N
,M
,MP
,LP
,J
62 C The driver for LBFGS must always declare LB2 as EXTERNAL
65 COMMON /LB3
/MP
,LP
,GTOL
,STPMIN
,STPMAX
72 C We do not wish to provide the diagonal matrices Hk0, and
73 C therefore set DIAGCO to FALSE.
86 CALL FGCOMPUTE
(F
,G
,X
,N
)
87 CALL LBFGS
(N
,M
,X
,F
,G
,DIAGCO
,DIAG
,IPRINT
,EPS
,XTOL
,W
,IFLAG
,SCACHE
)
88 IF(IFLAG
.LE
.0) GO TO 50
90 C We allow at most NFEVALMAX evaluations of F and G
91 IF(ICALL
.GE
.NFEVALMAX
) GO TO 50
95 WRITE(6,60)ICALL
,NFEVALMAX
96 WRITE(6,70)(X
(I
),I
=1,N
)
98 WRITE(6,70)(SCACHE
(I
),I
=1,N
)
100 CALL FGCOMPUTE
(F
,G
,X
,N
)
103 CALL FGCOMPUTE
(F
,G
,SCACHE
,N
)
106 60 FORMAT('SEARCH TERMINATED AFTER ',I4
,' FUNCTION EVALUATIONS',
107 &' (LIMIT: ',I4
,')',/,'CURRENT SOLUTION VECTOR: ')
108 70 FORMAT(4(2X
,1PD22
.15
))
109 80 FORMAT('SOLUTION CACHE: ')
110 90 FORMAT('F(CURRENT SOLUTION VECTOR) = ',1PD22
.15
)
111 100 FORMAT('F(SOLUTION CACHE) = ',1PD22
.15
)
114 C ** LAST LINE OF SIMPLE DRIVER (SDRIVE) **