I have a simple set of sets that has mutually exclusive elements that I would
like to invert into a param that, for each element, gives me the ID of the set
it belongs to.
Below is an example of the set of sets with mutually exclusive elements:
set POOLS := {"Pool201", "Pool203", "Pool204", "Pool205"};
set x_IN_POOLS{POOLS};
check {pool1 in POOLS, pool2 in POOLS : pool1 != pool2} card(x_IN_POOL[pool1]
inter x_IN_POOL[pool2])==0;
data;
set x_IN_POOLS ["Pool201"] := 234, 345, 456, 567, 678, 012, 543;
set x_IN_POOLS ["Pool203"] := 789, 890;
set x_IN_POOLS ["Pool204"] := 123, 901;
set x_IN_POOLS ["Pool205"] := 987, 876, 765, 654;
end;
I would like to calculate a param PoolID that, for a given "x", gives the
"Pool" it belongs to. This is equivalent to the following, but I want to use
GMPL to calculate the following and not code this into the data:
set All_x := setof{pool in POOLS, x in x_IN_POOL[pool]} x;
param PoolID{All_x}, symbolic;
data;
param PoolID :=
123 Pool204
234 Pool201
345 Pool201
456 Pool201
567 Pool201
678 Pool201
789 Pool203
890 Pool203
901 Pool204
012 Pool201
987 Pool205
876 Pool205
765 Pool205
654 Pool205
543 Pool201
;
I have not yet figured out a clever way to do the above with calculations and
no "data" section.
BTW, I do know that I could begin with the definition of All_x and PoolID, and
derive the set POOLS and the set-of-sets x_IN_POOLS:
set POOLS := setof{x in All_x} PoolID[x];
set x_IN_POOL{pool in POOLS} := setof{x in All_x : pool = PoolID[x]} x;
display x_IN_POOL;
But I didn't want to model my data that way.
-Marc
________________________________
This e-mail and any attachments may be confidential or legally privileged. If
you received this message in error or are not the intended recipient, you
should destroy the e-mail message and any attachments or copies, and you are
prohibited from retaining, distributing, disclosing or using any information
contained herein. Please inform us of the erroneous delivery by return e-mail.
Thank you for your cooperation.
_______________________________________________
Help-glpk mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-glpk