135 lines
4.9 KiB
Plaintext
135 lines
4.9 KiB
Plaintext
---
|
||
title: Constraint
|
||
description: API reference for qiskit.optimization.problems.Constraint
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: class
|
||
python_api_name: qiskit.optimization.problems.Constraint
|
||
---
|
||
|
||
<span id="qiskit-optimization-problems-constraint" />
|
||
|
||
# qiskit.optimization.problems.Constraint
|
||
|
||
<Class id="qiskit.optimization.problems.Constraint" isDedicatedPage={true} github="https://github.com/qiskit-community/qiskit-aqua/tree/stable/0.8/qiskit/optimization/problems/constraint.py" signature="Constraint(quadratic_program, name, sense, rhs)" modifiers="class">
|
||
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\_\_
|
||
|
||
<Function id="qiskit.optimization.problems.Constraint.__init__" signature="__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.
|
||
</Function>
|
||
|
||
## Methods
|
||
|
||
| | |
|
||
| -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
|
||
| [`__init__`](#qiskit.optimization.problems.Constraint.__init__ "qiskit.optimization.problems.Constraint.__init__")(quadratic\_program, name, sense, rhs) | Initializes the constraint. |
|
||
| [`evaluate`](#qiskit.optimization.problems.Constraint.evaluate "qiskit.optimization.problems.Constraint.evaluate")(x) | Evaluate left-hand-side of constraint for given values of variables. |
|
||
|
||
## Attributes
|
||
|
||
| | |
|
||
| --------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------- |
|
||
| [`name`](#qiskit.optimization.problems.Constraint.name "qiskit.optimization.problems.Constraint.name") | Returns the name of the constraint. |
|
||
| [`quadratic_program`](#qiskit.optimization.problems.Constraint.quadratic_program "qiskit.optimization.problems.Constraint.quadratic_program") | Returns the parent QuadraticProgram. |
|
||
| [`rhs`](#qiskit.optimization.problems.Constraint.rhs "qiskit.optimization.problems.Constraint.rhs") | Returns the right-hand-side of the constraint. |
|
||
| [`sense`](#qiskit.optimization.problems.Constraint.sense "qiskit.optimization.problems.Constraint.sense") | Returns the sense of the constraint. |
|
||
|
||
### Sense
|
||
|
||
<Attribute id="qiskit.optimization.problems.Constraint.Sense">
|
||
alias of `ConstraintSense`
|
||
</Attribute>
|
||
|
||
### evaluate
|
||
|
||
<Function id="qiskit.optimization.problems.Constraint.evaluate" signature="evaluate(x)" modifiers="abstract">
|
||
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.
|
||
</Function>
|
||
|
||
### name
|
||
|
||
<Attribute id="qiskit.optimization.problems.Constraint.name">
|
||
Returns the name of the constraint.
|
||
|
||
**Return type**
|
||
|
||
`str`
|
||
|
||
**Returns**
|
||
|
||
The name of the constraint.
|
||
</Attribute>
|
||
|
||
### quadratic\_program
|
||
|
||
<Attribute id="qiskit.optimization.problems.Constraint.quadratic_program">
|
||
Returns the parent QuadraticProgram.
|
||
|
||
**Return type**
|
||
|
||
`Any`
|
||
|
||
**Returns**
|
||
|
||
The parent QuadraticProgram.
|
||
</Attribute>
|
||
|
||
### rhs
|
||
|
||
<Attribute id="qiskit.optimization.problems.Constraint.rhs">
|
||
Returns the right-hand-side of the constraint.
|
||
|
||
**Return type**
|
||
|
||
`float`
|
||
|
||
**Returns**
|
||
|
||
The right-hand-side of the constraint.
|
||
</Attribute>
|
||
|
||
### sense
|
||
|
||
<Attribute id="qiskit.optimization.problems.Constraint.sense">
|
||
Returns the sense of the constraint.
|
||
|
||
**Return type**
|
||
|
||
`ConstraintSense`
|
||
|
||
**Returns**
|
||
|
||
The sense of the constraint.
|
||
</Attribute>
|
||
</Class>
|
||
|