IntegerToBinary#

class IntegerToBinary[source]#

Bases: QuadraticProgramConverter

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

References

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

Annealers. arxiv.org:1706.01945.

Methods

convert(problem)[source]#

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

Parameters:

problem (QuadraticProgram) – The problem to be solved, that may contain integer variables.

Returns:

The converted problem, that contains no integer variables.

Raises:

QiskitOptimizationError – if variable or constraint type is not supported.

Return type:

QuadraticProgram

interpret(x)[source]#

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

Parameters:

x (ndarray | List[float]) – The result of the converted problem or the given result in case of FAILURE.

Returns:

The result of the original problem.

Return type:

ndarray