|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
[AMPL 2589] rankingI 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. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~--- |
|
|
[AMPL 2590] Re: rankingOn 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 -~----------~----~----~----~------~----~------~--~--- |
|
|
[AMPL 2591] Re: rankingThanks, Paul On Jun 12, 12:56 pm, Paul <ru...@...> wrote: > 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 -~----------~----~----~----~------~----~------~--~--- |
| Free embeddable forum powered by Nabble | Forum Help |