delete a whole subset from the root set

40 views
Skip to first unread message

Gabriela G.

unread,
May 10, 2019, 4:25:53 PM5/10/19
to AIMMS - The Modeling System
I fill a subset inside a procedure and I want to delete the elements in this subset in the root set.

Subset := { };
if(something)then
Subset +=ElementCast(Set,s);
endif;

for(k in Subset)do
Set -= s;
endfor; 
 
It works for the first element in the subset, but it doesn´t delete the other elements. 

Mohan

unread,
May 12, 2019, 1:56:26 AM5/12/19
to AIMMS - The Modeling System
Hello Gabriela,

Just wanted to confirm if your "Subset" a subset of "Set" ? As you are using ElementCast, I am assuming that Subset is an unrelated set to Set.

The code inside your for loop should be

Set -= k

You are iterating over k but deleting the element s. The value of s is not changing.

Gabriela G.

unread,
May 12, 2019, 10:07:38 PM5/12/19
to AIMMS - The Modeling System
Subset is a subset of Set, I use ElementCast because I thought it was necessary.

I use 

for(k in Subset)do
Set -= k;
endfor; 

And it only deletes the first element.

Mohan

unread,
May 12, 2019, 11:35:04 PM5/12/19
to AIMMS - The Modeling System
Hi Gabriela,

If Subset is a subset of Set, then removing k from Set will also remove it from the subset.

May I ask what are you trying to achieve here so that I could recommend an approach ?

Gabriela G.

unread,
May 13, 2019, 12:48:42 AM5/13/19
to AIMMS - The Modeling System
Yes, I know that it would delete the element from the subset, but I want to delete all the elements from the subset in the root set, it doesn't matter if the subset ends up being empty.

I'm trying to delete multiple elements from a set and that's the only idea I had.


El viernes, 10 de mayo de 2019, 15:25:53 (UTC-5), Gabriela G. escribió:

Mohan

unread,
May 13, 2019, 7:51:34 AM5/13/19
to AIMMS - The Modeling System
Ok, can you try the below code ?

Set -= {s | s in Subset}
Reply all
Reply to author
Forward
0 new messages