CCL Home Page
Up Directory CCL test.f
      SUBROUTINE FCN03(N,X,F)
C
C POWELL"S BADLY SCALED FUNCTION
C
      DIMENSION X(N)
      COMMON/COUNT/IFCNT,IGCNT,IHCNT
      IFCNT=IFCNT+1
      F=(1.E4*X(1)*X(2)-1.)**2 + (EXP(-X(1))+EXP(-X(2))-1.0001)**2
      RETURN
      END
      SUBROUTINE FCN04(N,X,F)
C
C BROWN BADLY SCALED FUNCTION
C
      DIMENSION X(N)
      COMMON/COUNT/IFCNT,IGCNT,IHCNT
      IFCNT=IFCNT+1
      F=(X(1)-1.E6)**2 + (X(2)-2.E-6)**2 + (X(1)*X(2)-2.)**2
      RETURN
      END
      SUBROUTINE FCN05(N,X,F)
C
C BEALE FUNCTION
C
      DIMENSION X(N)
      COMMON/COUNT/IFCNT,IGCNT,IHCNT
      IFCNT=IFCNT+1
      F=(1.5-1.0*X(1)*(1.-1.0*X(2)))**2
     +      + (2.25 -1.0*X(1)*(1.-1.0*X(2)*X(2)))**2
     +      + (2.625-1.0*X(1)*(1.-1.0*X(2)*X(2)*X(2)))**2
      RETURN
      END
      SUBROUTINE FCN07(N,X,F)
C
C HELICAL VALLEY FUNCTION
C
      DIMENSION X(N)
      COMMON/COUNT/IFCNT,IGCNT,IHCNT
      IFCNT=IFCNT+1
      PI=3.1415926535898
      IF(X(1).GT. 0.) TH= (1./(2.*PI)) * ATAN(X(2)/X(1))
      IF(X(1).LT. 0.) TH= (1./(2.*PI)) * ATAN(X(2)/X(1))  + .5
      F=100.*(X(3)-10.*TH)**2
     +      +100.*(SQRT(X(1)**2 + X(2)**2)-1.)**2
     +      + X(3)*X(3)
      RETURN
      END
      SUBROUTINE FCN09(N,X,F)
C
C GAUSSIAN FUNCTION
C
      DIMENSION X(N),Y(15)
      COMMON/COUNT/IFCNT,IGCNT,IHCNT
      IFCNT=IFCNT+1
      Y(1)=.0009
      Y(2)=.0044
      Y(3)=.0175
      Y(4)=.0540
      Y(5)=.1295
      Y(6)=.2420
      Y(7)=.3521
      Y(8)=.3989
      Y(9)= Y(7)
      Y(10)=Y(6)
      Y(11)=Y(5)
      Y(12)=Y(4)
      Y(13)=Y(3)
      Y(14)=Y(2)
      Y(15)=Y(1)
      G=0.
      DO 10 I=1,15
        G=G + (X(1)*EXP( -X(2)*((8.-I)/2.-X(3))**2/2.) - Y(I))**2
   10 CONTINUE
      F=G
      RETURN
      END
      SUBROUTINE FCN12(N,X,F)
C
C BOX 3-DIMENSIONAL FUNCTION(N,X,F)
C
      DIMENSION X(N)
      COMMON/COUNT/IFCNT,IGCNT,IHCNT
      IFCNT=IFCNT+1
      G=0.
      DO 10 I=1,N
        T=I/10.
        G=G + (EXP(-T*X(1)) - EXP(-T*X(2))
     +        - X(3)*(EXP(-T)-EXP(-10.*T)))**2
   10 CONTINUE
      F=G
      RETURN
      END
      SUBROUTINE FCN14(N,X,F)
C
C WOOD FUNCTION
C
      DIMENSION X(N)
      COMMON/COUNT/IFCNT,IGCNT,IHCNT
      IFCNT=IFCNT+1
      F=100.*(X(2)-X(1)*X(1))**2 + (1.-X(1))**2
     +      + 90.*(X(4)-X(3)*X(3))**2 + (1.-X(3))**2
     +      +10.1*( (1.-X(2))**2 + (1.-X(4))**2)
     +      +19.8*(1.-X(2))*(1.-X(4))
      RETURN
      END
      SUBROUTINE GFCN14(N,X,G)
C
C WOOD FUNCTION FIRST DERIVATIVE
C
      INTEGER N
C        INPUT.  LENGTH OF X AND G.  MUST EQUAL 4.
C
      REAL X(N)
C        INPUT.  PARAMETER VECTOR.
C
      REAL G(N)
C        OUTPUT.  GRADIENT VECTOR.
C
      COMMON/COUNT/IFCNT,IGCNT,IHCNT
C
C     BODY OF ROUTINE
C
      IGCNT = IGCNT + 1
