qiskit-documentation/docs/api/qiskit/0.27/qiskit.optimization.problem...

167 lines
7.5 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: QuadraticConstraint
description: API reference for qiskit.optimization.problems.QuadraticConstraint
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.optimization.problems.QuadraticConstraint
---
# qiskit.optimization.problems.QuadraticConstraint
<Class id="qiskit.optimization.problems.QuadraticConstraint" isDedicatedPage={true} github="https://github.com/qiskit-community/qiskit-aqua/tree/stable/0.9/qiskit/optimization/problems/quadratic_constraint.py" signature="QuadraticConstraint(quadratic_program, name, linear, quadratic, sense, rhs)" modifiers="class">
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\_\_
<Function id="qiskit.optimization.problems.QuadraticConstraint.__init__" signature="__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.
</Function>
## Methods
| | |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| [`__init__`](#qiskit.optimization.problems.QuadraticConstraint.__init__ "qiskit.optimization.problems.QuadraticConstraint.__init__")(quadratic\_program, name, linear, …) | Constructs a quadratic constraint, consisting of a linear and a quadratic term. |
| [`evaluate`](#qiskit.optimization.problems.QuadraticConstraint.evaluate "qiskit.optimization.problems.QuadraticConstraint.evaluate")(x) | Evaluate the left-hand-side of the constraint. |
## Attributes
| | |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| [`linear`](#qiskit.optimization.problems.QuadraticConstraint.linear "qiskit.optimization.problems.QuadraticConstraint.linear") | Returns the linear expression corresponding to the left-hand-side of the constraint. |
| [`name`](#qiskit.optimization.problems.QuadraticConstraint.name "qiskit.optimization.problems.QuadraticConstraint.name") | Returns the name of the constraint. |
| [`quadratic`](#qiskit.optimization.problems.QuadraticConstraint.quadratic "qiskit.optimization.problems.QuadraticConstraint.quadratic") | Returns the quadratic expression corresponding to the left-hand-side of the constraint. |
| [`quadratic_program`](#qiskit.optimization.problems.QuadraticConstraint.quadratic_program "qiskit.optimization.problems.QuadraticConstraint.quadratic_program") | Returns the parent QuadraticProgram. |
| [`rhs`](#qiskit.optimization.problems.QuadraticConstraint.rhs "qiskit.optimization.problems.QuadraticConstraint.rhs") | Returns the right-hand-side of the constraint. |
| [`sense`](#qiskit.optimization.problems.QuadraticConstraint.sense "qiskit.optimization.problems.QuadraticConstraint.sense") | Returns the sense of the constraint. |
### Sense
<Attribute id="qiskit.optimization.problems.QuadraticConstraint.Sense">
alias of `qiskit.optimization.problems.constraint.ConstraintSense`
</Attribute>
### evaluate
<Function id="qiskit.optimization.problems.QuadraticConstraint.evaluate" signature="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.
</Function>
### linear
<Attribute id="qiskit.optimization.problems.QuadraticConstraint.linear">
Returns the linear expression corresponding to the left-hand-side of the constraint.
**Return type**
`LinearExpression`
**Returns**
The left-hand-side linear expression.
</Attribute>
### name
<Attribute id="qiskit.optimization.problems.QuadraticConstraint.name">
Returns the name of the constraint.
**Return type**
`str`
**Returns**
The name of the constraint.
</Attribute>
### quadratic
<Attribute id="qiskit.optimization.problems.QuadraticConstraint.quadratic">
Returns the quadratic expression corresponding to the left-hand-side of the constraint.
**Return type**
`QuadraticExpression`
**Returns**
The left-hand-side quadratic expression.
</Attribute>
### quadratic\_program
<Attribute id="qiskit.optimization.problems.QuadraticConstraint.quadratic_program">
Returns the parent QuadraticProgram.
**Return type**
`Any`
**Returns**
The parent QuadraticProgram.
</Attribute>
### rhs
<Attribute id="qiskit.optimization.problems.QuadraticConstraint.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.QuadraticConstraint.sense">
Returns the sense of the constraint.
**Return type**
`ConstraintSense`
**Returns**
The sense of the constraint.
</Attribute>
</Class>