1

i want to calculate symmetric difference between two set V(i,ip) and v(ipp,ippp)

i have set i={1,3,4,6} and j={1,2,..,10} i have set T(i,j) and , 3 set V,W,b too , that

     T(1)={2,5,10}
     T (3)={7,10}
     T (4)={2,5,6}
     T (6)={2,5}

and V is union of T(i) , W is symmetric difference between T and V , and b is a difference between V(i,ip)

the result of my b is not true! why ?

how can i get difference between V(i,ip)?

 v(i,ip)=t(i,j)+t(ip,j)    

 w(i,ip,ipp)= (t(i,j)+v(ip,ipp,j))-(t(i,j)*v(ip,ipp,j));

b(i,ip,ipp,ippp)=((v(i,ip,j)+v(ipp,ippp,j))-(v(ip,ipp,j)*v(ipp,ippp,j))) ;




*---- index and sets----*

sets
     i /1,3,4,6/
     j/1*10/

     t(i,j)  /
     1.(2,5,10)
     3.(7,10)
     4.(2,5,6)
     6.(2,5)
       / ;


 alias(i,ip,ipp,ippp);
 *---- parameter----*

 parameter
     MyOrd(i,ip);


*-------------------------------

MyOrd(i,ip)=i.val+(ip.val -1)*4;


set

     v(i,ip,j)'for union only'
     b(i,ip,ipp,ippp,j) 'symmetric diffrence   between v and v'
     w(i,ip,ipp,j) 'symmetric diffrence   between t and v'
     ;



v(i,ip,j)$(i.val<ip.val)=t(i,j)+t(ip,j);

w(i,ip,ipp,j)$(ip.val<ipp.val) =(t(i,j)+v(ip,ipp,j))-(t(i,j)*v(ip,ipp,j));

b(i,ip,ipp,ippp,j)$(i.val<ip.val and ipp.val<ippp.val and MyOrd(i,ip) 

display t,v,w,b;
  • 1
    for example for b (1,4,4,6)=10 but my code tell b (1,4,4,6)=2,5,6,10 –  Aug 04 '18 at 12:53
  • Did you check this post? https://stackoverflow.com/questions/51400240/how-can-define-union-intersection-symmetric-difference – Lutz Aug 06 '18 at 07:12
  • @lutz ,yes but I have the same trouble . –  Aug 07 '18 at 09:00
  • 1
    @lutz I want to have symmetric difference between two set T and V . and symmetric difference between every set V (for example (between v(1,6) and v(1,3) or v(3,4)) . I don't want to have duplicate set like w(1,23) and w(1,32) because these two set are same. My code doesn't work well –  Aug 07 '18 at 09:07

1 Answers1

1

in your code you write

 MyOrd(i,ip)=i.val+(ip.val -1)*4;

try with

parameter
     MyOrd(i,i1);
scalar
     counter /1/
;

 loop((i,i1)$(vulnerable(i) and vulnerable(i1) and i.val <i1.val ),
     MyOrd(i,i1)=counter;
     counter=counter+1;
 );
yaodao vang
  • 168
  • 10