bundles / scipy latest / scipy / optimize / _constraints / LinearConstraint
class
scipy.optimize._constraints:LinearConstraint
source: build-install/usr/lib/python3.14/site-packages/scipy/optimize/_constraints.py:143
Signature
class LinearConstraint(A, lb = -inf, ub = inf, keep_feasible = False)Members
Summary
Linear constraint on the variables.
Extended Summary
The constraint has the general inequality form
lb <= A.dot(x) <= ubHere the vector of independent variables x is passed as ndarray of shape (n,) and the matrix A has shape (m, n).
It is possible to use equal bounds to represent an equality constraint or infinite bounds to represent a one-sided constraint.
Parameters
A: {array_like, sparse array}, shape (m, n)Matrix defining the constraint.
lb, ub: dense array_like, optionalLower and upper limits on the constraint. Each array must have the shape (m,) or be a scalar, in the latter case a bound will be the same for all components of the constraint. Use
np.infwith an appropriate sign to specify a one-sided constraint. Set components oflbandubequal to represent an equality constraint. Note that you can mix constraints of different types: interval, one-sided or equality, by setting different components oflbandubas necessary. Defaults tolb = -np.infandub = np.inf(no limits).keep_feasible: dense array_like of bool, optionalWhether to keep the constraint components feasible throughout iterations. A single value sets this property for all components. Default is False. Has no effect for equality constraints. Note that finite difference approximation of the Jacobian may still violate the constraint; it is recommended to provide an analytical Jacobian function to handle this case.
Notes
Whilst LinearConstraint can be used to specify constraints for many different optimizers, the class is not responsible for enforcing those constraints, that is done by the individual minimizer. Importantly, the keep_feasible keyword is only ever used within the trust-constr optimizer, the keep_feasible keyword is not used by other minimize methods. The other methods may, or may not, keep solutions strictly feasible during operation.
Aliases
scipy.optimize.LinearConstraint