Identifying differences in contents with Gdxdiff

Top  Previous  Next

GAMS also distributes a utility that looks for differences in two GDX files creating a list of item names that differ and yet another GDX file that exactly specifies the differences.

GDXDIFF compares the data of for items in two GDX files and writes a GDX file showing the differences.  In particular for all items with the same name, type and dimension in the two GDX files the differences in numerical values are written to a third GDX file with A summary report written to standard output (ordinarily the LOG file).

This utility is used by using $Call or Execute with the line

 gdxdiff file1 file2 {diffile} {Eps = value} {RelEps = value} {Field = FieldName} {ID=Identifier}

GDXDIFF requires the first two file name parameters,

 File1                        Name of the first GDX file

 File2                        Name of the second GDX file

The remaining parameters are optional

Diffile

An optional third file name that is the name of the GDX file that contains the differences found in the parameters. If that parameter, is absent the file will be named 'diffile.gdx' and placed in the current directory.

Eps = value

A tolerance that is the maximum amount that two numbers may differ by ie given a1 and a2 then abs(a1-a2) is reported as different if it exceeds this tolerance

RelEps = value

A tolerance that is the maximum percentage amount that two numbers may differ by ie given a1 and a2 then abs(a1-a2)/max(abs(a1),abs(a2)) is reported as different if it exceeds this tolerance.  Note this is more complex as discussed in the gdxutilities document under help and tools.

Field = FieldName

A field that if specified limits doen between the information for variables and equations to specific attributes (Lo, L, Up, M, Scale and Prior)

ID=Identifier

Limits the comparisons to selected items; items not specified will be ignored. Multiple items can be specified as: ID=id1 ID=id2 or ID="id1 id2"

 

More is found on this in the GAMS utilities document at gdxutils.pdf or as found through the IDE help under docs and tools named gdxutils.chm or gdxutils.pdf.

Example:

Suppose we wish to compare the GDX files tran and tran2, then we would use the command

 

Gdxdiff tran tran2

 

In turn the output to standard output (nominally the terminal screen) appears as follows

 

Summary of differences:

     d   Data is different

   dem   Keys are different

   sup   Keys are different

supply   Symbol not found in file 1

     x   Symbol not found in file 1

 

and summarizes the differences found.  Simultaneously the file diffile.gdx when examined in the IDE contains the following

 

_img70        

 

which reports on the differences found in the two files.

Notes:

Some new coding is introduced in the difference GDX file.  Namely a new dimension is added to the parameters being compared which can contain 4 entries
dif1 indicates that the entry occurs in both files and shows the value found in the first file.
dif2 indicates that the entry occurs in both files and shows the value found in the second file.
ins1 indicates that the entry only occurs in the first files and shows the value found.
ins2 indicates that the entry only occurs in the second file and shows the value found.
Only named items with the same name, type and dimension will be compared in the diffile.gdx output.  Named items that are new or are deleted will only appear in the standard output summary report