C
      FACT1 = X(1)*X(1) - X(2)
      FACT2 = X(3)*X(3) - X(4)
C
      G(1) = 400.0*FACT1*X(1) - 2.0*(1.0 - X(1))
C
      G(2) = -200.0*FACT1 - 20.2*(1.0 - X(2)) - 19.8*(1.0 - X(4))
C
      G(3) = 360.0*FACT2*X(3) - 2.0*(1.0 - X(3))
C
      G(4) = -180.0*FACT2 - 20.2*(1.0 - X(4)) - 19.8*(1.0 - X(2))
C
      RETURN
      END
      SUBROUTINE HFCN14 (NR,N,X,H)
C
C WOOD FUNCTION SECOND DERIVATIVE
C
      INTEGER NR
C        INPUT.  FIRST DIMENSION OF H.
C
      INTEGER N
C        INPUT.  LENGTH OF X.  DIMENSION OF H.  MUST EQUAL 4.
C
      REAL X(N)
C        INPUT.  PARAMETER VECTOR.
C
      REAL H(NR, N)
C        OUTPUT.  HESSIAN MATRIX.
C
      COMMON /COUNT/ IFCNT, IGCNT, IHCNT
C
C     BODY OF ROUTINE
C
      IHCNT = IHCNT + 1
C
      H(1, 1) = 1200.0*X(1)*X(1) - 400.0*X(2) + 2.0
      H(2, 1) = -400.0*X(1)
      H(3, 1) = 0.0
      H(4, 1) = 0.0
      H(2, 2) = 220.2
      H(3, 2) = 0.0
      H(4, 2) = 19.8
      H(3, 3) = 1080.0*X(3)*X(3) - 360.0*X(4) + 2.0
      H(4, 3) = -360.0*X(3)
      H(4, 4) = 200.2
C
      DO 20 IR = 1, 3
         IR1 = IR + 1
         DO 10 IC = IR1, 4
            H(IR, IC) = H(IC, IR)
   10    CONTINUE
   20 CONTINUE
      RETURN
      END
      SUBROUTINE FCN16(N,X,F)
C
C BROWN + DENNIS FUNCTION
C
      DIMENSION X(N)
      COMMON/COUNT/IFCNT,IGCNT,IHCNT
      IFCNT=IFCNT+1
      G=0.
      DO 10 I=1,20
        T=I/5.
        G=G + ((X(1)+T*X(2)-EXP(T))**2
     +      +  (X(3)+X(4)*SIN(T)-COS(T))**2 )**2
   10 CONTINUE
      F=G
      RETURN
      END
      SUBROUTINE FCN18(N,X,F)
C
C BIGGS EXP6 FUNCTION
C
      DIMENSION X(N)
      COMMON/COUNT/IFCNT,IGCNT,IHCNT
      IFCNT=IFCNT+1
      G=0.
      DO 10 I=1,13
        T=I/10.
        G=G + (X(3)*EXP(-T*X(1))-X(4)*EXP(-T*X(2))
     +        + X(6)*EXP(-T*X(5))-EXP(-T)+5.*EXP(-10.*T)
     +        - 3.*EXP(-4.*T) )**2
   10 CONTINUE
      F=G
      RETURN
      END
      SUBROUTINE FCN20(N,X,F)
C
C WATSON FUNCTION
C
      DIMENSION X(N)
      COMMON/COUNT/IFCNT,IGCNT,IHCNT
      IFCNT=IFCNT+1
      G=0.
      DO 40 I=1,29
        T=I/29.
        SUM=0.
        S=1.
        DO 20 J=2,N
          SUM=SUM + (J-1)*X(J)*S
          S=T*S
   20   CONTINUE
        SUM2=0.
        S=1.
        DO 30 J=1,N
          SUM2=SUM2 + X(J)*S
          S=T*S
   30   CONTINUE
        G=G + (SUM - SUM2*SUM2 - 1.)**2
   40 CONTINUE
      G=G + X(1)*X(1) + (X(2)-X(1)**2-1.)**2
      F=G
      RETURN
      END
      SUBROUTINE FCN21(N,X,F)
C
C EXTENDED ROSENBROCK FUNCTION
C
      DIMENSION X(N)
      COMMON/COUNT/IFCNT,IGCNT,IHCNT
      IFCNT=IFCNT+1
      G=0.
      J=N/2
      DO 10 I=1,J
        G=G+ 100.*(X(2*I)- X(2*I-1)**2)**2 + (1.-X(2*I-1))**2
   10 CONTINUE
      F=G
      RETURN
      END
      SUBROUTINE GFCN21(N,X,G)
C
C UNEXTENDED ROSENBROCK FUNCTION FIRST DERIVATIVE
C
      INTEGER N
C        INPUT.  LENGTH OF X AND G.  MUST EQUAL 2.
C
      REAL X(N)
