how to update a set

Problems with syntax of GAMS
yanzhiping
User
User
Posts: 84
Joined: 6 months ago

how to update a set

Postby yanzhiping » 6 months ago

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;

cladelpino
User
User
Posts: 48
Joined: 7 months ago

Re: how to update a set

Postby cladelpino » 6 months ago

I adapted the text at https://www.gams.com/latest/docs/userguides/userguide/_u_g__dynamic_sets.html#UG_DynamicSets_SetComplement to your sets

"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
User
Posts: 84
Joined: 6 months ago

Re: how to update a set

Postby yanzhiping » 6 months ago

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


Return to “Syntax”

Who is online

Users browsing this forum: No registered users and 1 guest