[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] New set functions
From: |
glpk xypron |
Subject: |
Re: [Help-glpk] New set functions |
Date: |
Thu, 03 Nov 2011 07:32:44 +0100 |
Hello Nilo,
there is no expression in GMPL, which will return a single
element of a symbolic set. For a numeric set there is a
solution:
set A := {1..4};
param x{A};
solve;
printf "%s\n",
(if card({a in A : x[a] = 1}) = 0 then '*' else
min{a in A: x[a] == 1} a );
data;
param x :=
1 0
2 1
3 0
4 1;
end;
Best regards
Xypron
-------- Original-Nachricht --------
> Datum: Wed, 2 Nov 2011 19:34:33 -0200
> Von: Nilo Cesar Teixeira <address@hidden>
> An: address@hidden
> Betreff: [Help-glpk] New set functions
> Hi all,
>
> In my previous question (regarding printf and if), I thought about this
> expression which is invalid in current version of MathProg:
>
> printf "%30s", (if card({name in I : H[name] = 1}) = 0 then '*' else
> XXXX);
>
> My point is, I would like XXXX to be an expression which returns ONE
> element of a set. In this case, the value of 'name' for which H[name] = 1.
> *
> *
> I thought about these 2 functions which could be useful:
>
> 1. first({name in I : H[name] = 1}), would return value of name; last()
> would be good too;
> 2. member {name in I : H[name] = 1} (i), would return the ith member of
> set.
>
> So, member {name in I : H[name] = 1} (1) would return value of name too;
>
> To really be effective, this should work with unsubscripted sets to, like
> set I := A NO THER MEM BER;
>
> Suppose H[A] = 1, so the above functions return A.
>
> What do you think ? Thank you.
>
> --
> *Nilo Cesar Teixeira*
> address@hidden
--
Follow me at http://twitter.com/#!/xypron
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de