SOL file format: solution files

The SOL file format supports solution files.

CPLEX reads and writes solution files, formatted in XML, for all problem types, for all application programming interfaces (APIs). These solution files, known as SOL files, carry the file extension .sol. The XML solution file format makes it possible for you to display and view these solution files in most browsers as well as to pass the solution to XML-aware applications. CPLEX also provides a stylesheet and schema in yourCplexinstallation/include/ilcplex to facilitate your use of this format in your applications.

  • solution.xsl stylesheet

  • solution.xsd schema

Note:

Browsers may have specific conventions regarding accessing remote style sheets and XML files with extensions other than .xml. For example, your browser may not read the header of an SOL file with the extension .sol or may not consult the stylesheet designated there; consequently, your browser may display such a file as raw XML code, rather than the formatted display you expect. In such a situation, try copying your SOL file to a file with the extension .xml that your browser recognizes and processes correctly.

By default, the encoding of SOL file format is UTF-8.

CPLEX can also read SOL files as an advanced start. SOL files contain basis statuses, if they are available, and solution values. The basis statuses can be used for advanced starts with simplex optimizers; the solution values can be used for a crossover from a barrier solution or as a MIP start from a mixed integer solution. A mixed integer solution may be from a conventional MIP optimization or from a member of the solution pool.

SOL files contain XML formatted information, as do MST files. Unlike MST files, at the default write level of detail, SOL files contain solution values for all variables rather than only the variables that define the integer feasible solution. SOL files are thus larger, take longer to input, and (in unusual cases of numerically difficult models) are less likely to provide a feasible starting point. Consequently, it is generally a good practice to use MST files to restart the optimization instead of SOL files. However, if you already use SOL files for other purposes, you can also use them to provide a feasible starting point.

SOL files also carry an optional name attribute, useful when the problem has names. SOL files also include an index, corresponding to the constraint index or variable index of the problem.

The SOL header gives information about the status of the solution. For example, the optimization status appears as a string and the numeric value of the CPLEX symbolic constant.

The SOL quality gives information about the quality of the solution. For example, the maximum primal infeasibility, the values of the tolerance parameters in effect during the optimization, and other quality information appears in this part.

There are, of course, methods and routines for reading and writing SOL files.

  • In Concert Technology, use these methods:

    • In the C++ API, see the methods IloCplex::readSolution and IloCplex::writeSolution.

    • In the Java API, see the methods IloCplex.readSolution and IloCplex.writeSolution.

    • In the .NET API, see the methods Cplex.ReadSolution and Cplex.WriteSolution.

  • In the Callable Library, use the routine CPXreadcopysol to read a SOL file and the routine CPXsolwrite to write SOL files.

Here is an example of a SOL file.


<?xml version = "1.0" standalone="yes"?>
<?xml-stylesheet href="https://www.ilog.com/products/cplex/xmlv1.0/solution.xsl" type="text/xsl"?>
<CPLEXSolution version="1.2">
 <header
   problemName="../../../examples/data/mexample.mps"
   solutionName="incumbent"
   solutionIndex="-1"
   objectiveValue="-122.5"
   solutionTypeValue="3"
   solutionTypeString="primal"
   solutionStatusValue="101"
   solutionStatusString="integer optimal solution"
   solutionMethodString="mip"
   primalFeasible="1"
   dualFeasible="1"
   MIPNodes="0"
   MIPIterations="3"/>
 <quality
   epInt="1e-05"
   epRHS="1e-06"
   maxIntInfeas="0"
   maxPrimalInfeas="0"
   maxX="40"
   maxSlack="2"/>
 <linearConstraints>
  <constraint name="c1" index="0" slack="0"/>
  <constraint name="c2" index="1" slack="2"/>
  <constraint name="c3" index="2" slack="0"/>
 </linearConstraints>
 <variables>
  <variable name="x1" index="0" value="40"/>
  <variable name="x2" index="1" value="10.5"/>
  <variable name="x3" index="2" value="19.5"/>
  <variable name="x4" index="3" value="3"/>
 </variables>
</CPLEXSolution>
Tip: When you create an SOL file, it is a good idea to validate your file with respect to the stylesheet and schema in an XML-aware validator. This safety practice verifies that all required parts of such a file are present and syntactically correct.