Using the Interactive Optimizer for debugging
Describes Interactive Optimizer more fully as debugger.
The CPLEX Interactive Optimizer distributed with the Component Libraries offers a way to see what is going on within the CPLEX part of your application when you observe peculiar behavior in your optimization application. The commands of the Interactive Optimizer correspond exactly to routines of the Component Libraries, so anomalies due to the CPLEX-part of your application will manifest themselves in the Interactive Optimizer as well, and contrariwise, if the Interactive Optimizer behaves appropriately on your problem, you can be reasonably sure that routines you call in your application from the Component Libraries work in the same appropriate way.
With respect to parameter settings, you can write a parameter file
with the file extension .prm from your application
by means of one of these methods:
-
IloCplex::writeParamin the C++ API -
IloCplex.writeParamin the Java API -
Cplex.WriteParamin the .NET API -
CPXwriteparamin the Callable Library -
writefile.prmin the Interactive Optimizer
The Interactive Optimizer can read a .prm file
and then set parameters exactly as they are in your application.
In the other direction, you can use the display command
in the Interactive Optimizer to show the nondefault parameter settings;
you can then save those settings in a .prm file for
re-use later. See the topic Saving a parameter specification file in
the reference manual of the Interactive Optimizer for more detail
about using a parameter file in this way.
To use the Interactive Optimizer for debugging, you first need
to write a version of the problem from the application into a formatted
file that can then be loaded into the Interactive Optimizer. To do
so, insert a call to the method exportModel or to the
routine
CPXwriteprob
into
your application. Use that call to create a file, whether an LP, SAV,
or MPS formatted problem file. (Understanding file formats briefly
describes these file formats.) Then read that file into the Interactive
Optimizer and optimize the problem there.
Note that MPS, LP and SAV files have differences that influence how to interpret the results of the Interactive Optimizer for debugging. SAV files contain the exact binary representation of the problem as it appears in your program, while MPS and LP files are text files containing possibly less precision for numeric data. And, unless every variable appears on the objective function, CPLEX will probably order the variables differently when it reads the problem from an LP file than from an MPS or SAV file. With this in mind, SAV files are the most useful for debugging using the Interactive Optimizer, followed by MPS files, then finally LP files, in terms of the change in behavior you might see by use of explicit files. On the other hand, LP files are often quite helpful when you want to examine the problem, more so than as input for the Interactive Optimizer. Furthermore, try solving both the SAV and MPS files of the same problem using the Interactive Optimizer. Different results may provide additional insight into the source of the difficulty. In particular, use the following guidelines with respect to reproducing your program’s behavior in the Interactive Optimizer.
-
If you can reproduce the behavior with a SAV file, but not with an MPS file, this suggests corruption or errors in the problem data arrays. Use the
DataCheckparameter or diagnostic routines in the source filecheck.cto track down the problem. -
If you can reproduce the behavior in neither the SAV file nor the MPS file, the most likely cause of the problem is that your program has some sort of memory error. Memory debugging tools such as Purify will usually find such problems quickly.
-
When solving a problem in MPS or LP format, if the Interactive Optimizer issues a message about a segmentation fault or similar ungraceful interruption and exits, contact CPLEX customer support to arrange for transferring the problem file. The Interactive Optimizer should never exit with a system interrupt when solving a problem from a text file, even if the program that created the file has errors. Such cases are extremely rare.
If the peculiar behavior that you observed in your application persists in the Interactive Optimizer, then you must examine the LP or MPS or SAV problem file to discover whether the problem file actually defines the problem you intended. If it does not define the problem you intended to optimize, then the problem is being passed incorrectly from your application to CPLEX, so you need to look at that part of your application.
Make sure the problem statistics and matrix coefficients indicated
by the Interactive Optimizer match the ones for the intended model
in your application. Use the Interactive Optimizer command display problem stats to
verify that the size of the problem, the sense of the constraints,
and the types of variables match your expectations. For example, if
your model is supposed to contain only general integer variables,
but the Interactive Optimizer indicates the presence of binary variables,
check the type variable passed to the constructor of the variable
(Concert Technology) or check the specification of the ctype array
and the routine
CPXcopyctype
(Callable
Library). You can also examine the matrix, objective, and righthand
side coefficients in an LP or MPS file to see if they are consistent
with the values you expect in the model.