This is a pre-release version (latest).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy latest / scipy / optimize / _linprog_util / _clean_inputs

function

scipy.optimize._linprog_util:_clean_inputs

source: build-install/usr/lib/python3.14/site-packages/scipy/optimize/_linprog_util.py:213

Signature

def _clean_inputs(lp)

Summary

Given user inputs for a linear programming problem, return the objective vector, upper bound constraints, equality constraints, and simple bounds in a preferred format.

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_ub specifies the coefficients of a linear inequality constraint on x.

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_eq specifies the coefficients of a linear equality constraint on x.

b_eq

The equality constraint vector. Each element of A_eq @ x must equal the corresponding element of b_eq.

bounds

The bounds of x, as min and max pairs. If bounds are specified for all N variables separately, valid formats are: * a 2D array (2 x N or N x 2); * a sequence of N sequences, each with 2 values. If all variables have the same bounds, a single pair of values can be specified. Valid formats are: * a sequence with 2 scalar values; * a sequence with a single element containing 2 scalar values. If all variables have a lower bound of 0 and no upper bound, the bounds parameter can be omitted (or given as None).

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 x0 represents a basic feasible 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_ub specifies the coefficients of a linear inequality constraint on x.

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_eq specifies the coefficients of a linear equality constraint on x.

b_eq

The equality constraint vector. Each element of A_eq @ x must equal the corresponding element of b_eq.

bounds

The bounds of x, as min and max pairs, one for each of the N elements of x. 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 x0 represents a basic feasible solution.

Aliases

  • scipy.optimize._linprog_util._clean_inputs