bundles / scipy latest / scipy / optimize / _linprog_util / _presolve
function
scipy.optimize._linprog_util:_presolve
source: build-install/usr/lib/python3.14/site-packages/scipy/optimize/_linprog_util.py:477
Signature
def _presolve(lp, rr, rr_method, tol = 1e-09)Summary
Given inputs for a linear programming problem in preferred format, presolve the problem: identify trivial infeasibilities, redundancies, and unboundedness, tighten bounds where possible, and eliminate fixed variables.
Parameters
lp: A `scipy.optimize._linprog_util._LPProblem` consisting of the following fields:c
The coefficients of the linear objective function to be minimized.
A_ub
The inequality constraint matrix. Each row of
A_ubspecifies the coefficients of a linear inequality constraint onx.b_ub
The inequality constraint vector. Each element represents an upper bound on the corresponding value of
A_ub @ x.A_eq
The equality constraint matrix. Each row of
A_eqspecifies the coefficients of a linear equality constraint onx.b_eq
The equality constraint vector. Each element of
A_eq @ xmust equal the corresponding element ofb_eq.bounds
The bounds of
x, asminandmaxpairs, one for each of the N elements ofx. The N x 2 array contains lower bounds in the first column and upper bounds in the 2nd. Unbounded variables have lower bound -np.inf and/or upper bound np.inf.x0
Guess values of the decision variables, which will be refined by the optimization algorithm. This argument is currently used only by the 'revised simplex' method, and can only be used if
x0represents a basic feasible solution.
rr: boolIf
Trueattempts to eliminate any redundant rows inA_eq. Set False ifA_eqis known to be of full row rank, or if you are looking for a potential speedup (at the expense of reliability).rr_method: strMethod used to identify and remove redundant rows from the equality constraint matrix after presolve.
tol: floatThe tolerance which determines when a solution is "close enough" to zero in Phase 1 to be considered a basic feasible solution or close enough to positive to serve as an optimal solution.
Returns
lp: A `scipy.optimize._linprog_util._LPProblem` consisting of the following fields:c
The coefficients of the linear objective function to be minimized.
A_ub
The inequality constraint matrix. Each row of
A_ubspecifies the coefficients of a linear inequality constraint onx.b_ub
The inequality constraint vector. Each element represents an upper bound on the corresponding value of
A_ub @ x.A_eq
The equality constraint matrix. Each row of
A_eqspecifies the coefficients of a linear equality constraint onx.b_eq
The equality constraint vector. Each element of
A_eq @ xmust equal the corresponding element ofb_eq.bounds
The bounds of
x, asminandmaxpairs, possibly tightened.x0
Guess values of the decision variables, which will be refined by the optimization algorithm. This argument is currently used only by the 'revised simplex' method, and can only be used if
x0represents a basic feasible solution.
c0: 1D arrayConstant term in objective function due to fixed (and eliminated) variables.
x: 1D arraySolution vector (when the solution is trivial and can be determined in presolve)
: revstack: list of functionsthe functions in the list reverse the operations of _presolve() the function signature is x_org = f(x_mod), where x_mod is the result of a presolve step and x_org the value at the start of the step (currently, the revstack contains only one function)
: complete: boolWhether the solution is complete (solved or determined to be infeasible or unbounded in presolve)
status: intAn integer representing the exit status of the optimization
0 : Optimization terminated successfully 1 : Iteration limit reached 2 : Problem appears to be infeasible 3 : Problem appears to be unbounded 4 : Serious numerical difficulties encountered
message: strA string descriptor of the exit status of the optimization.
Aliases
scipy.optimize._linprog._presolve