tell to GAMS, an element isn't belong to set.

Archive of Gamsworld Google Group
Post Reply
richard
User
User
Posts: 27
Joined: 5 years ago

tell to GAMS, an element isn't belong to set.

Post by richard »

Hi everyone


I have 3 set A /45*200/ ,B/39*443/ ,and c/12*187/.
I show symmetric difference of A,B by symAB,
symmetric difference of A,c by symAc and
symmetric difference of B,c by symBc, I want to code below summation in GAMS

Sum(k$ k isn't belong to symAB)+Sum(k$ k isn't belong to symAc) <= Sum(j$ j isn't belong to symBc)

My questions

Should I define new subset j and k ?

I don't know how I can tell to GAMS, an element isn't belong to set.

How should I do?

Thanks & Best
Richard
User avatar
bussieck
Moderator
Moderator
Posts: 1033
Joined: 7 years ago

Re: tell to GAMS, an element isn't belong to set.

Post by bussieck »

The answer is not so clear. When you write "k$ k isn't belong to symAB" could this mean that k is part of the intersection of A and B or the intersection plus the elements that are neither in A nor in B. My code shows what I mean:

Code: Select all

set N / 1*500 /;
set A(N) /45*200/, B(N) /39*443/, C(N) /12*187/;
set symAB(N), symAC(N), symBC(N);

$macro symDiff(x,y,i) (x(i) and not y(i)) or (y(i) and not x(i))
symAB(N) = symDiff(A,B,N);
symAC(N) = symDiff(A,C,N);
symBC(N) = symDiff(B,C,N);

scalar ans1; ans1 = sum(N$(not symAB(N)), 1);
scalar ans2; ans2 = sum(N$(A(N) and B(N)), 1);
-Michael
Post Reply