Reputation: 11
I tend to write some codes in GAMS that include a loop that exclude some indices ,how can I write some a loop like with exception?
u("p1","j1")*o1("p1","j2") - sum(t,v("p1","j1",t)*I1("p1","j2",t))=l=0;
u("p1","j1")*o1("p1","j3") - sum(t,v("p1","j1",t)*I1("p1","j3",t))=l=0;
in these equations u , o together and also v,I1 together have different indices j; how can write this loop?
Upvotes: 0
Views: 654
Reputation: 556
You can use a loop, but probably a better solution is to limit the equations to the right combination of sets. In any case it can be done using alias of the sets and the SameAs operator.
Alias(p,pp);
Alias(j,jj);
E_myEquation(p,j,pp,jj) $(not (SameAs(p,pp) and SameAs(j,jj)))..
u(p,j)*o1(pp,jj) - sum(t, v(p,j,t)*I1(pp,jj,t)) =l= 0;
This defines the equation for all combinations of (p,j) with itself, except for (p,j)==(p,j).
I hope I have understood the request correctly, but otherwise you can probably figure out the exact implementation you want, using the Alias and SameAs functions.
Upvotes: 1