
      !!!!    PROGRAM DemoSimplex

      INCLUDE 'STDHDR.FOR'
      REAL cnstr(0: maxr, 0: maxc),rh(0: maxv),obj(0: maxv)
      REAL ofv(0: maxv),os(0: maxv)
      INTEGER br(0:maxc),i,nr,nc

      nr = 3  ! number of constraints
      nc = 4  ! number of variables

      !      coefficients of constraint variables

       cnstr(0, 0) = 1.0
       cnstr(0, 1) = 1.0
       cnstr(0, 2) = 1.0
       cnstr(0, 3) = 1.0

       cnstr(1, 0) = 7.0
       cnstr(1, 1) = 5.0
       cnstr(1, 2) = 3.0
       cnstr(1, 3) = 2.0

       cnstr(2, 0) = 3.0
       cnstr(2, 1) = 5.0
       cnstr(2, 2) = 10.0
       cnstr(2, 3) = 15.0

       ! values of constraint right hand sides

       rh(0) = 15.0
       rh(1) = 120.0
       rh(2) = 100.0

      ! {coefficients of objective function}

      obj(0) = 4.0
      obj(1) = 5.0
      obj(2) = 9.0
      obj(3) = 11.0

      CALL simplex(cnstr, obj, rh, nr, nc, os, br, ofv)
      WRITE(*,*) ' Optimal solution'
      DO i = 0, nr
        WRITE (*,10) 'Variable # ', br(i),os(i)
      END DO
      WRITE( *,*)
      WRITE (*,*) 'Objective function values'
      DO i = 0, nc + nr
        WRITE (*,10) 'Variable # ', i,ofv(i)
      END DO
      READ (*,*)

10    FORMAT (1X,A15,I2,5X,F7.2)

      END


