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

IBM Quantum Platform is moving and this version will be sunset on July 1. To get started on the new platform, read the migration guide.

InequalityToEquality

class InequalityToEquality

GitHub

Convert inequality constraints into equality constraints by introducing slack variables.

Examples

>>> from qiskit.optimization.problems import QuadraticProgram
>>> from qiskit.optimization.converters import InequalityToEquality
>>> problem = QuadraticProgram()
>>> # define a problem
>>> conv = InequalityToEquality()
>>> problem2 = conv.encode(problem)

Methods

decode

InequalityToEquality.decode(result)

Convert a result of a converted problem into that of the original problem.

Parameters

result (OptimizationResult) – The result of the converted problem.

Return type

OptimizationResult

Returns

The result of the original problem.

encode

InequalityToEquality.encode(op, name=None, mode='auto')

Convert a problem with inequality constraints into one with only equality constraints.

Parameters

  • op (QuadraticProgram) – The problem to be solved, that may contain inequality constraints.

  • name (Optional[str]) – The name of the converted problem.

  • mode (str) –

    To chose the type of slack variables. There are 3 options for mode.

    • ’integer’: All slack variables will be integer variables.

    • ’continuous’: All slack variables will be continuous variables

    • ’auto’: Try to use integer variables but if it’s not possible,

      use continuous variables

Return type

QuadraticProgram

Returns

The converted problem, that contain only equality constraints.

Raises

Was this page helpful?
Report a bug or request content on GitHub.