[Top][All Lists]

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

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

From: xypron
Subject: Re: [Help-glpk] First element of the set
Date: Thu, 22 Oct 2009 10:05:32 -0700 (PDT)


>> 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
See example below.

Best regards


# 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
set S := the quick brown fox jumps over a lazy dog;

View this message in context:
Sent from the Gnu - GLPK - Help mailing list archive at

reply via email to

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