{ } Raw JSON

bundles / scipy latest / scipy / optimize / _linprog_util / _LPProblem

class

scipy.optimize._linprog_util:_LPProblem

source: /scipy/optimize/_linprog_util.py

Signature

class   _LPProblem ( c A_ub = None b_ub = None A_eq = None b_eq = None bounds = None x0 = None integrality = None )

Summary

Represents a linear-programming problem.

Attributes

c : 1D array

The coefficients of the linear objective function to be minimized.

A_ub : 2D array, optional

The inequality constraint matrix. Each row of A_ub specifies the coefficients of a linear inequality constraint on x.

b_ub : 1D array, optional

The inequality constraint vector. Each element represents an upper bound on the corresponding value of A_ub @ x.

A_eq : 2D array, optional

The equality constraint matrix. Each row of A_eq specifies the coefficients of a linear equality constraint on x.

b_eq : 1D array, optional

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

bounds : various valid formats, optional

The bounds of x, as min and max pairs. If bounds are specified for all N variables separately, valid formats are: * a 2D array (N x 2); * a sequence of N sequences, each with 2 values. If all variables have the same bounds, the bounds can be specified as a 1-D or 2-D array or sequence with 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). Absent lower and/or upper bounds can be specified as -numpy.inf (no lower bound), numpy.inf (no upper bound) or None (both).

x0 : 1D array, optional

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.

integrality : 1-D array or int, optional

Indicates the type of integrality constraint on each decision variable.

0Continuous variable; no integrality constraint.

1Integer variable; decision variable must be an integer within bounds.

2Semi-continuous variable; decision variable must be within bounds or take value 0.

3Semi-integer variable; decision variable must be an integer within bounds or take value 0.

By default, all variables are continuous.

For mixed integrality constraints, supply an array of shape c.shape. To infer a constraint on each decision variable from shorter inputs, the argument will be broadcast to c.shape using np.broadcast_to.

This argument is currently used only by the 'highs' method and ignored otherwise.

Notes

This namedtuple supports 2 ways of initialization: >>> lp1 = _LPProblem(c=[-1, 4], A_ub=[[-3, 1], [1, 2]], b_ub=[6, 4]) >>> lp2 = _LPProblem([-1, 4], [[-3, 1], [1, 2]], [6, 4])

Note that only c is a required argument here, whereas all other arguments A_ub, b_ub, A_eq, b_eq, bounds, x0 are optional with default values of None. For example, A_eq and b_eq can be set without A_ub or b_ub: >>> lp3 = _LPProblem(c=[-1, 4], A_eq=[[2, 1]], b_eq=[10])

Aliases

  • scipy.optimize._linprog._LPProblem