GAMS does not read my code

Problems with modeling
Post Reply
happiniar
User
User
Posts: 2
Joined: 1 month ago

GAMS does not read my code

Post by happiniar » 1 month ago

Dear friends,

I have a problem. Here is my code, but GAMS ignore my second Sum function in "objective" line.

PS: I want to take into consideration the values which are not equal to zero in the Table aa(i,j,i,j) for objective function.

sets i /A,B,C,D/
j /1,2,3,4/;

table d(i,j)
1 2 3 4
A 0.020833 0.083333 0.010417 0.041667
B 0.041667 0.062500 0.020833 0.031250
C 0.062500 0.041667 0.031250 0.020833
D 0.083333 0.020833 0.041667 0.010417 ;

table aa(i,j,i,j)

A.1 A.2 A.3 A.4 B.1 B.2 B.3 B.4 C.1 C.2 C.3 C.4 D.1 D.2 D.3 D.4
A.1 0 0 0 0 0 0.006 0.013 0.020 0 0.014 0.028 0.042 0 0.0216 0.043 0.064
A.2 0 0 0 0 0 0 0.006 0.013 0 0 0.014 0.028 0 0 0.0216 0.0432
A.3 0 0 0 0 0 0 0 0.006 0 0 0 0.014 0 0 0 0.021
A.4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
B.1 0 0.006 0.013 0.020 0 0 0 0 0 0.010 0.020 0.031 0 0.0308 0.0617 0.092
B.2 0 0 0.006 0.013 0 0 0 0 0 0 0.010 0.020 0 0 0.0308 0.061
B.3 0 0 0 0.006 0 0 0 0 0 0 0 0.010 0 0 0 0.0308
B.4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
C.1 0 0.014 0.028 0.042 0.010 0.0209 0.0314 0 0 0 0 0 0 0 0 0
C.2 0 0 0.014 0.028 0 0.0104 0.020 0 0 0 0 0 0 0 0 0
C.3 0 0 0 0.014 0 0 0.020 0 0 0 0 0 0 0 0 0
C.4 0 0 0 0.014 0 0 0.0209 0 0 0 0 0 0 0 0 0
D.1 0 0.021 0.043 0.014 0.030 0.061 0.0209 0 0 0 0 0 0 0 0 0
D.2 0 0 0.021 0.014 0 0.030 0.0209 0 0 0 0 0 0 0 0 0
D.3 0 0 0 0.014 0 0 0.0209 0 0 0 0 0 0 0 0 0
D.4 0 0 0 0.014 0 0 0.0209 0 0 0 0 0 0 0 0 0

;

display aa ;

binary variables x(i,j);

variable z;

equations objective,
con1,
con2;
objective..z=e= Sum((i,j), x(i,j)*d(i,j))+ Sum((i,j), x(i,j)*aa(i,j,i,j));
con1(j)..Sum(i,x(i,j))=e=1;
con2(i)..Sum(j, x(i,j))=e=1

model trial /all/;
solve trial using miqcp minimizing z;

If you give me advices about solving this problem, I would be pretty happy!
Thank you in advance,

Best wishes.

User avatar
dirkse
Moderator
Moderator
Posts: 29
Joined: 1 year ago
Location: Fairfax, VA

Re: GAMS does not read my code

Post by dirkse » 1 month ago

Your problem is similar to that of accessing all elements of a parameter A(i,i). This link explains how an alias (or in your case, two aliases: one for i, another for j) will solve the problem:

User avatar
dirkse
Moderator
Moderator
Posts: 29
Joined: 1 year ago
Location: Fairfax, VA

Re: GAMS does not read my code

Post by dirkse » 1 month ago


happiniar
User
User
Posts: 2
Joined: 1 month ago

Re: GAMS does not read my code

Post by happiniar » 1 month ago

Dear Steve,

Thank you very much for your reply. I will check the link and let you know if I solve it or not.
Thanks again!

All the best

Post Reply