$title Supplychain

$ontext
supply chain first modeling
$offtext

$onsymxref;
$onsymlist;

sets
i index of firms /A,B/
j index of stores /S,T/
k index of customers /1*3/ ;

parameters
cap(i) capacity of each firm /A 210
                              B 100/
D(k) demand of each customers /1 60,2 40,3 210/
F(i,j,k) transportation cost;


table c(i,j,k) transportation distance
         1       2       3
A.S      5       6       9
A.T      7       10      13
B.S      10      11      14
B.T      6       9       7     ;

F(i,j,k)= 10 * C(i,j,k);

variable Z;
integer variable X(i,j,k);
*X.fx("a","s","3")=20;
X.up(i,j,k)=1000;

equations
ObjectiveFunction
Co1(i)
Co2(k);

ObjectiveFunction  .. Z =e= sum((i,j,k),x(i,j,k)*f(i,j,k));
Co1(i)             .. sum((j,k),X(i,j,k)) =l= cap(i);
Co2(k)             .. sum((i,j),X(i,j,k)) =g= D(k);

model example2 /all/
option  limrow=100, limcol=100;
option MIP=Cplex;
solve example2 using MIP minimizing Z;
display Z.l , X.l;