Try our new documentation site (beta).
Model.addMQConstr()
addMQConstr ( Q, c, sense, rhs, xQ_L=None, xQ_R=None, xc=None, name="" )
Add a quadratic constraint to the model using matrix semantics. The
added constraint is
(except that
the constraint sense is determined by the sense
argument). The
Q
argument must be a NumPy ndarray or a SciPy sparse matrix.
Note that you will typically use overloaded operators to build and
add constraints using matrix semantics. The overloaded @
operator can be used to build a
linear matrix expression
or
quadratic matrix expression.
An overloaded comparison operator can then be used to build a
TempConstr
object, which is then passed to
addConstr.
Arguments:
Q: The quadratic constraint matrix - a NumPy 2-D ndarray or a SciPy sparse matrix.
c: The linear constraint vector - a NumPy 1-D ndarray. This can be None if there are no linear terms.
sense: Constraint sense. Valid values are , , or .
rhs: Right-hand-side value.
xQ_L: Decision variables for quadratic terms; left multiplier for Q. Argument can be an MVar object, a list of Var objects, or None (None uses all variables in the model). The length of the argument must match the size of the first dimension of Q.
xQ_R: Decision variables for quadratic terms; right multiplier for Q. The length of the argument must match the size of the second dimension of Q.
xc: Decision variables for linear terms. Argument can be an MVar object, a list of Var objects, or None (None uses all variables in the model). The length of the argument must match the length of c.
name: Name for new constraint.
Return value:
The QConstr object.
Example usage:
Q = np.full((2, 3), 1) xL = model.addMVar(2) xR = model.addMVar(3) model.addMQConstr(Q, None, '<', 1.0, xL, xR)