Tuslu
Tuslu

Reputation: 1

GAMS code Error: indexing issue for parameter


Sets
    i /1, 2, 3, 4, 5/
    t /1, 2, 3, 4, 5, 6, 7, 8, 9/;

Alias(t, u);

Parameter
    p(i)  'Number of weeks to complete job i'
          /1 3
           2 2
           3 4
           4 4
           5 3/;

Parameter
M(t)
          /1 30
           2 30
           3 30
           4 30
           5 30
           6 30
           7 30
           8 30
           9 30 /;
table L(i,u)
   1  2  3  4
1  2  3  1  0
2  4  5  0  0
3  2  4  1  5
4  3  4  2  2
5  9  2  3  0;


binary variable x(i,t);
free variable
z;

Equations obj,C1(i), C2(i,u),C3(t),C4(t);

obj.. z=e=z;

C1(i).. sum(u$(ord(u) <= (9 - p(i) + 1)),x(i, u)) =e= 1;

C2(i, u)$((ord(u) + p(i) - 1) > card(t)).. x(i, u) =e= 0;

C3(t).. sum(i,sum(u$(ord(u) >= (ord(t) - p(i) + 1) and ord(u) <= ord(t)),L(i,t-u+1)*x(i,u)))=l=M(t);

C4(t).. sum(i,sum(u$(ord(u) >= (ord(t) - p(i) + 1) and ord(u) <= ord(t)),L(i,t-u+1)*x(i,u)))=l=z;

model JobScheduling/all/;
option mip=cplex;
solve JobScheduling minimizing z using mip;`

**I am getting error about L(i,t-u+1) part. t-u+1 is not calculated by the program. What is the issue there. The error:dimension different. I just want to use t-u+1 values instead of u for L(i,u).

Upvotes: 0

Views: 23

Answers (1)

Lutz
Lutz

Reputation: 2292

I guess you need to use ord(u) instead, so change equations C3 and C4 to

C3(t).. sum(i,sum(u$(ord(u) >= (ord(t) - p(i) + 1) and ord(u) <= ord(t)),L(i,t-(ord(u)+1))*x(i,u)))=l=M(t);

C4(t).. sum(i,sum(u$(ord(u) >= (ord(t) - p(i) + 1) and ord(u) <= ord(t)),L(i,t-(ord(u)+1))*x(i,u)))=l=z;

Upvotes: 0

Related Questions