On Wed, 2010-12-01 at 15:41 -0500, John Foreman wrote:
> Hello,
> 
>  
> 
> Are there any plans to put any functions in GMPL that take a set as
> input and return an individual element? I’m thinking of functions such
> as element(set,index), first(), and last() in AIMMS and OPL.
> 
>  
> 
> Thanks,
> 
> John Foreman
> 
> Senior Operations Research Consultant
> 
>  
> 
> Revenue Analytics, Inc.
> 
> 3100 Cumberland Blvd.
> 
> Suite 1000
> 
> Atlanta, Georgia 30339
> 
> www.revenueanalytics.com
> 
>  

Set is an unordered collection, so it is impossible to define any
natural ordering of its elements. For example, the first element of a
set could be defined as an element which appears first in some list,
however, it could also be defined as a lexicographically minimal
element, or even as an element on which some ordering function takes a
minimal value.

In GNU MathProg this issue can be resolved by defining a mapping like
follows:

set S;
param elem{i in 1..card(S)}, symbolic, in S;
data;
set S := red green blue;
param elem [1] blue, [2] red, [3] green;

where elem[i] is i-th element of S.


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

Reply via email to