« Return to Thread: [AMPL 2589] ranking

[AMPL 2590] Re: ranking

by Paul A. Rubin :: Rate this Message:

Reply to Author | View in Thread




On Jun 12, 3:14 pm, Hans Mittelmann <mittelm...@...> wrote:
> I have a single-index parameter of real numbers of length n and want
> to generate another parameter of integers recording the reverse order
> of the elements in the first parameter,
> so smallest number gets a 1 in the new parameter and largest an n.

Can't swear this is the fastest, but it works assuming that there are
no ties.

param x {1..n};  # original data
param r {1..n} integer ;  # ranks
set X ordered by interval (-Infinity, Infinity);
let X := setof {i in 1..n} x[i];
let {i in 1..n} r[i] := ord(x[i], X);

/Paul
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to ampl@...
To unsubscribe from this group, send email to ampl+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/ampl?hl=en
-~----------~----~----~----~------~----~------~--~---

 « Return to Thread: [AMPL 2589] ranking