loop over two sets

Problems with syntax of GAMS
Post Reply
cladelpino
User
User
Posts: 108
Joined: 7 years ago

Re: loop over two sets

Post by cladelpino »

Loop part is correct, declarations are not. I took the code to correct syntax (other ways are also possible):

sets
A /a,b,c/
A1 /a1,b1/;
parameter
B(A, A1) /
a.a1 1
a.b1 1
b.a1 2
b.b1 3
c.a1 2
c.b1 3/;
parameter
C(A,A1)
;
loop((A,A1),
C(A,A1) =ceil(B(A, A1)/2);
);

Display C;
cladelpino
User
User
Posts: 108
Joined: 7 years ago

Re: loop over two sets

Post by cladelpino »

Besides: the loop is actually unnecesary.

C(A,A1) =ceil(B(A, A1)/2);

will just do the trick
cladelpino
User
User
Posts: 108
Joined: 7 years ago

Re: loop over two sets

Post by cladelpino »

this is the correct way:

A(Year)$(ord(Year)<card(Year)) = (card(Year)-1)*card(dset) - (ord(Year)-1)*card(dset);
Post Reply