C        INPUT.  PARAMETER VECTOR.
C
      REAL G(N)
C        OUTPUT.  GRADIENT VECTOR.
C
      COMMON/COUNT/IFCNT,IGCNT,IHCNT
C
C     BODY OF ROUTINE
C
      IGCNT = IGCNT + 1
C
      FACT1 = X(1)*X(1) - X(2)
C
      G(1) = 400.0*FACT1*X(1) - 2.0*(1.0 - X(1))
C
      G(2) = -200.0*FACT1
C
      RETURN
      END
      SUBROUTINE HFCN21 (NR,N,X,H)
C
C WOOD FUNCTION SECOND DERIVATIVE
C
      INTEGER NR
C        INPUT.  FIRST DIMENSION OF H.
C
      INTEGER N
C        INPUT.  LENGTH OF X.  DIMENSION OF H.  MUST EQUAL 2.
C
      REAL X(N)
C        INPUT.  PARAMETER VECTOR.
C
      REAL H(NR, N)
C        OUTPUT.  HESSIAN MATRIX.
C
      COMMON /COUNT/ IFCNT, IGCNT, IHCNT
C
C     BODY OF ROUTINE
C
      IHCNT = IHCNT + 1
C
      H(1, 1) = 1200.0*X(1)*X(1) - 400.0*X(2) + 2.0
      H(2, 1) = -400.0*X(1)
      H(2, 2) = 200.0
C
      DO 20 IR = 1, 1
         IR1 = IR + 1
         DO 10 IC = IR1, 2
            H(IR, IC) = H(IC, IR)
   10    CONTINUE
   20 CONTINUE
      RETURN
      END
      SUBROUTINE FCN22(N,X,F)
C
C EXTENDED POWELL SINGULAR FUNCTION
C
      DIMENSION X(N)
      COMMON/COUNT/IFCNT,IGCNT,IHCNT
      IFCNT=IFCNT+1
      G=0.
      J=N/4
      DO 10 I=1,J
        G=G + (X(4*I-3) + 10.*X(4*I-2))**2
     +      + 5.*(X(4*I-1) - X(4*I))**2
     +      + ( (X(4*I-2)-2.*X(4*I-1))**2)**2
     +      + 10.*( (X(4*I-3)-X(4*I))**2)**2
   10 CONTINUE
      F=G
      RETURN
      END
      SUBROUTINE GFCN22(N,X,G)
C
C UNEXTENDED POWELL FUNCTION FIRST DERIVATIVE
C
      INTEGER N
C        INPUT.  LENGTH OF X AND G.  MUST EQUAL 4.
C
      REAL X(N)
C        INPUT.  PARAMETER VECTOR.
C
      REAL G(N)
C        OUTPUT.  GRADIENT VECTOR.
C
      COMMON/COUNT/IFCNT,IGCNT,IHCNT
C
C     BODY OF ROUTINE
C
      IGCNT = IGCNT + 1
C
      FACT1 = X(1) - X(4)
      FACT1 = FACT1*FACT1*FACT1
      FACT2 = X(2) - 2.0*X(3)
      FACT2 = FACT2*FACT2*FACT2
C
      G(1) = 2.0*(X(1) + 10.0*X(2)) + 40.0*FACT1
C
      G(2) = 20.0*(X(1) + 10.0*X(2)) + 4.0*FACT2
C
      G(3) = 10.0*(X(3) - X(4)) - 8.0*FACT2
C
      G(4) = -10.0*(X(3) - X(4)) - 40.0*FACT1
C
      RETURN
      END
      SUBROUTINE HFCN22 (NR,N,X,H)
C
C POWELLS FUNCTION SECOND DERIVATIVE
C
      INTEGER NR
C        INPUT.  FIRST DIMENSION OF H.
C
      INTEGER N
C        INPUT.  LENGTH OF X.  DIMENSION OF H.  MUST EQUAL 4.
C
      REAL X(N)
C        INPUT.  PARAMETER VECTOR.
C
      REAL H(NR, N)
C        OUTPUT.  HESSIAN MATRIX.
C
      COMMON /COUNT/ IFCNT, IGCNT, IHCNT
C
C     BODY OF ROUTINE
C
      IHCNT = IHCNT + 1
C
      FACT1 = X(1) - X(4)
      FACT2 = X(2) - X(3)
C
      H(1, 1) = 2.0 + 120.0*FACT1*FACT1
      H(2, 1) = 20.0
      H(3, 1) = 0.0
      H(4, 1) = -120.0*FACT1*FACT1
      H(2, 2) = 200.0 + 12.0*FACT2*FACT2
      H(3, 2) = -24.0*FACT2*FACT2
      H(4, 2) = 0.0
      H(3, 3) = 10.0 + 48.0*FACT2*FACT2
      H(4, 3) = -10.0
      H(4, 4) = 10.0 + 120.0*FACT1*FACT1
