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.QuadraticProgramToQubo

class QuadraticProgramToQubo(penalty=None)

GitHub

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)

Parameters

penalty (Optional[float]) – Penalty factor to scale equality constraints that are added to objective. If None is passed, penalty factor will be automatically calculated.

__init__

__init__(penalty=None)

Parameters

penalty (Optional[float]) – Penalty factor to scale equality constraints that are added to objective. If None is passed, penalty factor will be automatically calculated.


Methods

__init__([penalty])type penaltyOptional[float]
convert(problem)Convert a problem with linear equality constraints into new one with a QUBO form.
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.
get_compatibility_msg(problem)Checks whether a given problem can be solved with this optimizer.
interpret(result)Convert a result of a converted problem into that of the original problem.
is_compatible(problem)Checks whether a given problem can be solved with the optimizer implementing this method.

Attributes

penaltyReturns the penalty factor used in conversion.

convert

convert(problem)

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

Parameters

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

Return type

QuadraticProgram

Returns

The problem converted in QUBO format.

Raises

QiskitOptimizationError – In case of an incompatible problem.

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

get_compatibility_msg

static get_compatibility_msg(problem)

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.

Parameters

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

Return type

str

Returns

A message describing the incompatibility.

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.

Return type

OptimizationResult

Returns

The result of the original problem.

is_compatible

is_compatible(problem)

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

Parameters

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

Return type

bool

Returns

Returns True if the problem is compatible, False otherwise.

penalty

Returns the penalty factor used in conversion.

Return type

Optional[float]

Returns

The penalty factor used in conversion.

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