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)
- Parameters:
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.
- Returns:
The penalty factor used in conversion.
Methods
- convert(problem)[source]#
Convert a problem with linear constraints into new one with a QUBO form.
- Parameters:
problem (QuadraticProgram) – The problem with linear constraints to be solved.
- Returns:
The problem converted in QUBO format as minimization problem.
- Raises:
QiskitOptimizationError – In case of an incompatible problem.
- Return type:
- 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.
- Parameters:
problem (QuadraticProgram) – The optimization problem to check compatibility.
- Returns:
A message describing the incompatibility.
- Return type:
- is_compatible(problem)[source]#
Checks whether a given problem can be solved with the optimizer implementing this method.
- Parameters:
problem (QuadraticProgram) – The optimization problem to check compatibility.
- Returns:
Returns True if the problem is compatible, False otherwise.
- Return type: