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

106 lines
2.4 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

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: Constraint (v0.31)
description: API reference for qiskit.optimization.problems.Constraint in qiskit v0.31
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.optimization.problems.Constraint
---
# Constraint
<Class id="qiskit.optimization.problems.Constraint" isDedicatedPage={true} github="https://github.com/qiskit-community/qiskit-aqua/tree/stable/0.9/qiskit/optimization/problems/constraint.py" signature="Constraint(quadratic_program, name, sense, rhs)" modifiers="class">
Bases: `qiskit.optimization.problems.quadratic_program_element.QuadraticProgramElement`
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.
## Methods
<span id="qiskit-optimization-problems-constraint-evaluate" />
### evaluate
<Function id="qiskit.optimization.problems.Constraint.evaluate" signature="Constraint.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>
## Attributes
### 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>