2.2.1 Transshipment Problem with fixed costs (multmip1)

Run LPL Code  ,  PDF Document

Problem

The model is a transportation problem from a set of origins to destinations with variable and fixed costs on each route if used. The model is from [4]

Modeling Steps

An set of products p P must be transported from origins (p.e. warehouses) i O to destinations (p.e. client regions) j D. The supply quantity at the origin i per product p is given as si,p, the demand at the destination j for product p is dj,p. Maximally, ui,j units of the products can be transported on an route (i,j). Variable transportation costs on route (i,j) for product p is vci,j,p. There is also a fixed cost on route (i,j) if this route is use: fci,j. The unknown transporation quantity is a variable Ti,j,p. Furthermore, we need a binary variable Ui,j, which is 1 if the route (i,j) is used. The model is:

          ∑                       ∑
min               vci,j,p ⋅ Ti,j,p +      f ci,j ⋅ Ui,j
      i∈O, j∈D, p∈P              i∈O, j∈D
      ∑
s.t      Ti,j,p = si,p   forall i ∈ O, p ∈ P
      j∈∑D
         Ti,j,p = dj,p   forall j ∈ D, p ∈ P
      i∈O
      ∑  T    <=  u   U     forall i ∈ O, j ∈ D
           i,j,p      i,j i,j
      p∈P

Further Comments

This model showns how close the AMPL (and LPL) notation is to the mathematical notation. To run the model, AMPL uses a separated script language :

  model multmip1.mod;
  data multmip1.dat;
  solve;
  option display_1col 5;
  display Trans;

In LPL, one can also separate data and output instructions from the model structure and then run the following instruction from the command line :
  lplc multmip1 - @INF=’multmip1.txt’#@OUTF=’multmip1.out’

LPL code (run multmip1)

model multmip1 "Transshipment Problem with fixed costs"; 
  set ORIG;   // origins 
  set DEST;   // destinations 
  set PROD;   // products 
 
  parameter supply{ORIG,PROD}; 
  parameter demand{DEST,PROD}; 
  parameter limit{ORIG,DEST}; 
  parameter vcost{ORIG,DEST,PROD}; 
 
  variable Trans{ORIG,DEST,PROD}; 
  parameter fcost{ORIG,DEST}; 
  binary variable Use{ORIG,DEST}; 
 
  minimize TotalCost: 
    sum{i in ORIG, j in DEST, p in PROD} vcost[i,j,p] * Trans[i,j,p] 
    + sum{i in ORIG, j in DEST} fcost[i,j]*Use[i,j]; 
  constraint 
    Supply{i in ORIG, p in PROD}: sum{j in DEST} Trans[i,j,p] = supply[i,p]; 
    Demand{j in DEST, p in PROD}: sum{i in ORIG} Trans[i,j,p] = demand[j,p]; 
    Multi{i in ORIG, j in DEST} : sum{p in PROD} Trans[i,j,p] <= limit[i,j] * Use[i,j]; 
end

LPL output model (download multmip1.out)

