[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] pick element from set?
From: |
glpk xypron |
Subject: |
Re: [Help-glpk] pick element from set? |
Date: |
Mon, 02 Jul 2012 07:42:56 +0200 |
Hello Kevin,
there is no function that will return an element of a set (except for
one-dimensional numeric sets).
You can create subsets.
e.g.
set X, dimen 2 := {(5, 7), (1, 10), (23, -3), ("y", "x"), ("a", "abc")};
set S := setof{(i,j) in X : forall{(k,l) in X} i <=k && j <= l} (i,j);
see
http://en.wikibooks.org/wiki/GLPK/GMPL_Workarounds#Sorted_output
Best regards
Xypron
-------- Original-Nachricht --------
> Datum: Sun, 01 Jul 2012 03:11:00 -0400
> Betreff: [Help-glpk] pick element from set?
> Hello GLPK List,
>
> Is there a method to pick an arbitrary single item from a set? I don't
> care which one, but I need to have a single element from a set such that
> I can uniquely and consistently identify it.
>
> There is no order to the set, but /if/ there were an ordering to this
> set, I might reference this element as "nought". Put differently, say I
> have a set X:
>
> set X, dimen 2 := {(5, 7), (1, 10), (23, -3), ("y", "x"), ("a", "abc")};
>
> Is there functionality -- say a function called "pick()" -- to pick an
> arbitrary element from that set?
>
> Put another way, /if/ I could put that set into a list:
>
> list(X) == [(5, 7), (1, 10), (23, -3), ("y", "x"), ("a", "abc")]
>
> then I could get an arbitrary element, perhaps like 'get(list(X), 0)'.
>
> Is there a method to grab a single element from the set?
>
> I'll point out that I have an ad-hoc method of this for a
> single-dimensional set (using a nested setof structure and a comparison
> operator), but can't do it for any higher-dimensionality sets.
>
> Thanks,
>
> Kevin
>
> _______________________________________________
> Help-glpk mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/help-glpk