How-to

Comparing two generated math programs

  • 31 January 2022
  • 0 replies
  • 167 views
Comparing two generated math programs
Userlevel 5
Badge +4

If you have two versions of an AIMMS project in which you solve a math program then it can sometimes happen that you get two different solutions (after running) while you expected that both versions would return the same solution. Assuming that you are using the same solver (and version), and the solver does not hit a time limit, this usually means that the math programs generated by AIMMS are different. One approach to find these differences is described below.

First create the constraint listings for both project versions by setting the following Solvers General options:

  • 'Constraint Listing' to 'At every solve' (or 'At first solve')
  • 'Constraint Listing Variable Values' to 'Print variable values'

By setting the second option AIMMS will not only print the level values of all variables in the generated math program, but also their upper and lower bounds.

The constraint listing will be printed at the end of the solve (by default) but you can also generate it at the beginning of the solve by setting the following Solvers General option:

  • 'Constraint Listing Printed When' to 'Before solve'

This might save you some time if you are not interested in the solution at this point.

The constraint listing will be printed in the listing file (.lis) in the log folder of the AIMMS project.

Another useful option is the option ‘Listing number precision’ which specifies the number of decimals used for printing numbers in the constraint listing. The default is 3.

Once you have printed both constraint listings you can compare the two listing files using a tool like WinMerge, which works fine if the listing files are not very large and if there are not too many differences. However, I recommend using a special, somewhat hidden, tool that is part of the AIMMS Developer installation which is named CompLis (Windows only). This tool can handle very large files (5 GB or bigger), it is quite fast and it represents differences in a special way because of the typical format of the constraint listings.

The CompLis tool can be found in the Bin folder of an AIMMS Developer installation (and its help file can be found in the Help folder). I have attached a zip file with the latest version of the executable (plus help file).

To use it, you should copy the file ‘complis.exe’ to a folder containing the two listing files. To run the program, open a Command Prompt and type in

complis f1.lis f2.lis

to compare the constraint listings in the files f1.lis and f2.lis. The output will be written to the file complis.log. If the listing files contain multiple constraint listings (because you are solving multiple math programs in your AIMMS project) then the tool will compare the n-th constraint listing in the first file with the n-th constraint listing in the second file.

(Note that you can open a command prompt from the File Explorer Address Bar by typing in ‘cmd’ and pressing enter.)

By default the tool will ignore ordering differences of the variables and constraints. That is, if in the first file some constraint is printed as last and in the second file as first, then this will not be regarded as a difference.

CompLis comes with several options to influence its behavior. If you just run

complis

then a list with all available options will be shown. The most important options are:

  • o: Report ordering differences for constraints and variables
  • b: Compare also the lower and upper bounds of the variables
  • l: Compare also the level values of the variables
  • n: Compare also nonlinear coefficients
  • p<i>: Precision used for printing numbers (default: 2)
  • x: Print output to html file (with colors) instead of text file

The latest version also supports this option:

  • f<i,j>: Compare only constraint listing i from the first file with constraint listing j from the second file (you can also use f<i> if i=j)

An example:

complis f1.lis f2.lis -blp5

Now the bounds and level values of the variables will be compared, and numbers will be printed using a precision of 5. (Note that it does not make much sense to use a precision value that is higher than the value of the option ‘Listing number precision’ used in the AIMMS projects.)


0 replies

Be the first to reply!

Reply


Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator