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


parameters
D(k) demand of customers /1 60,2 40,3 70/
cap(i) capacity of firms /A 100,B 90/
C(i,j);

$onecho > book1.txt
par=C  rng=a1 rdim=1 cdim=1
$offecho

$call GDXXRW book1.xlsx  @book1.txt
$GDXIN book1.gdx
$load c
$GDXIN



$ontext
table C(i,j) cost of transportation between firms and stores
         S       T
A        2       5
B        7       4 ;
$offtext


table CP(j,k) cost of transportation between stores and customers
         1       2       3
S        3       4       7
T        2       5       3 ;

variables
Z
integer variable X(i,j)
integer variable Y(j,k);


Equations
objectiveFunction
co1(k)
co2(i)
co3(j) ;

objectiveFunction      .. Z =e= sum((i,j),X(i,j)*c(i,j)) + sum((j,k),y(j,k)*CP(j,k));
co1(k)                 .. sum(j,y(j,k)) =g= D(k);
co2(i)                 .. sum(j,x(i,j)) =l= cap(i);
co3(j)                 .. sum(i,x(i,j)) =G= sum(k,y(j,k)) ;

model supplychain1 /all/;
solve supplychain1 using MIP minimizing Z;
display Z.l , X.l , Y.l,c ;

