CPLEX_SOLUTION_READ
Read Solution Data from CPLEX Result File


CPLEX_SOLUTION_READ, a MATLAB program which extracts solution data from a CPLEX result file; CPLEX can be "fed" by an LP file created by POLYOMINO_MONOHEDRAL_MATRIX or POLYOMINO_MULTIHEDRAL_MATRIX, and the results can be displayed by POLYOMINO_MONOHEDRAL_TILING_PRINT or POLYOMINO_MULTIHEDRAL_TILING_PRINT.

CPLEX is a general integer programming package. We use CPLEX to solve a particular set of undetermined integer equations of the form A*x=b, for which the solution x is required to be binary, that is, to contain only 0 and 1 values.

CPLEX can compute all possible solutions, and returns them packaged in a single XML file, which also contains other information, and substantial formatting text. It is desired to extract the NUM_VAR by NUM_SOL array of solution vectors X, for treatment by MATLAB.

A program called XML2STRUCT is employed to convert XML to a MATLAB structure. Then the necessary solution data is carefully extracted and the array X is reconstructed and output.

Although it is not necesary to know this, the particular integer programming problem being solved is related to a polyomino tiling puzzle. CPLEX is a powerful and accurate tool for solving the related system. To learn more about the problem being solved, you can refer to the simple MATLAB codes for attempting this solution: POLYOMINO_MONOHEDRAL and POLYOMINO_MULTIHEDRAL.

The information stored in the CPLEX file has a number of peculiarities. For one thing, if there are N solutions, and N is more than 1, then, CPLEX displays N+1 solutions, since it wishes to specifically display an "optimal" solution. Thus, when gathering solutions from a CPLEX file, if the number of solutions is greater than 1, then the first solution should be dropped.

In listing a particular solution, depending on the user options, CPLEX might only display the nonzero entries. Since most entries are zero, this keeps the output short; however, this also means that the CPLEX file never actually lists the total number of variables. Thus, we prefer that the user specifically ask CPLEX to story ALL variable values, including zeros. Otherwise, the returned solution information may be confusingly shortened because trailing zeros may be omitted.

Apparently, during the solution process, CPLEX reindexes the variables. The output listing of the variables include the user's original index (or label, actually, such as "x20"), and the CPLEX index. Thus, we have to ignore the CPLEX index, read the string "x20", drop the "x" and convert the remainder from string to number.

Licensing:

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

Related Programs and Data:

cplex_solution_read_test

GUROBI_SOLUTION_READ, a MATLAB program which reads a file created by the optimization package GUROBI, representing the solution of a polyomino tiling problem, and writes out a simple ASCII file that can be read by load().

SCIP_SOLUTION_READ, a MATLAB program which reads a file created by the integer programming package SCIP, representing the solution of a polyomino tiling problem, and writes out a simple ASCII file that can be read by load().

Reference:

  1. IBM ILOG CPLEX Optimization Studio,
    Getting Started with CPLEX.
  2. IBM ILOG CPLEX Optimization Studio,
    CPLEX User's Manual.

Source Code:


Last revised on 13 December 2018.