help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] First element of the set


From: Haroldo Santos
Subject: Re: [Help-glpk] First element of the set
Date: Wed, 14 Dec 2011 21:31:45 -0200

A function returning the smallest element from a set would be very useful for me too.

anything better than the the O(n^2) suggestion would be great....
set F := setof{ s in S : forall{u in S} s <= u } s;

Can this be implemented in GLPK ?

On Thu, Oct 22, 2009 at 3:05 PM, xypron <address@hidden> wrote:

Hello

>> have a set MBC.
>> Now I need the restriktion, y[x]=0 where x is just the first element of
>> the MBC.

sets in GLPK are unordered. Hence the first element cannot be accessed. Of
cause you could define a parameter with the value of the first element.

Determining a set containing the smallest element of a given set is
possible.
See example below.

Best regards

Xypron

# some set
set S;
# set of the smallest element in S
# GLPK is inefficient here, needing O(n^2) time!
set F := setof{ s in S : forall{u in S} s <= u } s;
# variable
var y{s in S}, >= 0, <=1;
# some objective
maximize obj :
 sum{s in S} y[s];
# constraint for the smallest element in S
s.t. c1{s in F} :
 y[s] = 0;
# display constraint
display c1;
# initialization
data;
set S := the quick brown fox jumps over a lazy dog;

--
View this message in context: http://www.nabble.com/First-element-of-the-set-tp26010502p26013668.html
Sent from the Gnu - GLPK - Help mailing list archive at Nabble.com.



_______________________________________________
Help-glpk mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/help-glpk



--
=============================================================
Haroldo Gambini Santos
Computing Department - Universidade Federal de Ouro Preto - UFOP
email: haroldo [at ] iceb.ufop.br
home/research page: www.decom.ufop.br/haroldo/
 
"Computer science is no more about computers than astronomy
is about telescopes." Edsger Dijkstra
 

reply via email to

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