|
Merging GDX files |
Top Previous Next |
|
GDXMERGE is a utility distributed with GAMS that can be used to combine the information from several GDX files into one composite file and in turn can be used to compare their contents. Symbols with the same name, dimension and type that appear in the separate files are combined into a single symbol with an added dimension in the first index position that gives the file name.
The procedure is uses as follows : gdxmerge filepattern1 filepattern2 .... filepatternn
where the filepattern entries represent are either individual file names or a wildcard representation using ? and *.
The result will be written to a file called merged.gdx.
In the resultant GDX file one cal find all of the data in the source GDX files plus a set named Merged_set_1 that contains the names of all the files processed during the merge operation. In that set the explanatory text contains the date and time of the gdx file processed.
Notes:
Example (gdxmerge.gms):
Suppose we solve the trnsport model from the model library using different LP solvers and wish to compare the runs. To do this After each run, we write all symbols to a gdx file and then use GDXMERGE to merge the solution information. Then suppose we compare the results or the two dimensional trnsport model solution variable X reading the X from the merged GDX file into an array called ALLX that has the file names as its first dimension
$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 bdmlp.gdx cplex.gdx xpress.gdx conopt.gdx minos.gdx snopt.gdx set i supply set j demand set merged_set_1 names of gdx files variable AllX(merged_set_1,i,j); *load i and j from one of the solver gdx files $gdxin bdmlp.gdx $load i $load j *load merged file $gdxin merged.gdx $load merged_set_1 $load AllX=X $gdxin option AllX:5:1:2; display i,j,merged_set_1,AllX.L;
Instead of using the display statement, we can also use the GAMSIDE to view the merged.gdx file by opening it in the editor and looking at X then dragging the indices around into the order wanted.:
|