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.

qiskit.optimization.converters.InequalityToEquality

class InequalityToEquality(mode='auto')

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.convert(problem)

Parameters

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

__init__

__init__(mode='auto')

Parameters

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


Methods

__init__([mode])type modestr
convert(problem)Convert a problem with inequality constraints into one with only equality constraints.
decode(result)DEPRECATED Decode a result into another form using the information of conversion.
encode(problem)DEPRECATED Encode a QuadraticProgram into another form and keep the information required to decode the result.
interpret(result)Convert a result of a converted problem into that of the original problem.

Attributes

modeReturns the mode of the converter

convert

convert(problem)

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

Parameters

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

Return type

QuadraticProgram

Returns

The converted problem, that contain only equality constraints.

Raises

decode

decode(result)

DEPRECATED Decode a result into another form using the information of conversion.

Return type

OptimizationResult

encode

encode(problem)

DEPRECATED Encode a QuadraticProgram into another form and keep the information required to decode the result.

Return type

QuadraticProgram

interpret

interpret(result)

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

Parameters

result (OptimizationResult) – The result of the converted problem or the given result in case of FAILURE.

Return type

OptimizationResult

Returns

The result of the original problem.

mode

Returns the mode of the converter

Return type

str

Returns

The mode of the converter used for additional slack variables

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