Error 148 - Dimension Different

Problems with syntax of GAMS
Post Reply
oguzhnorhn
User
User
Posts: 2
Joined: 3 years ago

Error 148 - Dimension Different

Post by oguzhnorhn »

Hello everyone,
I am pretty new to GAMS so i have a lot of problems doing my homework about assembly lines. I couldnt find where the problem is in my code stated below. Thanks for your help. Wish you healty days!
sets
j tasks /Task1*Task11/
Screenshot_1.png
i jobs /1*11/
k stations /1*8/
parameter Ear(i) /1 1, 2 1, 3 1, 4 2, 5 1, 6 2, 7 3, 8 2, 9 3, 10 4, 11 6/ ;
parameter Lat(i) /1 4, 2 5, 3 5, 4 6, 5 8, 6 7, 7 6, 8 7, 9 7, 10 7, 11 8/ ;


Variable
z;
Binary Variable x(i,k), y(k);
Table p(i,j) 'precedence matrix'
Task1 Task2 Task3 Task4 Task5 Task6 Task7 Task8 Task9 Task10 Task11
1 0 1 1 0 0 0 0 0 0 0
2 0 1 1 0 0 0 0 0 0
3 0 0 1 1 0 0 0 0
4 0 0 1 0 0 0 0
5 0 0 0 0 0 1
6 0 1 0 0 0
7 0 1 0 0
8 0 0 1
9 1 0
10 1
11 ;

equations
obj
ass
precedence
cycle;
obj.. sum(k, y(k)) =e= z;
ass.. sum(i, sum(k $(Ord(k)<=Lat(i) and Ord(k)>=Ear(i)), x(i, k))) =e= 1;
precedence.. sum(i,k, k*x(i,k)-sum(j,k $((p(i,j)=1) and Ord(k)<=Lat(j) and Ord(k)>=Ear(j)), k*x(j,k)))=l=0
Model hw2 / all /;

solve hw2 using lp minimizing z;

The problem is with the "k" in big letter. I get the errors 148, 8, 653, 37 and 409.
abhosekar
Moderator
Moderator
Posts: 295
Joined: 3 years ago

Re: Error 148 - Dimension Different

Post by abhosekar »

the correct syntax is sum((i, k), ....)

Hope this helps.

Atharv
oguzhnorhn
User
User
Posts: 2
Joined: 3 years ago

Re: Error 148 - Dimension Different

Post by oguzhnorhn »

abhosekar wrote: 3 years ago the correct syntax is sum((i, k), ....)

Hope this helps.

Atharv
Thanks for your reply,
I corrected it after posting this message but still getting same errors. Do you have any other advice?
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: Error 148 - Dimension Different

Post by Renger »

Hi

k is not interpreted by Gams as an integer (it is a string), so you have to use k.val to get the value.
Check the parenthesis very carefully. Build an expression like this in two steps. Write it first without the second sum. Run your code (without solving the model). If that is fine, do the same with the second sum.

Check the messages provided by Gams. If you write "sum((j,k)$p(i,j)" Gams is missing an index to compare the j in the summation with, so you might want to sum like this sum((i,j,k)$p(i,j).
You use Lat(j) but Gams will tell you that it is defined differently (you defined it over i not over j).

And a last remark: put your code in a code block as this preserves the format of your table (use the </> symbol in the post editor). Otherwise, people have to format the table back to the intended format.

Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Post Reply