I’m trying to model a transshipment problem, the mathematical formulation of which is given in the picture attached.
There are m supply centers and n demand centers, and X_ij_ is the quantity shipped from center i to center j. Since in a transshipment problem, any supply or demand center can ship to any other supply or demand center, supply centers are numbers from 1 to m, whereas demand centers from m+1 to m+n.
The problem I’m facing is with writing the constraints on GAMS. After searching through some posts on the forum and going through GAMS’s YouTube tutorial on sets, I’ve been attempting to introduce dynamics sets to differentiate i, j, m and n so that these can be modeled in the constraints. I have come up with the following code for the aforementioned mathematical model.
$ title Transshipment
Set
* set of supply and demand centers
i / Brn, Rxl, Brj, Amj, Ktm, Pkr /
j(i)
m(i)
n(i);
j(i) = yes;
* selecting only the supply centers from i
m(i) = yes;
m('Brj') = no;
m('Amj') = no;
m('Ktm') = no;
m('Pkr') = no;
* selecting only the demand centers from i
n(i) = yes;
n('Brn') = no;
n('Rxl') = no;
Parameter
supply(i) /
Brn 40100
Rxl 46400
Brj 0
Amj 0
Ktm 0
Pkr 0 /;
Parameter
demand(j) /
Brn 0
Rxl 0
Brj 8700
Amj 35200
Ktm 20700
Pkr 5800 /;
Parameter T 86500;
Table cost(i,j)
Brn Rxl Brj Amj Ktm Pkr
Brn 0 243.4 250.6 280.2 511.5 490.5
Rxl 243.4 0 7.2 36.8 268.1 247.1
Brj 250.6 7.2 0 30.4 261.7 240.7
Amj 280.2 36.8 30.4 0 231.3 210.3
Ktm 511.5 268.1 261.7 231.3 0 247
Pkr 490.5 247.1 240.7 210.3 247 0;
Positive variable
X(i,j);
Variable
Z;
Equation
obj
con1(m)
con2(n)
con3(m)
con4(n)
nnc(i,j);
obj.. sum((i,j), cost(i,j)*X(i,j)) =e= Z;
con1(m).. sum(j, X(m,j)) =l= supply(m) + T;
con2(n).. sum(j, X(n,j)) =e= T;
con3(m).. sum(i, X(i,m)) =e= T;
con4(n).. sum(i, X(i,n)) =g= demand(n) + T;
nnc(i,j).. X(i,j) =g= 0;
Model transshipment / all /;
Options MIP = Cplex;
Solve transshipment minimizing Z using MIP;
Display X.l;
I’ve been facing the errors:
171 Domain violation for set
187 Assigned set used as domain
Where and how I did I go wrong with the way I have used sets here? Further help with modeling the constraints for different subset assignments of i and j as in the mathematical model would be much appreciated.