Skip to main contentIBM Quantum Documentation
This page is from an old version of Qiskit SDK and does not exist in the latest version. We recommend you migrate to the latest version. See the release notes for more information.

qiskit.optimization.problems.QuadraticConstraint

class QuadraticConstraint(quadratic_program, name, linear, quadratic, sense, rhs)

GitHub

Representation of a quadratic constraint.

Constructs a quadratic constraint, consisting of a linear and a quadratic term.

Parameters

  • quadratic_program (Any) – The parent quadratic program.
  • name (str) – The name of the constraint.
  • linear (Union[ndarray, spmatrix, List[float], Dict[Union[int, str], float]]) – The coefficients specifying the linear part of the constraint.
  • quadratic (Union[ndarray, spmatrix, List[List[float]], Dict[Tuple[Union[int, str], Union[int, str]], 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__

__init__(quadratic_program, name, linear, quadratic, sense, rhs)

Constructs a quadratic constraint, consisting of a linear and a quadratic term.

Parameters

  • quadratic_program (Any) – The parent quadratic program.
  • name (str) – The name of the constraint.
  • linear (Union[ndarray, spmatrix, List[float], Dict[Union[int, str], float]]) – The coefficients specifying the linear part of the constraint.
  • quadratic (Union[ndarray, spmatrix, List[List[float]], Dict[Tuple[Union[int, str], Union[int, str]], 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.

Methods

__init__(quadratic_program, 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

linearReturns the linear expression corresponding to the left-hand-side of the constraint.
nameReturns the name of the constraint.
quadraticReturns the quadratic expression corresponding to the left-hand-side of the constraint.
quadratic_programReturns the parent QuadraticProgram.
rhsReturns the right-hand-side of the constraint.
senseReturns the sense of the constraint.

Sense

alias of qiskit.optimization.problems.constraint.ConstraintSense

evaluate

evaluate(x)

Evaluate the left-hand-side of the constraint.

Parameters

x (Union[ndarray, List, Dict[Union[int, str], float]]) – The values of the variables to be evaluated.

Return type

float

Returns

The left-hand-side of the constraint given the variable values.

linear

Returns the linear expression corresponding to the left-hand-side of the constraint.

Return type

LinearExpression

Returns

The left-hand-side linear expression.

name

Returns the name of the constraint.

Return type

str

Returns

The name of the constraint.

quadratic

Returns the quadratic expression corresponding to the left-hand-side of the constraint.

Return type

QuadraticExpression

Returns

The left-hand-side quadratic expression.

quadratic_program

Returns the parent QuadraticProgram.

Return type

Any

Returns

The parent QuadraticProgram.

rhs

Returns the right-hand-side of the constraint.

Return type

float

Returns

The right-hand-side of the constraint.

sense

Returns the sense of the constraint.

Return type

ConstraintSense

Returns

The sense of the constraint.

Was this page helpful?
Report a bug or request content on GitHub.