QuadraticProgramToQubo#

class QuadraticProgramToQubo(penalty=None)[source]#

Bases: QuadraticProgramConverter

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

Examples

>>> from qiskit_optimization.problems import QuadraticProgram
>>> from qiskit_optimization.converters import QuadraticProgramToQubo
>>> problem = QuadraticProgram()
>>> # define a problem
>>> conv = QuadraticProgramToQubo()
>>> problem2 = conv.convert(problem)
প্যারামিটার:

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.

রিটার্নস:

The penalty factor used in conversion.

Methods

convert(problem)[source]#

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

প্যারামিটার:

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

রিটার্নস:

The problem converted in QUBO format as minimization problem.

রেইজেস:

QiskitOptimizationError -- In case of an incompatible problem.

রিটার্ন টাইপ:

QuadraticProgram

static get_compatibility_msg(problem)[source]#

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.

প্যারামিটার:

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

রিটার্নস:

A message describing the incompatibility.

রিটার্ন টাইপ:

str

interpret(x)[source]#

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

প্যারামিটার:

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

রিটার্নস:

The result of the original problem.

রিটার্ন টাইপ:

ndarray

is_compatible(problem)[source]#

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

প্যারামিটার:

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

রিটার্নস:

Returns True if the problem is compatible, False otherwise.

রিটার্ন টাইপ:

bool