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.

IntegerToBinary

class IntegerToBinary

GitHub

Convert a QuadraticProgram into new one by encoding integer with binary variables.

This bounded-coefficient encoding used in this converted is proposed in [1], Eq. (5).

Examples

>>> from qiskit.optimization.problems import QuadraticProgram
>>> from qiskit.optimization.converters import IntegerToBinary
>>> problem = QuadraticProgram()
>>> var = problem.integer_var(name='x', lowerbound=0, upperbound=10)
>>> conv = IntegerToBinary()
>>> problem2 = conv.encode(problem)

References

[1]: Sahar Karimi, Pooya Ronagh (2017), Practical Integer-to-Binary Mapping for Quantum

Annealers. arxiv.org:1706.01945.


Methods

decode

IntegerToBinary.decode(result)

Convert the encoded problem (binary variables) back to the original (integer variables).

Parameters

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

Return type

OptimizationResult

Returns

The result of the original problem.

encode

IntegerToBinary.encode(op, name=None)

Convert an integer problem into a new problem with binary variables.

Parameters

  • op (QuadraticProgram) – The problem to be solved, that may contain integer variables.
  • name (Optional[str]) – The name of the converted problem. If not provided, the name of the input problem is used.

Return type

QuadraticProgram

Returns

The converted problem, that contains no integer variables.

Raises

QiskitOptimizationError – if variable or constraint type is not supported.

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