I have 3 set A /45200/ ,B/39443/ ,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.
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:
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);