help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] Invert a set-of-sets with mutually exclusive elements


From: Meketon, Marc
Subject: Re: [Help-glpk] Invert a set-of-sets with mutually exclusive elements
Date: Thu, 26 May 2016 10:30:45 -0500

Thank you Heinrich.

Both suggestions about max/min_symbolic and the iterated concatenate function 
would be helpful, especially the max/min_symbolic one.  One of my attempts at 
this was to use the iterated "min" (similar to your solution), but it came back 
with a nasty message about only working for numbers, not symbols.

In real life, the names of the pools are not Pool201 etc. but rather names of 
companies.  Pool201 would really be, say "Xerox" and Pool203 would really be, 
say, "Apple" so doing parsing of the name would not help.

The temporary solution that I choose was to begin with the inversion (begin 
with PoolID), and derive the other sets, but that is not the natural way of 
looking at the data.  Like you, I've wanted to do this in other situations in 
the past and never figured out how.

-Marc

-----Original Message-----
From: Heinrich Schuchardt [mailto:address@hidden
Sent: Thursday, May 26, 2016 12:55 AM
To: Meketon, Marc; address@hidden; Andrew Makhorin
Subject: Re: [Help-glpk] Invert a set-of-sets with mutually exclusive elements

Hello Marc,

unfortunately the min and max functions do not accept symbolic parameters.

@Andrew:
I guess it would be quite easy to create a max_symbolic{} and min_symbolic{} 
function. I have been missing these several times. An iterated concatenate{} 
function would also make sense.

So my solution has to rely on the fact that your prefix length in "Pooln" is 
constant.

Best regards

Heinrich

set POOLS := {"Pool201", "Pool203", "Pool204", "Pool205"};

set x_IN_POOLS{POOLS};

set All_x := setof{pool in POOLS, x in x_IN_POOLS[pool]} x;

param PoolID{x in All_x}, symbolic :=
  "Pool" & max{pool in POOLS, y in x_IN_POOLS[pool] : x==y}  substr(pool,5);

display PoolID;

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;


On 05/25/2016 11:23 PM, Meketon, Marc wrote:
> 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 PoolIDthat, 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;
>


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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]