Lindo Systems

! Standard fixed charge transportation problem;
! Keywords: Fixed charge, Transportation problem;
sets:
  source: capacity, fixedcost, open;
  dest: demand;
  sxd( source, dest): costpu, ship;
endsets
data:
! Sources of production;
 source  =  PLANT01  PLANT02 PLANT03;
! Capacity of each source;
 capacity =  1200     1800    1500;
! Fixed cost if we ship anything from source;
 fixedcost=  1800     1900    1700;

! Destinations;
   dest  =  CUST01   CUST02   CUST03   CUST04;
! Demand at each destination;
   demand =  600      700      500      550;
! Cost per unit shipped from each source to each destination;
   costpu =    9        8        6        7
               5        7        8        6
               6        5        9        8;
enddata
! Variables:
     open( s) = 1 is source s is used (or open), else 0,
                 i.e., it is a binary variable,
     ship( s, d) = amount shipped from source s to destination d;
! LINGO assumes by default that all variables are >= 0;

! minimize fixed cost + shipping costs;
   min = fctot + sctot;
        fctot = @sum( source( s): fixedcost( s)* open(s));
        sctot = @sum( sxd( s, d) : costpu( s, d)* ship( s, d));

 @for( source( s):
    @bin( open( s)); ! Source is either used (1) or not used (0);
 ! Cannot ship more than installed capacity from source s;
    @sum( sxd( s, d): ship( s, d)) <= capacity( s)* open(s);
     );

 @for( dest( d):
! Must satisfy demand at each destination d;
    @sum( sxd( s, d): ship( s, d)) = demand( d); 
       );