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

_______________________________________________
Help-glpk mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-glpk

Reply via email to