0

I have a few collection ,and the intersection of these collections gives me a few new collection.

I want to have summation under these intersections , but some of these are null. And I get an error for my summation, for example

 Set I/1*3/;
  Set j/1*3/;
  Set  s(I,j)
 1.(2,3)
 2.(1,3)
 3.(2);
Alias (I,i1,j);
  Set  intersection (I,i1,j);
 Intersection (I,i1,j)= s(I,j)*s(i1,j);
 Variable x(j) ,z;
 Binary variable x;
 Equation    c1,c2;

  C1(I)..sum(j$s(I,j),x(j))=e=z;
 C2(I,i1)..sum(j$ intesection(i,I1,j),x(j))=g=1;
 Model test /all/;
 Solve test using lp minimizing z;

I have error for constraint 2 because intersection(2,3) is null ,and I have 0> 1

How can I write this summation?

Richard
  • 177
  • 1
  • 9

1 Answers1

1

I do not really understand, what you model here, but this way it runs without an error (there is still no feasible solution though because of equation C1('3')):

Set I/1*3/;
Set j/1*3/;
Set  s(I,j) / 1.(2,3)
              2.(1,3)
              3.(2)   /;
Alias (I,i1);
Set  intersection (I,i1,j);
Intersection (I,i1,j)= s(I,j)*s(i1,j);

Variable x(j) ,z;
Binary variable x;
Equation    c1,c2;

C1(I)..  sum(j$s(I,j),x(j))=e=z;
C2(I,i1)$sum(j$ Intersection(i,I1,j),1)..
         sum(j$ Intersection(i,I1,j),x(j))=g=1;
Model test /all/;
Solve test using mip minimizing z;
Lutz
  • 2,197
  • 1
  • 10
  • 12