GLPK/Solution information

This page explains how to recover and interpret solution information from GLPK. The information presented here should be relevant to both modelers using GLPSOL and programmers using the callable library APIs.

You must have made an attempt to solve your problem before the material on this page will apply &mdash; but the GLPK solution process need not have produced a usable answer. Answer or no, there are many reasons for seeking extra information about the solution process and/or solution.

Run-time reporting
GLPK will normally print information during the solution process &mdash; the details of which can be found on the terminal output page.

Failure to solve to optimality
There are several reasons (software faults aside) as to why GLPK may fail to reach an optimal solution:


 * the problem is empty and the solver returns
 * the solver proves that the problem is unbounded and returns
 * the solver proves that the problem is nonfeasible and returns
 * the solver is unable to find a starting feasible solution within the allocated time or available memory
 * the solver is unable to find an optimal solution within the allocated time or available memory
 * the solver encounters numerical instability problems

Not all of these conditions are relevant to each of the { simplex, interior-point } &times; { LP, MIP } combinations, but this outline does give an indication of the kind of issues that can arise. The troubleshooting page offers some suggestions and fixes. Numerical instability warnings, in particular, may result from poor scaling. If you encounter a really puzzling problem and think it a bug in GLPK, please report the issue so it can be addressed.

If programming with GLPK, bear in mind that the solver, paradoxically perhaps, need not have found a solution to return success &mdash; it only needs to have completed its assigned tasks satisfactorily.

Solution recovery
Assuming that GLPK provides an optimal solution, there are several methods for recovering the solution information using both standard calls and tailored methods. Some techniques may also accept and process non-optimal feasible solutions.

The MathProg language allows for tight control over the output of solution information. The language now supports suffixes for constraints and variables (but not parameters) &mdash; a feature that can be useful when seeking, for example, dual values. The section on close-to-zero rounding shows how to use a MathProg conditional to output true zeros instead of very small numbers.

GLPSOL offers the options --output and --write for obtaining solution information in human readable and machine parsible formats, respectively. Both may be used in the one command:

glpsol ... --output file.out --write file.wri

These two output formats are presented on the interoperability page. Terminal output can also be duplicated to a text file with the GLPSOL command-line option --log file.log. Conversely, the special filename /dev/stdout can be used to write "files" to the terminal instead of to a regular file. And both tactics can be used together.

The output produced by glp_print_sol is similar to that used by the IBM MPS/360 linear programming package, but altered a little, because GLPK uses auxiliary rather than slack/surplus variables.

The various GLPK API calls that can be used to recover information are listed below. Elsewhere, the relevant function names are given to aid cross-referencing back to the GLPK API manual, where comprehensive technical descriptions can usually be found.

Sensitivity analysis report
A problem solved to optimality with the simplex solver can be further subject to a sensitivity analysis. This feature is not available to solutions generated by the interior-point solver or for mixed-integer problems. The glp_print_ranges API call produces a sensitivity report in human readable format.

The GLPSOL --ranges option also produces this report (or issues a suitable warning if its use is inappropriate):

glpsol ... --ranges file.sen

The output produced by glp_print_ranges is identical to that used by the IBM MPS/360 linear programming package (see Murtagh 1981).

The description here is intentionally brief &mdash; details can be found in the official GLPK API manual, including an explanation of break points and objective coefficient sensitivities. The two following tables can be used to read a sensitivity analysis report.

Abbreviations: RHS means right-hand side. Inf means infinity.

The official documentation (GLPK 4.45) explains that analysis of a row is the analysis of its auxiliary variable, which is equal to the row linear form $$\sum a_j x_j$$. And the analysis of a column is the analysis of its corresponding structural variable. Formally, there is no innate difference between rows and columns when performing a sensitivity analysis.

Karush-Kuhn-Tucker optimality conditions
For pure linear programs (excluding mixed-integer programs), the Karush-Kuhn-Tucker optimality conditions are necessary and sufficient for the given solution to be a global optimum (assuming that some regularity conditions are also met). These KKT conditions are listed here as they apply to GLPK. Numerical solvers also use these KKT conditions to estimate the accuracy of their floating point calculations upon completion. GLPK can provide on request, a human readable report giving, among other things, the KKT conditions for any solution obtained using either the simplex or interior-point solvers.

KKT calculation
GLPK provides the <tt>lpx_check_kkt</tt> routine to calculate and interpret the KKT optimality conditions for the current basic solution. This call fills a C struct <tt>LPXKKT</tt> instance, from which specific information can be recovered. Its use is documented in the official GLPK API manual and the call itself is also described in this wikibook.

KKT report
The GLPK <tt>glp_print_sol</tt> and <tt>glp_print_ipt</tt> calls print a report which contains both the solution and the KKT optimality conditions for that solution. The GLPSOL <tt>--output</tt> option also displays the same information for pure LP (non-MIP) problems (usage is not restricted).

glpsol ... --output file.out

The KKT conditions are most often used to estimate the effects of inaccurate floating point arithmetic on the quality of the reported solution (assuming that exact arithmetic has not been deployed). The description given here is intentionally brief &mdash; consult the official GLPK API manual for details. There are four reported tests, labeled <tt>KKT.PE</tt> thru <tt>KKT.DB</tt>. A typical report is shown &mdash; which is clean in this case!

KKT.PE: max.abs.err = 0.00e+00 on row 0 max.rel.err = 0.00e+00 on row 0 High quality

KKT.PB: max.abs.err = 0.00e+00 on row 0 max.rel.err = 0.00e+00 on row 0 High quality

KKT.DE: max.abs.err = 0.00e+00 on column 0 max.rel.err = 0.00e+00 on column 0 High quality

KKT.DB: max.abs.err = 0.00e+00 on row 0 max.rel.err = 0.00e+00 on row 0 High quality

The following three tables can be used to read a KKT report. The mathematical expressions given in the first table are described in detail here.

The char column above refers to the character values contained int the GLPK <tt>LPXKKT</tt> C-struct.

Interpretation
For a given problem, with scaling if operative, the GLPK 4.45 API manual states that "if all the indicators show high or medium quality &hellip; the user can be sure that the obtained basic solution is quite accurate."

Integer feasibility report
The first two KKT conditions <tt>KKT.PE</tt> and <tt>KKT.PB</tt> can also be calculated for the solution to a mixed-integer program and used to investigate the numerical accuracy of the resulting solution. These two tests alone do not guarantee optimality, but the solver will know if the branch-and-bound tree has been exhausted or not. See the preceding section for details.

The GLPK <tt>glp_print_mip</tt> call prints a report which contains both the solution and the integer feasibility conditions for that solution The GLPSOL <tt>--output</tt> option can be used to display this information for MIP problems (usage is not restricted).

glpsol ... --output file.out

Note too the GLPSOL option <tt>--nomip</tt> which allows an MIP problem to be solved as a pure LP by removing the integer restrictions.

Informational APIs
The following functions can be used to collect information directly (and should be used in preference to regexing text files):

The following functions should produce human readable reports:

Adaptive use
Several innovative projects use GLPK solution information in an adaptive context. Results from one run are used to generate the next model, and so on, until some predetermined condition is reached.

Note: more details needed.