* E04JYF Example Program Text * Mark 18 Release. NAG Copyright 1997. * .. Parameters .. INTEGER N, LIW, LW PARAMETER (N=4,LIW=N+2,LW=N*(N-1)/2+12*N) INTEGER NOUT PARAMETER (NOUT=6) * .. Local Scalars .. DOUBLE PRECISION F INTEGER IBOUND, IFAIL, J * .. Local Arrays .. DOUBLE PRECISION BL(N), BU(N), RUSER(N), W(LW), X(N) INTEGER IUSER(N), IW(6) * .. External Subroutines .. EXTERNAL E04JYF, FUNCT1 * .. Executable Statements .. WRITE (NOUT,*) 'E04JYF Example Program Results' X(1) = 3.0D0 X(2) = -1.0D0 X(3) = 0.0D0 X(4) = 1.0D0 IBOUND = 0 BL(1) = 1.0D0 BU(1) = 3.0D0 BL(2) = -2.0D0 BU(2) = 0.0D0 * * X(3) is unconstrained, so we set BL(3) to a large negative * number and BU(3) to a large positive number. * BL(3) = -1.0D6 BU(3) = 1.0D6 BL(4) = 1.0D0 BU(4) = 3.0D0 IFAIL = 1 * CALL E04JYF(N,IBOUND,FUNCT1,BL,BU,X,F,IW,LIW,W,LW,IUSER,RUSER, + IFAIL) * IF (IFAIL.LT.0) THEN WRITE (NOUT,*) WRITE (NOUT,99996) ' ** E04JYF returned with IFAIL = ', IFAIL ELSE IF (IFAIL.NE.0) THEN WRITE (NOUT,*) WRITE (NOUT,99999) 'Error exit type', IFAIL, + ' - see routine document' END IF IF (IFAIL.NE.1) THEN WRITE (NOUT,*) WRITE (NOUT,99998) 'Function value on exit is ', F WRITE (NOUT,99997) 'at the point', (X(J),J=1,N) END IF END IF * 99999 FORMAT (1X,A,I3,A) 99998 FORMAT (1X,A,F8.4) 99997 FORMAT (1X,A,4F9.4) 99996 FORMAT (1X,A,I5) END * SUBROUTINE FUNCT1(N,XC,FC,IUSER,RUSER) * Routine to evaluate objective function. * .. Scalar Arguments .. DOUBLE PRECISION FC INTEGER N * .. Array Arguments .. DOUBLE PRECISION RUSER(*), XC(N) INTEGER IUSER(*) * .. Local Scalars .. DOUBLE PRECISION X1, X2, X3, X4 * .. Executable Statements .. X1 = XC(1) X2 = XC(2) X3 = XC(3) X4 = XC(4) FC = (X1+10.0D0*X2)**2 + 5.0D0*(X3-X4)**2 + (X2-2.0D0*X3)**4 + + 10.0D0*(X1-X4)**4 RETURN END