equaiton based on part of a set Topic is solved

Problems with syntax of GAMS
Post Reply
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: equaiton based on part of a set

Post by Renger »

Hi

sameas(a,b) expects both a and b in the equation, so they can be compared (e.g. eq1(a,b)$(not sameas(a,b)).

Example:

Code: Select all

set A/a1*a10/;
set B(A)/a2*a4/;
set C(A);
C(A)= not B(A);

parameter t(a,b);

t(a,b)$(not sameas(a,b)) = 1;

display t;
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
cladelpino
User
User
Posts: 108
Joined: 7 years ago

Re: equaiton based on part of a set

Post by cladelpino »

When you do:

Code: Select all

Eq1(A)$(not sameas (A,B))
You have no control over set B. This is not a valid gams statement, and will trigger and "Uncontrolled set entered as constant" error.

Conditions are meant to be evaluated in particular elements of the sets. sameas(A,B) is not for checking if an element of A belongs in B, rather, that an element of A being considered is the same as the element of B being considered, in a particular "instance" of the equation.

Example of sameas():

Code: Select all

Set A /a1*a3/;
set b /a1*a3/;

parameter k(a,b);

k(a,b)$(not sameas(a,b))=1;

display k;
cladelpino
User
User
Posts: 108
Joined: 7 years ago

Re: equaiton based on part of a set

Post by cladelpino »

:lol: at similarity of example
Post Reply