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: Heinrich Schuchardt
Subject: Re: [Help-glpk] Invert a set-of-sets with mutually exclusive elements
Date: Thu, 26 May 2016 06:54:59 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.8.0

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;
> 



reply via email to

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