This is a pre-release version (2.0.0.dev0+git20260907.41eeb59).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy 2.0.0.dev0+git20260907.41eeb59 / scipy / optimize / _linprog_util / _parse_linprog

function

scipy.optimize._linprog_util:_parse_linprog

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

Signature

def _parse_linprog(lp, options, meth)

Summary

Parse the provided linear programming problem

Extended Summary

_parse_linprog employs two main steps _check_sparse_inputs and _clean_inputs. _check_sparse_inputs checks for sparsity in the provided constraints (A_ub and ``A_eq) and if these match the provided sparsity optional values.

_clean inputs checks of the provided inputs. If no violations are identified the objective vector, upper bound constraints, equality constraints, and simple bounds are returned in the expected 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.

options : dict

A dictionary of solver options. All methods accept the following generic options:

maxiter

Maximum number of iterations to perform.

disp

Set to True to print convergence messages.

For method-specific options, see show_options('linprog').

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.

options : dict, optional

A dictionary of solver options. All methods accept the following generic options:

maxiter

Maximum number of iterations to perform.

disp

Set to True to print convergence messages.

For method-specific options, see show_options('linprog').

Aliases

  • scipy.optimize._linprog._parse_linprog