help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-glpk] Re: Retrieve element of set in GMPL


From: Andrew Makhorin
Subject: [Help-glpk] Re: Retrieve element of set in GMPL
Date: Thu, 02 Dec 2010 02:20:05 +0300

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.




reply via email to

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