model output; 
  Write(' %5s' n', {j in DEST} j); 
  Write{i in ORIG}('%4s %5d' n', i, {j in DEST} sum{p in PROD} Trans[i,j,p]); 
end

AMPL code (download multmip1.mod)

set ORIG;   # origins 
set DEST;   # destinations 
set PROD;   # products 
 
param supply {ORIG,PROD} >= 0;  # amounts available at origins 
param demand {DEST,PROD} >= 0;  # amounts required at destinations 
 
   check {p in PROD}: 
      sum {i in ORIG} supply[i,p] = sum {j in DEST} demand[j,p]; 
 
param limit {ORIG,DEST} >= 0;   # maximum shipments on routes 
param vcost {ORIG,DEST,PROD} >= 0; # variable shipment cost on routes 
var Trans {ORIG,DEST,PROD} >= 0;   # units to be shipped 
param fcost {ORIG,DEST} >= 0;      # fixed cost for using a route 
var Use {ORIG,DEST} binary;        # = 1 only for routes used 
 
minimize Total_Cost: 
   sum {i in ORIG, j in DEST, p in PROD} vcost[i,j,p] * Trans[i,j,p] 
 + sum {i in ORIG, j in DEST} fcost[i,j] * Use[i,j]; 
 
subject to Supply {i in ORIG, p in PROD}: 
   sum {j in DEST} Trans[i,j,p] = supply[i,p]; 
subject to Demand {j in DEST, p in PROD}: 
   sum {i in ORIG} Trans[i,j,p] = demand[j,p]; 
subject to Multi {i in ORIG, j in DEST}: 
   sum {p in PROD} Trans[i,j,p] <= limit[i,j] * Use[i,j];

LPL data (download multmip1.txt)

model data; 
  ORIG := [GARY CLEV PITT] ; 
  DEST := [FRA DET LAN WIN STL FRE LAF] ; 
  PROD := [bands coils plate] ; 
  supply{ORIG,PROD} := / 
             : (tr)  GARY   CLEV   PITT : 
             bands    400    700    800 
             coils    800   1600   1800 
             plate    200    300    300 /; 
  demand{DEST,PROD} := / 
       : (tr)  FRA  DET  LAN  WIN  STL  FRE  LAF : 
       bands   300  300  100   75  650  225  250 
       coils   500  750  400  250  950  850  500 
       plate   100  100    0   50  200  100  250 /; 
  limit{ORIG,DEST} := 625 ; 
  vcost{ORIG,DEST,PROD} := / 
 [*,*,bands]:  FRA  DET  LAN  WIN  STL  FRE  LAF : 
        GARY    30   10    8   10   11   71    6 
        CLEV    22    7   10    7   21   82   13 
        PITT    19   11   12   10   25   83   15 
 [*,*,coils]:  FRA  DET  LAN  WIN  STL  FRE  LAF : 
        GARY    39   14   11   14   16   82    8 
        CLEV    27    9   12    9   26   95   17 
        PITT    24   14   17   13   28   99   20 
 [*,*,plate]:  FRA  DET  LAN  WIN  STL  FRE  LAF : 
        GARY    41   15   12   16   17   86    8 
        CLEV    29    9   13    9   28   99   18 
        PITT    26   14   17   13   31  104   20 /; 
  fcost{o,d} := / 
           :   FRA  DET  LAN  WIN  STL  FRE  LAF : 
        GARY  3000 1200 1200 1200 2500 3500 2500 
        CLEV  2000 1000 1500 1200 2500 3000 2200 
        PITT  2000 1200 1500 1500 2500 3500 2200 /; 
end

AMPL data (download multmip1.dat)

data; 
set ORIG := GARY CLEV PITT ; 
set DEST := FRA DET LAN WIN STL FRE LAF ; 
set PROD := bands coils plate ; 
param supply (tr):  GARY   CLEV   PITT := 
            bands    400    700    800 
            coils    800   1600   1800 
            plate    200    300    300 ; 
param demand (tr): 
               FRA  DET  LAN  WIN  STL  FRE  LAF := 
       bands   300  300  100   75  650  225  250 
       coils   500  750  400  250  950  850  500 
       plate   100  100    0   50  200  100  250 ; 
param limit default 625 ; 
param vcost := 
 [*,*,bands]:  FRA  DET  LAN  WIN  STL  FRE  LAF := 
        GARY    30   10    8   10   11   71    6 
        CLEV    22    7   10    7   21   82   13 
        PITT    19   11   12   10   25   83   15 
 
 [*,*,coils]:  FRA  DET  LAN  WIN  STL  FRE  LAF := 
        GARY    39   14   11   14   16   82    8 
        CLEV    27    9   12    9   26   95   17 
        PITT    24   14   17   13   28   99   20 
 
 [*,*,plate]:  FRA  DET  LAN  WIN  STL  FRE  LAF := 
        GARY    41   15   12   16   17   86    8 
        CLEV    29    9   13    9   28   99   18 
        PITT    26   14   17   13   31  104   20 ; 
 
param fcost:   FRA  DET  LAN  WIN  STL  FRE  LAF := 
        GARY  3000 1200 1200 1200 2500 3500 2500 
        CLEV  2000 1000 1500 1200 2500 3000 2200 
        PITT  2000 1200 1500 1500 2500 3500 2200 ;