[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fwd: Re: [Help-glpk] Mathprog question
From: |
glpk xypron |
Subject: |
Fwd: Re: [Help-glpk] Mathprog question |
Date: |
Sat, 12 Dec 2009 22:33:12 +0100 |
Hello Andrew,
currently in GMPL there is no way to retrieve an element of a
symbolic set by a logical condition. In the example below
I am able to sort the values x{I}, but I am unable to
output the indices sorted by the values.
One way to add such a functionality would be functions
Max{ domain } tuple
Min{ domain } tuple
Then I could write
param a, symbolic := Max{ i in I : x[i] = 3 } i;
to retrieve a special element of a set.
Or the following restricition could be removed:
"implementation restriction; in/within setof{} not allowed".
Best regards
Xypron
-------- Original-Nachricht --------
Datum: Sat, 12 Dec 2009 12:57:22 -0800 (PST)
Von: xypron
An: address@hidden
Betreff: Re: [Help-glpk] Mathprog question
Hello Jeffrey,
see example below. Unfortunately sorted output requires O(n^3) time.
Best regards
Xypron
set I;
param a{I} := Uniform01();
var x{I};
s.t. c{i in I}:
a[i] = x[i];
solve;
printf "unsorted\n";
for{i in I}
printf "%10s: %f\n", i, x[i];
printf "decreasing order\n";
for{i in (0..(card(I)-1))}
{
printf "%d: %f\n", i+1, sum{j in I :
i == sum{ k in I :
x[j]<x[k] || ( x[j]==x[k] && j < k )} 1 } x[j];
}
printf "increasing order\n";
for{i in (0..(card(I)-1))}
{
printf "%d: %f\n", i+1, sum{j in I :
i == sum{ k in I :
x[k]<x[j] || ( x[k]==x[j] && k < j )} 1 } x[j];
}
data;
set I := ape bear crocodile elefant lion snake tiger zebra;
end;
Jeffrey Kantor wrote:
>
> Hi all --
>
> I'm struggling to come up with a way to print a list ordered by the value
> of
> a solved variable. I have
>
> var start{TASKS};
> ....
> solve;
>
> and now I'd like to print the tasks ordered by the value of the start
> variables. Perhaps I'm just not thinking
> clearly, but is there a simple way to do this?
>
> Jeff
--
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01