GDXMERGE

Table of Contents

The program gdxmerge combines multiple GDX files into one file. Symbols with the same name, dimension and type are combined into a single symbol of a higher dimension. The added dimension has the file name of the combined file as its unique element.

Usage

gdxmerge filepattern1 filepattern2 .... filepatternN [Optional parameters]

Optional parameters:

id=<ident1>, <ident2>...

only merge the symbols ident1, ident2, ...

exclude=<ident1>, <ident2>...

merge all symbols except ident1, ident2

big=<integer>

the size for big symbols

output = fileid

output file name

Each file pattern represents a file name or a wildcard representation using ? and *. A parameter of the form @filename, will process the commands from the text file specified.

The result of the merge will be written to a file called merged.gdx unless overwritten by the output parameter.

All symbols with matching type and dimension will be merged. By specifying the parameter ID=ident1 the merge process will only be performed for the identifier(s) specified. EXCLUDE=ident1 indicates that all symbols should be merged except for the ones specified in the EXCLUDE list. Note that the two options ID and `EXCLUDE' are mutually exclusive.

By default, the program reads all gdx once and stores all data in memory before writing the merged.gdxfile. The big parameter is used to specify a cutoff for symbols that will be written one at a time. Each symbol that exceeds the size will be processed by reading each gdx file and only process the data for that symbol. This can lead to reading the same gdx file many times, but it allows the merging of large data sets. The formula used to calculate the cutoff is:

Dimension * TotalNumberOfElements.

The calculated value is doubled for variables and equations.

In addition to the symbols written, a set is added to the gdx file representing all the files processed during the merge operation. The name of the set is Merged_set_1, and is made unique by changing the number. The explanatory text for each set element contains the date and time of the gdx file processed.

Note
  • The file 'merged.gdx', or the file specified with the output parameter, will never be used in a merge operation even if the name matches a file pattern.
  • Symbols with dimension 20 cannot be merged, because the resulting symbol will have dimension 21 which exceeds the maximum dimension allowed by GAMS.

Example

In this example, we solve the trnsport model using different LP solvers. After each run, we write all symbols to a gdx file and merge the files into one file. The variable X is read from the merged file and displayed.

$call gamslib trnsport
$call gams trnsport lp=bdmlp gdx=bdmlp
$call gams trnsport lp=cplex gdx=cplex
$call gams trnsport lp=xpress gdx=xpress
$call gams trnsport lp=conopt gdx=conopt
$call gams trnsport lp=minos gdx=minos
$call gams trnsport lp=snopt gdx=snopt
$call gdxmerge *.gdx
variable AllX(*,*,*);
$gdxin merged.gdx
$load AllX=X
$gdxin
option AllX:5:1:2;
display AllX.L;

Instead of using the display statement, we can also use the GAMSIDE to view the merged.gdx file. After selecting the level field to be displayed and arranging the display:

gdxmerge1.gif