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.Constraint

class Constraint(quadratic_program, name, sense, rhs)

GitHub

Abstract Constraint Class.

Initializes the constraint.

Parameters

  • quadratic_program (Any) – The parent QuadraticProgram.
  • name (str) – The name of the constraint.
  • sense (ConstraintSense) – The sense of the constraint.
  • rhs (float) – The right-hand-side of the constraint.

__init__

__init__(quadratic_program, name, sense, rhs)

Initializes the constraint.

Parameters

  • quadratic_program (Any) – The parent QuadraticProgram.
  • name (str) – The name of the constraint.
  • sense (ConstraintSense) – The sense of the constraint.
  • rhs (float) – The right-hand-side of the constraint.

Methods

__init__(quadratic_program, name, sense, rhs)Initializes the constraint.
evaluate(x)Evaluate left-hand-side of constraint for given values of variables.

Attributes

nameReturns the name 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 ConstraintSense

evaluate

abstract evaluate(x)

Evaluate left-hand-side of constraint for given values of variables.

Parameters

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

Return type

float

Returns

The left-hand-side of the constraint.

name

Returns the name of the constraint.

Return type

str

Returns

The name of the constraint.

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.