9.2. Solution-related Files¶
After using MindOpt to solve, the obtained optimal solution or feasible solution can be output to a file.
File Type |
Model Type |
Description |
|---|---|---|
BAS |
LP |
Basis status of variables and constraints |
SOL |
LP & MIP |
Solution of variables |
MST |
MIP |
Solution of discontinuous variables |
9.2.1. BAS File¶
After successfully solving a linear programming problem, the basis status of each variable in the primal problem and each variable in the dual problem can be written to a file using the bas file format. A bas file can also be read before solving a linear programming problem to initialize a basis status for the solver.
A bas file contains multiple lines. The first line records the model name
NAME : foo
The first line starts with a keyword NAME, followed by : and a space, with the rest of the line recording the model name.
The next lines record the basis status of dual problem variables, i.e., RowBasis, with each line corresponding to one variable in the dual problem. For example:
FR R0
As can be seen, this line contains a status code FR and a constraint name R0, indicating that the dual variable corresponding to constraint R0 has a basis status of “free”.
The correspondence of basis status codes is shown in the following table:
Code |
Status Meaning |
|---|---|
FR |
isFree |
BS |
basic |
UU |
atUpperBound |
UL |
atLowerBound |
SB |
superBasic |
EQ |
isFixed |
UK |
unknown |
The following multiple lines record the basis status of primal problem variables, i.e., ColBasis, with each line corresponding to one variable. For example:
BS C0
This indicates that variable C0 is a basic variable.
Note
Lines recording basis status should start with a space, i.e., indented by 1 space.
Finally, the bas file ends with an unindented ENDATA.
ENDATA
9.2.2. SOL File¶
After successfully solving with MindOpt, the solutions of the primal and dual problems can be output to a sol file. A sol file contains three parts of information:
Model information, including name, objective function values of primal and dual problems, etc.
Variable solutions
Dual variable solutions
First is the model information, for example:
NAME : foo
PRIMAL OBJECTIVE : -4.88569887318817E+00
DUAL OBJECTIVE : -4.88569887318827E+00
PROBLEM STATUS : OPTIMAL
Contains four lines, each with two fields separated by :. They represent respectively:
Model name
Primal problem objective function value
Dual problem objective function value
Solution status
Next is a blank line, followed by multiple lines of variable solutions (i.e., X):
VARIABLES
C0 +4.76048966504162E-01
C1 +8.73391945822582E-01
C2 +0.00000000000000E+00
C3 +3.36918727744315E-01
C4 +8.96258337238064E-01
C5 +6.36894231964933E-01
C6 +8.62158935460491E-01
Variable solutions start with “VARIABLES” on a separate line. The first field of each line is the variable name, and the second field is the variable’s solution.
Next is another blank line, followed by multiple lines of dual variable solutions (i.e., DualSoln):
CONSTRAINTS
c0 -1.32829351698292E-01
c1 -4.53378851617045E-01
c2 +1.07104207431984E-01
c3 +6.87509566168726E-01
c4 +6.09393433447014E-03
c5 -2.88026626252556E-01
c6 +1.56943391710642E+00
Dual variable solutions start with “CONSTRAINTS” on a separate line. The first field of each line is the constraint name, and the second field is the solution of the dual variable corresponding to that constraint.
9.2.3. MST File¶
MST files are designed to implement warm starts for MIP problems. After solving a mixed integer programming problem, we can output the current integer variable solutions to a file to use as initial solutions for another problem.
Since mixed integer programming is typically much slower than linear programming, determining solutions for integer variables is more difficult than for continuous variables. To reduce file size, mst files only record solutions for integer variables. Moreover, providing solutions for all integer variables is not mandatory, as the solver will attempt to infer the missing values.
mst files are designed to be easy to edit and modify manually, with a very simple format. They contain multiple lines, each recording the solution of one integer variable, such as:
# Solutions
c0 0
c1 1
c2 0
This records the solutions for three integer variables c0, c1, and c2. Any line starting with # will be treated as a comment and ignored.
However, reading an initial solution from a file for warm start before solving a problem does not necessarily take effect. In any case, the solver will only treat this initial solution as a reference.
Reading an mst file containing some variables is equivalent to setting Start for these variables.