[Top][All Lists]

[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: Andrew Makhorin
Subject: Re: [Help-glpk] Invert a set-of-sets with mutually exclusive elements
Date: Thu, 26 May 2016 20:58:00 +0300

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

The following should work (based on Heinrich's example):

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


table foo1{pool in POOLS, x in x_IN_POOLS[pool]} OUT "CSV" "/tmp/foo":
   pool~POOL, x~X;

set All_x;

param PoolID{x in All_x}, symbolic;

table foo2 IN "CSV" "/tmp/foo": All_x <- [X], PoolID~POOL;

display PoolID;


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; 


reply via email to

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