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

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