[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) |
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.