## how to update a set

Problems with syntax of GAMS
yanzhiping
User
Posts: 85
Joined: 1 year ago

### how to update a set

note set B includes 2 subsets B1 and B2, B0 is a subset of B1, B3 is a subset in B2

Code: Select all

``````set
B
B0(B)
B1(B)
B2(B)
B3(B)
B4(B)
Bi(B)
C(B)
;
*set Bi to have 3 same subsets as B
Bi(B)=yes;
display Bi;

B4(Bi)=not B0(Bi);
display B4;

*Bi includes B1 and B3(part of B2)
Bi(B2)=No;
Bi(B3)=yes;
display Bi;

*since Bi is changed, how can we update B4 accordingly? the following code shows the same B4 as before.
B4(Bi)=not B0(Bi);
display B4;
``````

User
Posts: 75
Joined: 1 year ago

### Re: how to update a set

"The membership of B4 is set equal to all those in Bi but not in B0. The operation above is equivalent to the following longer way of representation,

B4(Bi)=yes; B4(B0)=no;"

Key part is "all those in Bi". That definition says nothing about those elements you have removed from Bi, and since you have added them to B4 before, they will remain there.

Easy way out:

Postpone B4 assignment

If that is undesirable:

Reset B4:

B4(B)=NO;
B4(Bi)=not B0(Bi);

yanzhiping
User
Posts: 85
Joined: 1 year ago

### Re: how to update a set

I think the second way works for me, since I need B4 before and after the change of Bi.
Thanks a lot.