QuadraticProgram.quadratic_constraint¶
- QuadraticProgram.quadratic_constraint(linear=None, quadratic=None, sense='<=', rhs=0.0, name=None)[source]¶
- Adds a quadratic equality constraint to the quadratic program of the form:
(x * quadratic * x + linear * x) sense rhs
.
- Parameters:
linear (
Union
[ndarray
,spmatrix
,List
[float
],Dict
[Union
[int
,str
],float
],None
]) – The linear coefficients of the constraint.quadratic (
Union
[ndarray
,spmatrix
,List
[List
[float
]],Dict
[Tuple
[Union
[int
,str
],Union
[int
,str
]],float
],None
]) – The quadratic coefficients of the constraint.sense (
Union
[str
,ConstraintSense
]) –The sense of the constraint,
==
,=
,E
, andEQ
denote ‘equal to’.>=
,>
,G
, andGE
denote ‘greater-than-or-equal-to’.<=
,<
,L
, andLE
denote ‘less-than-or-equal-to’.
rhs (
float
) – The right-hand side of the constraint.name (
Optional
[str
]) – The name of the constraint. If it’sNone
or empty""
, the default name, e.g.,q0
, is used.
- Return type:
- Returns:
The added constraint.
- Raises:
QiskitOptimizationError – if the constraint name already exists.