Lindo Systems

MODEL:
! A generic Transportation Model;
! Keywords: Transportation model, Sparse representation;
SETS:
! The SETS section describes the general data structure;
   SUPPLIER : CAPACITY; ! Each supplier has a capacity;
   CUSTOMER : DEMAND;   ! Each customer has a demand;
! A combination of supplier/customer has a 
     cost/unit shipped and amount shipped;
   LINK( SUPPLIER, CUSTOMER): COST, VOLUME;
ENDSETS
! The Model section;
! The objective;
   MIN = @SUM( LINK( I, J): 
                    COST( I, J) * VOLUME( I, J));

! The capacity constraints. Volume shipped out of I
   must be <= supply at I;
   @FOR( SUPPLIER( I): 
    @SUM( LINK( I, J): VOLUME( I, J)) <= 
     CAPACITY( I));

! The demand constraints. Volume shipped into J
   must equal demand at J;
   @FOR( CUSTOMER( J): 
    @SUM( LINK( I, J): VOLUME( I, J)) = DEMAND( J));

! Here are the data for a specific instance;
DATA:
   SUPPLIER = WH1 WH2 WH3 WH4 WH5 WH6;  
   CAPACITY =  60  55  51  43  41  52; 
   CUSTOMER = V1 V2 V3 V4 V5 V6 V7 V8;
   DEMAND =   35 37 22 32 41 32 43 38;
! The LINK set is sparse. Not all links exist;
      LINK,  COST=
     WH1, V1  6 
     WH1, V2  2 
     WH1, V5  4 
     WH1, V6  2 
     WH2, V1  4 
     WH2, V3  5 
     WH2, V4  3 
     WH2, V8  2
     WH3, V2  2 
     WH3, V3  1
     WH3, V7  3 
     WH3, V8  3 
     WH4, V4  3 
     WH4, V6  2
     WH4, V8  1 
     WH5, V1  2 
     WH5, V2  3
     WH5, V6  2 
     WH6, V3  2 
     WH6, V4  2
     WH6, V6  1 
     WH6, V7  4 
     WH6, V8  3 ;

 ! You can get the data from and store results
  to a spreadsheet with the @OLE() statement,
  or a SQL database with the @ODBC() statement;
ENDDATA
END