$TITLE  DISCRETIZE PROBLEM
$OFFUPPER
* This problem solves the infinite LP on pg 10 of
*  Anderson and Nash, by discretization.
*
*  References: 
*        The problem is taken from the book on Linear Programming
*        in Infinite Dimensional Spaces.
*
*  The number of discretization points is 11. The dimension
*   of I and the constant n need to be changed if the
*   number of discretization points are increase.

  SETS
       I   discretization points   / I1*I11 /
       J   discretization points   / J1*J11 /;

VARIABLES
  X1(I)   
  X2(I)   
  Z;

POSITIVE VARIABLES X1, X2 ;

X1.UP(I)=2;

X2.UP(I)=4;

SCALAR N number of discretization points /11/ ;

EQUATIONS
   COST   objective function
   STRGL(J)  lower bound on storage
   STRGU(J)  upper bound on storage;

COST .. Z =E= SUM(I,X2(I))/N;

STRGL(J) .. SUM(I$(ORD(I) LE ORD(J)),(X1(I)-X2(I)))/N =G= 0;
* STRGL(J) .. SUM(I$(IND(I,J) NE 0),(X1(I)-X2(I)))/N =G= 0;

STRGU(J) .. SUM(I$(ORD(I) LE ORD(J)),(X1(I)-X2(I)))/N =L= 1;
*STRGU(J) .. SUM(I$IND(I,J),(X1(I)-X2(I)))/N =L= 1;

MODEL DISCRETIZE /ALL/;

SOLVE DISCRETIZE USING LP MAXIMIZING Z;

DISPLAY X1.L, X2.L, Z.L ;

