QuadraticProgramToQubo#

class QuadraticProgramToQubo(penalty=None)[fuente]#

Bases: QuadraticProgramConverter

Convert a given optimization problem to a new problem that is a QUBO.

Ejemplos

>>> from qiskit_optimization.problems import QuadraticProgram
>>> from qiskit_optimization.converters import QuadraticProgramToQubo
>>> problem = QuadraticProgram()
>>> # define a problem
>>> conv = QuadraticProgramToQubo()
>>> problem2 = conv.convert(problem)
Parámetros:

penalty (float | None) – Penalty factor to scale equality constraints that are added to objective. If None is passed, a penalty factor will be automatically calculated on every conversion.

Attributes

penalty#

Returns the penalty factor used in conversion.

Devuelve:

The penalty factor used in conversion.

Methods

convert(problem)[fuente]#

Convert a problem with linear constraints into new one with a QUBO form.

Parámetros:

problem (QuadraticProgram) – The problem with linear constraints to be solved.

Devuelve:

The problem converted in QUBO format as minimization problem.

Muestra:

QiskitOptimizationError – In case of an incompatible problem.

Tipo del valor devuelto:

QuadraticProgram

static get_compatibility_msg(problem)[fuente]#

Checks whether a given problem can be solved with this optimizer.

Checks whether the given problem is compatible, i.e., whether the problem can be converted to a QUBO, and otherwise, returns a message explaining the incompatibility.

Parámetros:

problem (QuadraticProgram) – The optimization problem to check compatibility.

Devuelve:

A message describing the incompatibility.

Tipo del valor devuelto:

str

interpret(x)[fuente]#

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

Parámetros:

x (ndarray | List[float]) – The result of the converted problem.

Devuelve:

The result of the original problem.

Tipo del valor devuelto:

ndarray

is_compatible(problem)[fuente]#

Checks whether a given problem can be solved with the optimizer implementing this method.

Parámetros:

problem (QuadraticProgram) – The optimization problem to check compatibility.

Devuelve:

Returns True if the problem is compatible, False otherwise.

Tipo del valor devuelto:

bool