Very clever solution. Thank you. However, having the max/min_symbolic would be less esoteric maybe more useful.
Sent from my mobile > On May 26, 2016, at 1:58 PM, Andrew Makhorin <[email protected]> wrote: > > >> 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"}; > > set x_IN_POOLS{POOLS}; > > 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; > > 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; > > > 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
