'Equation Coding in GAMS environment
everybody, there is a constraint called k4 I want to code but I don't know how to achieve it. How I can write this equation in the GAMS environment? The k4 constraint I want to encode is as in the picture:
I think, I coded all constraints (k1, k2, k3, k5, k6, k7 k8, and k9) except k4. Unfortunately, I don't know how I code constraint k4 that is seen in the picture.
My code is as follows:
Sets
t /0*15/
i /1*6/
m /1*4/
k /1*3/;
Alias(i,j);
Parameter
p(i)
/1 0
2 2
3 5
4 3
5 3
6 0/;
Parameter
Prec(i,j);
Prec("1","2") = 1;
Prec("1","3") = 1;
Prec("2","4") = 1;
Prec("3","5") = 1;
Prec("4","6") = 1;
Prec("5","6") = 1;
Table S(m,k)
1 2 3
1 0 1 1
2 1 0 1
3 1 0 0
4 1 0 1;
Table b(i,k)
1 2 3
1 0 0 0
2 0 1 1
3 1 0 1
4 2 1 0
5 0 1 0
6 0 0 0;
Variables
st(i)
obj;
Binary Variables
x(i,m,t)
y(i,m,k)
z(i,t);
Equations
amac, k1, k2, k3, k4, k5, k6, k7, k8, k9;
amac(i).. obj =e= sum(t, z(i,t)*ord(t));
k1(i).. st(i) =e= sum(t, z(i,t)*ord(t));
k2(i,j)$(Prec(i,j)).. st(i)+p(i) =l= st(j);
k3(i,m,t).. x(i,m,t) =l= 1;
k4(t).. sum((i,d), x(i,m,d)) =l= 1;
k5(i,m,t).. x(i,m,t) =l= z(i,t);
k6(i,m,t).. x(i,m,t)+1 =l= z(i,t)+sum(k, y(i,m,k));
k7(i,m,k).. y(i,m,k) =l= S(m,k);
k8(i,k).. sum(m, y(i,m,k)) =e= b(i,k);
k9(i,m).. sum(t, x(i,m,t)) =e= sum(k, y(i,m,k));
Model MSRCPSP /all/;
Solve MSRCPSP using MIP minimizing obj;
Display x.l, y.l, z.l;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
