GAMS [ Home | Downloads | Documentation | Solvers | APIs | Tools | Model Libraries | Resources | Sales | Support | Contact Us | Search ]

GDXDIFF

Table of Contents

The gdxdiff program compares the data of symbols with the same name, type and dimension in two GDX files and writes the differences to a third GDX file. A summary report will be written to standard output.

Usage

gdxdiff file1 file2 {diffile} {Options}

diffile

An optional name of the GDX difference file; see below

Options

Eps = value

Absolute difference for comparisons; see below.

RelEps = value

Relative difference for comparisons; see below.

Field = FieldName

The specified field is the only field used for deciding if a variable or equation is different. FieldName is one of the following: L, M, Up, Lo, Prior, Scale or All.

ID = Identifier

Limits the comparisons to one or more symbols; symbols not specified will be ignored. Multiple identifiers can be specified as: ID=id1 ID=id2 or as ID="id1 id2"

FldOnly

Used in combination with the Field option; all variables and equations will be written as parameters using the value of the field specified. This option cannot be used in combination with DiffOnly.

DiffOnly

Differences for Variables and Equations will be written as parameters; each parameter will have an additional index which is used to store the field name. Only fields that are different will be written. This option cannot be used in combination with FldOnly.

GDXDIFF requires two parameters, the file names of two GDX files. An optional third parameter is the name of the GDX difference file. Without the third parameter, the difference file will be 'diffile.gdx' in the current directory.

The use of Eps and RelEps is best described by the code fragment below.

AbsDiff := Abs(V1 - V2);
if  AbsDiff <= EpsAbsolute
then
  Result := true
else
  if EpsRelative > 0.0
  then
     Result := AbsDiff / (1.0 + DMin(Abs(V1), Abs(V2))) <= EpsRelative
  else
     Result := false;

Only symbols with the same name, type and dimension will be compared. Tuples with different values are written to the GDX difference file, and a dimension is added to describe the difference using the following labels:

  • ins1 indicates that the tuple only occurs in the first file.
  • ins2 indicates that the tuple only occurs in the second file.
  • dif1 indicates that the tuple occurs in both files; contains the value from the first file.
  • dif2 indicates that the tuple occurs in both files; contains the value from the second file.

Example

In the following example, the trnsport model is solved twice with different capacity data. GDX files are saved for each run, and compared using gdxdiff. The shipments variable is loaded into a new variable used for a display statement. We introduce four new unique elements that are used in the difference file.

solve transport using lp minimizing z ;

execute_unload 'case1.gdx',a,x;
a('seattle') = 1.2 * a('seattle');
solve transport using lp minimizing z ;
execute_unload 'case2.gdx',a,x;

execute 'gdxdiff.exe case1 case2 diffile';

set difftags /dif1,dif2,ins1,ins2/;
variable xdif(i,j,difftags);
execute_load 'diffile' xdif=x;
display xdif.L;