Hello! I am trying to translate my code from GAMS to GAMSPy. My main problem is the dynamic sets which in GAMS are defined by dollar statements and loop statements. Is there any example that might of help to understand the logic to efficiently make the translation? Here is my GAMS code:
Tb(t)$(ord(t)<(card(t)/2))=yes;
Tl(t)$(ord(t)>(card(t)/2))=yes;
Tl_even(t)$((mod(ord(t),2)=0)and(Tl(t)))=yes;
Tl_odd(t)$((mod(ord(t),2)=1)and(Tl(t)))=yes;
U(k)$(Ord(k)>=5)=yes;
subT(t)=yes;
Parent(t,tt)$(2*ord(t)=ord(tt))=yes;
Parent(t,tt)$(2*ord(t)+1=ord(tt))=yes;
tB(t)$((ord(t)<(card(subT)/2))and(subT(t)))=yes;
tL(t)$((ord(t)>(card(subT)/2))and(subT(t)))=yes;
loop(t,
loop(tt,
anc(t,tt)$(2*ord(t)=ord(tt))=yes;
anc(t,tt)$(2*ord(t)+1=ord(tt))=yes;
));
loop((t,tt),
Tree(t,tt,"left")$((mod(ord(tt),2) = 0)and(anc(t,tt)))=yes ;
Tree(t,tt,"right")$((mod(ord(tt),2) = 1)and(anc(t,tt)))=yes ;
);
loop(t,
loop(tt,
loop(ttt,
anc(t,ttt)$((anc(t,tt))and(anc(tt,ttt))) =yes;
)));
Right(t)$(mod(ord(t),2) = 1)=yes;
Left(t)$(mod(ord(t),2) = 0)=yes;
loop((t,tt,ttt),
path(t,ttt,dd)$((Tree(t,tt,dd))and(anc(tt,ttt))and(anc(t,ttt)))=yes;) ;
path(t,tt,dd)$Tree(t,tt,dd)=yes;