| 1 | # [Feasibility and optimality](@id kkt) |
| 2 | |
| 3 | Mathematically, continuous optimization problems have exact feasibility |
| 4 | and optimality conditions. However, since solvers cannot always |
| 5 | satisfy these conditions exactly when using floating-point arithmetic, |
| 6 | they do so to within tolerances. As explored below, some solvers aim |
| 7 | to satisfy those tolerances absolutely, and others aim to satisfy |
| 8 | tolerances relative to problem data. When tolerances are satisfied |
| 9 | relatively, they are generally not satisfied absolutely. The use of |
| 10 | tolerances relative to problem data is not consistent across solvers, |
| 11 | and can give a misleading claim of optimality. To achieve consistency, |
| 12 | HiGHS reassesses the optimal solution claimed by such a solver in a |
| 13 | reasonable and uniform manner. |
| 14 | |
| 15 | ### Feasibility and optimality conditions |
| 16 | |
| 17 | To discuss tolerances and their use in different solvers, consider the |
| 18 | standard form linear programming (LP) problem with ``n`` variables and |
| 19 | ``m`` equations (``n\ge m``). |
| 20 | |
| 21 | ```math |
| 22 | \begin{aligned} |
| 23 | \textrm{minimize} \quad & c^T\! x \\ |
| 24 | \textrm{subject to} \quad & Ax = b \\ |
| 25 | & x \ge 0, |
| 26 | \end{aligned} |
| 27 | ``` |
| 28 | |
| 29 | The feasibility and optimality conditions (KKT conditions) are that, at |
| 30 | a point ``x``, there exist (row) dual values ``y`` and reduced costs |
| 31 | (column dual values) ``s`` such that |
| 32 | |
| 33 | ```math |
| 34 | \begin{aligned} |
| 35 | Ax=b&\qquad\textrm{Primal~equations}\\ |
| 36 | A^Ty+s=c&\qquad\textrm{Dual~equations}\\ |
| 37 | x\ge0&\qquad\textrm{Primal~feasibility}\\ |
| 38 | s\ge0&\qquad\textrm{Dual~feasibility}\\ |
| 39 | c^Tx-b^Ty=0&\qquad\textrm{Optimality} |
| 40 | \end{aligned} |
| 41 | ``` |
| 42 | |
| 43 | The optimality condition is equivalent to the complementarity |
| 44 | condition that ``x^Ts=0``. Since any LP problem can be transformed |
| 45 | into standard form, the following discussion loses no generality. This |
| 46 | discussion also largely applies to quadratic programming (QP) |
| 47 | problems, with the differences explored below. |
| 48 | |
| 49 | ### The HiGHS feasibility and optimality tolerances |
| 50 | |
| 51 | HiGHS has separate tolerances for the following, listed with convenient mathematical notation |
| 52 | |
| 53 | - [Primal feasibility](@ref option-primal-feasibility-tolerance) (``\epsilon_P``) |
| 54 | - [Dual feasibility](@ref option-dual-feasibility-tolerance) (``\epsilon_D``) |
| 55 | - Residual errors in the [primal equations](@ref option-primal-residual-tolerance) (``\epsilon_R``) |
| 56 | - Residual errors in the [dual equations](@ref option-dual-residual-tolerance) (``\epsilon_C``) |
| 57 | - [Optimality](@ref option-optimality-tolerance) (``\epsilon_{O}``) |
| 58 | |
| 59 | All are set to the same default value of ``10^{-7}``. Although each |
| 60 | can be set to different values by the user, if the user wishes to |
| 61 | solve LPs to a general lower or higher tolerance, the value of the |
| 62 | [KKT tolerance](@ref option-kkt-tolerance) can be changed from this |
| 63 | default value. |
| 64 | |
| 65 | ### When HiGHS yields an optimal solution |
| 66 | |
| 67 | When HiGHS returns a model status of optimal, the solution will |
| 68 | satisfy feasibility and optimality tolerances absolutely or relatively |
| 69 | according to whether the solver yields a basic solution. |
| 70 | |
| 71 | ### Solutions with a corresponding basis |
| 72 | |
| 73 | The HiGHS simplex solvers and the interior point solver after |
| 74 | crossover yield an optimal basic solution of the LP, consisting of |
| 75 | ``m`` basic variables and ``n-m`` nonbasic variables. At any basis, |
| 76 | the nonbasic variables are zero, and values for the basic variables |
| 77 | are given by solving a linear system of equations. Values for the row |
| 78 | dual values (``y``) can be computed by solving a linear system of equations, |
| 79 | and the column dual values are then given by ``s=c-A^Ty``. With exact |
| 80 | arithmetic, the basic dual values are zero by construction. |
| 81 | |
| 82 | When primal and dual values are computed using floating-point |
| 83 | arithmetic, the basic dual values are set to zero so the optimality |
| 84 | condition holds by construction. However, the primal and dual |
| 85 | equations may not be satisfied exactly, so have nonzero |
| 86 | residuals. Fortunately, when solving a linear system of equations |
| 87 | using a stable technique, any residuals are small relative to the RHS |
| 88 | of the equations, whatever the condition of the matrix of |
| 89 | coefficients. Hence HiGHS does not assess the primal residuals, or the |
| 90 | dual residuals for basic variables. Thus optimality for a basic |
| 91 | solution is assessed by HiGHS according to whether the following |
| 92 | conditions hold |
| 93 | |
| 94 | ```math |
| 95 | \begin{aligned} |
| 96 | x_i\ge-\epsilon_P&\qquad\forall i=1,\ldots,n\\ |
| 97 | s_i\ge-\epsilon_D&\qquad\forall i=1,\ldots,n. |
| 98 | \end{aligned} |
| 99 | ``` |
| 100 | |
| 101 | The HiGHS active set QP solver has an objective function ``(1/2)x^TQx + c^Tx``, |
| 102 | and maintains the QP equivalent of a basis in which a subset |
| 103 | of (up to ``n``) variables are zero. However, there are variables |
| 104 | that are off their bounds whose reduced costs are not zero by |
| 105 | construction. At an optimal solution they will only be less than a |
| 106 | dual feasibility tolerance in magnitude, so the optimality condition |
| 107 | will not be satisfied by construction. The primal and dual equations |
| 108 | (where the latter is ``A^Ty+s=Qx+c``) will be satisfied with small |
| 109 | residuals. Optimality is assessed by HiGHS according to whether primal |
| 110 | and dual feasibility is satisfied to within the corresponding |
| 111 | tolerance. |
| 112 | |
| 113 | |
| 114 | ### Solutions without a corresponding basis |
| 115 | |
| 116 | The HiGHS PDLP solver and the interior point solvers (HiPO and IPX) |
| 117 | without crossover yield "optimal" primal and dual values that satisfy |
| 118 | internal conditions for termination of the underlying algorithm. These |
| 119 | conditions are discussed below, and are used for good reason. However, |
| 120 | particularly in the case of PDLP, they can lead to a misleading claim |
| 121 | of optimality. |
| 122 | |
| 123 | #### Interior point solutions |
| 124 | |
| 125 | The interior point algorithm uses a single feasibility tolerance |
| 126 | ``\epsilon=\min(\epsilon_P, \epsilon_D)``, and an independent |
| 127 | [optimality tolerance](@ref option-ipm-optimality-tolerance) |
| 128 | (``\epsilon_{IPM}``) that, by default, is (currently) ten times |
| 129 | smaller than the other feasibility and optimality tolerances used by |
| 130 | HiGHS. It terminates when |
| 131 | |
| 132 | ```math |
| 133 | \begin{aligned} |
| 134 | \|Ax-b\|_\infty&\le(1+\|b\|_\infty)\epsilon_R\\ |
| 135 | \|c-A^Ty+s\|_\infty&\le(1+\|c\|_\infty)\epsilon_C\\ |
| 136 | -x_i&\le\epsilon\qquad\forall i=1,\ldots,n\\ |
| 137 | -s_i&\le \epsilon\qquad\forall i=1,\ldots,n\\ |
| 138 | |c^Tx-b^Ty|&\le(1+|c^Tx+b^Ty|/2)\epsilon_{IPM}. |
| 139 | \end{aligned} |
| 140 | ``` |
| 141 | |
| 142 | In practice, the feasibility tolerances are readily satisfied when |
| 143 | using interior point solvers. Hence their termination generally |
| 144 | depends on satisfying the optimality tolerance, with relative |
| 145 | feasibility satisfied to a higher tolerance than required. Thus the |
| 146 | solution obtained using interior point solvers typically has small |
| 147 | absolute feasibility errors. |
| 148 | |
| 149 | #### PDLP solutions |
| 150 | |
| 151 | The PDLP algorithm uses an independent [optimality tolerance](@ref |
| 152 | option-pdlp-optimality-tolerance) (``\epsilon_{PDLP}``) that is equal |
| 153 | to the other feasibility and optimality tolerances used by HiGHS. It |
| 154 | determines values of ``x\ge0`` and ``y``, and chooses ``s`` to be the |
| 155 | non-negative values of ``c-A^Ty``. Hence it guarantees primal and dual |
| 156 | feasibility by construction. It terminates when |
| 157 | |
| 158 | ```math |
| 159 | \begin{aligned} |
| 160 | \|Ax-b\|_2&\le (1+\|b\|_2)\epsilon_P\\ |
| 161 | \|c-A^Ty-s\|_2&\le (1+\|c\|_2)\epsilon_D\\ |
| 162 | |c^Tx-b^Ty|&\le (1+|c^Tx|+|b^Ty|)\epsilon_{PDLP}. |
| 163 | \end{aligned} |
| 164 | ``` |
| 165 | |
| 166 | Unlike interior point solvers, PDLP does not readily satisfy the |
| 167 | relative feasibility tolerances. Although they and the optimality |
| 168 | tolerance are satisfied on successful termination, the solution |
| 169 | obtained may have meaningful absolute feasibility errors. |
| 170 | |
| 171 | #### HiGHS solutions |
| 172 | |
| 173 | The relative measures used by HiPO, IPX and PDLP assume that all |
| 174 | components of the cost and RHS vectors are relevant. When an LP |
| 175 | problem is in standard form this is true for ``b``, but not |
| 176 | necessarily for the cost vector ``c``. Consider a large component of |
| 177 | ``c`` for which the corresponding reduced cost value in ``s`` is also |
| 178 | large, in which case the LP solution is insensitive to the cost. This |
| 179 | component will contribute significantly to ``\|c\|`` and, hence, the |
| 180 | RHS of the dual residual condition, allowing large values of |
| 181 | ``\|c-A^Ty-s\|`` to be accepted. However, this can lead to |
| 182 | unacceptably large absolute residual errors and non-optimal solutions |
| 183 | being deemed "optimal". When equations in ``Ax=b`` correspond to |
| 184 | inequality constraints with large RHS values and a slack variable (so |
| 185 | the constraint is redundant) the same issue occurs in the case of |
| 186 | primal residual errors. The solution of the LP is not sensitive to |
| 187 | this large RHS value, but its contribution to ``||b||`` can allow |
| 188 | large absolute primal residual errors to be overlooked. |
| 189 | |
| 190 | To make an informed assessment of whether an "optimal" solution |
| 191 | obtained by HiPO, IPX or PDLP is acceptable, HiGHS computes infinity norm |
| 192 | measures of ``b`` and ``c`` corresponding to the components that |
| 193 | define the optimal solution. For ``c`` these are the components |
| 194 | corresponding to positive values of ``x`` and reduced costs that are |
| 195 | close to zero. For ``b``, these are the components corresponding to |
| 196 | constraints that are (close to being) satisfied exactly. The resulting |
| 197 | measures are smaller than ``\|b\|`` or ``\|c\|``, and may lead to |
| 198 | relative measures of primal/dual residual errors or infeasibilities |
| 199 | not being satisfied, so the status of the solver's "optimal" solution |
| 200 | may be reduced to "unknown". When this happens - and possibly if |
| 201 | tolerances on relative measures _have_ been satisfied - users can |
| 202 | consult the absolute and relative measures available via |
| 203 | [HighsInfo](@ref info-num-primal-infeasibilities). |
| 204 | |
| 205 | ### Discrete optimization problems |
| 206 | |
| 207 | Discrete optimization problems, such as the mixed-integer programming |
| 208 | (MIP) problems solved by HiGHS, have no local optimality |
| 209 | conditions. Variables required to take integer values will do so to |
| 210 | within the `mip_feasibility_tolerance`. Since MIP sub-problems are |
| 211 | solved with the simplex solver, the values of the variables and |
| 212 | constraints will satisfy absolute feasibility tolerances. Within the |
| 213 | MIP solver, the value of `mip_feasibility_tolerance` is used for |
| 214 | `primal_feasibility_tolerance` when solving LP sub-problems, and one |
| 215 | tenth of this value is used for `dual_feasibility_tolerance`. Hence |
| 216 | any value of `primal_feasibility_tolerance` (or |
| 217 | `dual_feasibility_tolerance`) set by the user has no effect of the MIP |
| 218 | solver. |
| 219 |