Many scientific computing platforms provide a linear programming solver. For example, there is a linprog
function in MATLAB, Scipy, and DolphinDB. And linprog
in all those three platforms provides a parameter for inequality constraints, namely A
, and two parameters for bounded variables, namely lb
and ub
.
If a linear programming problem has bounded variables, I could place them in the inequality constraints, A
, by adding a row containing only one 1
or -1
with the remaining elements being 0
, or alternatively I could simply place them in lb
and/or ub
.
Is there any difference between those two ways? Or is there any reason that I should favor A
over lb
/ub
, or vice versa?
Bounds are a little bit more efficient than explicit constraints. Basically, in a Simplex solver, a bound does not increase the size of the basis matrix. This basis matrix needs to be solved and inverted (factorized).
Advanced solvers have a presolver that will convert singleton constraints into bounds. In that case there is no real performance penalty. For those solvers it is mostly a question of taste how to specify bound constraints: as a bound or as a singleton constraint.