GDXRANK

A GAMS utility for ranking one-dimensional numeric data.

Developed by Thomas F. Rutherford, Department of Economics, University of Colorado

This utility consists of an executable file, gdxrank.exe which resides in the GAMS system directory.

Attention
GDXRANK is deprecated (see GAMS 36 GDXRank, GDXRename release notes). Please use $libInclude gdxservice GDXRank instead.

Usage

GDXRANK reads one or more one dimensional parameters from a GDX file, sorts each parameter and writes the sorted indices as a one dimensional parameters to the output GDX file.

Usage:

gdxrank inputfile outputfile

Each one dimensional parameter is read from the input file, sorted and the corresponding integer permutation index written to the output file using the same name for the symbol. GAMS special values such as Eps, +Inf and -Inf are recognized.

GDXRANK Example

In this example we sort a parameter, create a sorted version and verify that the sort worked correctly:

Set I / i1*i6 /;

Parameter A(I) / i1 +Inf, i2 -Inf, i3 Eps, i4 10, i5 30, i6 20 /;

display A;

* write symbol A to gdx file
execute_unload "rank_in.gdx", A;

* sort symbol; permutation index will be named A also
execute 'gdxrank rank_in.gdx rank_out.gdx';

* load the permutation index
Parameter AIndex(i);

execute_load "rank_out.gdx", AIndex=A;

display AIndex;

* create a sorted version
Parameter ASorted(i);
ASorted(i + (AIndex(i) - ord(i))) = A(i);
display ASorted;

* check that the result is sorted
Set C(i);
C(i)=yes$(ord(i) < card(i)) and (ASorted(i) > ASorted(i+1));

display C;

abort$(card(C) <> 0) 'sort failed';