qiskit_addon_opt_mapper.problems.QuadraticConstraint¶
- class QuadraticConstraint(optimization_problem, name, linear, quadratic, sense, rhs)[source]¶
Bases:
ConstraintRepresentation of a quadratic constraint.
Constructs a quadratic constraint, consisting of a linear and a quadratic term.
- Parameters:
optimization_problem (Any) – The parent optimization problem.
name (str) – The name of the constraint.
linear (ndarray | spmatrix | list[float] | dict[str | int, float]) – The coefficients specifying the linear part of the constraint.
quadratic (ndarray | spmatrix | list[list[float]] | dict[tuple[str | int, str | int], float]) – The coefficients specifying the linear part of the constraint.
sense (ConstraintSense) – The sense of the constraint.
rhs (float) – The right-hand-side of the constraint.
- __init__(optimization_problem, name, linear, quadratic, sense, rhs)[source]¶
Constructs a quadratic constraint, consisting of a linear and a quadratic term.
- Parameters:
optimization_problem (Any) – The parent optimization problem.
name (str) – The name of the constraint.
linear (ndarray | spmatrix | list[float] | dict[str | int, float]) – The coefficients specifying the linear part of the constraint.
quadratic (ndarray | spmatrix | list[list[float]] | dict[tuple[str | int, str | int], float]) – The coefficients specifying the linear part of the constraint.
sense (ConstraintSense) – The sense of the constraint.
rhs (float) – The right-hand-side of the constraint.
- Return type:
None
Methods
__init__(optimization_problem, name, linear, ...)Constructs a quadratic constraint, consisting of a linear and a quadratic term.
evaluate(x)Evaluate the left-hand-side of the constraint.
Attributes
Returns the linear expression corresponding to the left-hand-side of the constraint.
Returns the name of the constraint.
Returns the parent OptimizationProblem.
Returns the quadratic expression corresponding to the left-hand-side of the constraint.
Returns the right-hand-side of the constraint.
Returns the sense of the constraint.
- property linear: LinearExpression¶
Returns the linear expression corresponding to the left-hand-side of the constraint.
- Returns:
The left-hand-side linear expression.
- property optimization_problem: OptimizationProblem¶
Returns the parent OptimizationProblem.
- Returns:
The parent OptimizationProblem.
- property quadratic: QuadraticExpression¶
Returns the quadratic expression corresponding to the left-hand-side of the constraint.
- Returns:
The left-hand-side quadratic expression.
- property rhs: float¶
Returns the right-hand-side of the constraint.
- Returns:
The right-hand-side of the constraint.
- property sense: ConstraintSense¶
Returns the sense of the constraint.
- Returns:
The sense of the constraint.