Accessing slack variables and solution values
Documents the conventions that CPLEX observes with respect to slack variables and solution values.
In most use cases, you can regard the values of slack variables returned by solution routines in CPLEX as the righthand side (RHS) of the corresponding constraint minus the value of the linear (or quadratic) expression in the lefthand side (LHS), regardless of the sense of the constraint.
Ranged rows with finite lower and upper bounds have slack values consisting of the value of the linear expression minus the lower bound.
The slack variable values adhere to those conventions regardless of the application programming interface (API) in use.
CPXXgetpi
as reduced costs on slack variables depends on the internal representation
inside CPLEX of those slacks. In that context, CPLEX follows these conventions:
- For less-than-or-equal-to (≤) constraints, CPLEX adds a nonnegative slack.
- For equality (==) constraints, CPLEX adds an artificial variable with lower and upper bounds of 0 (zero).
- For greater-than-or-equal-to (≥) constraints, CPLEX subtracts a nonnegative surplus value.
The artificial variable associated with an equality constraint takes on a value of 0 (zero) in the case of a feasible basis solution.
Thus, for greater-than-or-equal-to (≥) constraints, the reduced cost on the slack is simply the associated dual variable value, whereas for all other constraints, the reduced cost on the slack is the negative of the dual value.
Formally, CPLEX transforms the problem to standard form, like this:
min c'x, such that Ax + Es = b, l ≤ x ≤ u, 0 ≤ s ≤ r
| sense | E_i | r_i |
|---|---|---|
| == | e_i | 0 (zero) |
| ≤ | e_i | infinity |
| ≥ | -e_i | infinity |
| range | -e_i | absolute value of range |
This practice of CPLEX adding slack or artificial variables depending on the sense of a constraint
is also relevant to users of the Callable Library (C API) advanced linear programming routines
to access parts of the so-called simplex tableau. First of all, slacks are handled implicitly
and are not part of the constraint matrix of structural variables passed to CPLEX via routines such as
CPXXcopylp,
CPXXaddrows, or
CPXXaddcols.
Therefore, advanced routines, such as
CPXXbinvarow or
CPXXbinvacol,
generate simplex row and column tableau information only for structural variables. To access
the tableau row elements associated with the slack variables, you must first call
CPXXbinvrow
to obtain the associated row of the basis inverse; then you must negate the
elements associated with the ≥ constraints. Likewise, to access the tableau columns
for slack variables, you must first call
CPXXbinvcol
for the appropriate slack variable; then you must negate those tableau column elements
if the slack corresponds to a ≥ constraint.