C
      DO 20 IR = 1, 3
         IR1 = IR + 1
         DO 10 IC = IR1, 4
            H(IR, IC) = H(IC, IR)
   10    CONTINUE
   20 CONTINUE
      RETURN
      END
      SUBROUTINE FCN23(N,X,F)
C
C PENALTY FUNCTION I
C
      DIMENSION X(N)
      COMMON/COUNT/IFCNT,IGCNT,IHCNT
      IFCNT=IFCNT+1
      G=0.
      DO 20 I=1,N
        G=G + (1.E-5) * (X(I)-1.)**2
   20 CONTINUE
      SUM=0.
      DO 30 J=1,N
        SUM=SUM + X(J)*X(J)
   30 CONTINUE
      G=G + (SUM-.25)**2
      F=G
      RETURN
      END
      SUBROUTINE FCN24(N,X,F)
C
C PENALTY FUNCTION II
C
      DIMENSION X(N)
      COMMON/COUNT/IFCNT,IGCNT,IHCNT
      IFCNT=IFCNT+1
      G=(X(1)-.2)**2
      DO 10 I=2,N
        T=EXP(I/10.) + EXP((I-1)/10.)
        G=G + 1.E-5* (EXP(X(I)/10.) + EXP(X(I-1)/10.) - T)**2
   10 CONTINUE
      M1=N+1
      M2=2*N-1
      DO 20 I=M1,M2
        G=G + 1.E-5* (EXP(X(I-N+1)/10.) - EXP(1./10.))**2
   20 CONTINUE
      SUM=0.
      DO 30 J=1,N
        SUM=SUM + (N-J+1)*X(J)*X(J)
   30 CONTINUE
      G=G + (SUM-1.)**2
      F=G
      RETURN
      END
      SUBROUTINE FCN25(N,X,F)
C
C VARIABLY DIMENSIONED FUNCTION
C
      DIMENSION X(N)
      COMMON/COUNT/IFCNT,IGCNT,IHCNT
      IFCNT=IFCNT+1
      G=0.
      DO 10 I=1,N
        G=G + (X(I)-1.)**2
   10 CONTINUE
      S=0.
      DO 20 I=1,N
        S=S + I*(X(I)-1.)
   20 CONTINUE
      G=G + S*S + (S*S)**2
      F=G
      RETURN
      END
      SUBROUTINE FCN26(N,X,F)
C
C TRIGONOMETRIC FUNCTION
C
      DIMENSION X(N)
      COMMON/COUNT/IFCNT,IGCNT,IHCNT
      IFCNT=IFCNT+1
      G=0.
      SUM=0.
      DO 10 J=1,N
        SUM=SUM + COS(X(J))
   10 CONTINUE
      DO 20 I=1,N
        G=G+ (N-SUM + I*(1.-COS(X(I))) - SIN(X(I)) )**2
   20 CONTINUE
      F=G
      RETURN
      END
      SUBROUTINE FCN35(N,X,F)
C
C CHEBYQUAD FUNCTION
C
      DIMENSION X(N)
C WORK ARRAYS PASSED THRU COMMON DIMENSIONED .GE. N
      COMMON Y1(100),Y2(100),Y3(100)
      COMMON/COUNT/IFCNT,IGCNT,IHCNT
      IFCNT=IFCNT+1
C
      SUM=0.
      DO 10 J=1,N
        Y1(J)=2.*X(J)-1.
        SUM=SUM+Y1(J)
   10 CONTINUE
      G=(SUM/N)**2
C
      SUM=0.
      DO 20 J=1,N
        Y2(J)=2.*(2.*X(J)-1.)*Y1(J)-1.
        SUM=SUM+Y2(J)
   20 CONTINUE
      G=G+ (SUM/N + 1./3.)**2
C
      SUM=0.
      DO 30 J=1,N
        Y3(J)=2.*(2.*X(J)-1.)*Y2(J)-Y1(J)
        SUM=SUM+Y3(J)
   30 CONTINUE
      G=G+(SUM/N)**2
C
      DO 40 I=4,N
C I-TH COMPONENT
        SUM=0.
        DO 35 J=1,N
          Y1(J)=Y2(J)
          Y2(J)=Y3(J)
          Y3(J)=2.*(2.*X(J)-1.)*Y3(J)-Y1(J)
          SUM=SUM+Y3(J)
   35   CONTINUE
        K=MOD(I,2)
        IF(K.EQ.1) G=G+(SUM/N)**2
        IF(K.EQ.0) G=G+(SUM/N + 1./(I*I-1))**2
   40 CONTINUE
      F=G
      RETURN
      END
Modified: Fri Jul 2 16:00:00 1993 GMT
Page accessed 8468 times since Sat Apr 17 21:35:20 1999 GMT