qiskit_addon_opt_mapper.converters.OptimizationProblemToHubo¶
- class OptimizationProblemToHubo(penalty=None)[source]¶
 Bases:
OptimizationProblemConverterConvert an optimization problem into a HUBO form.
HUBO stands for “higher-order unconstrained binary optimization”. The conversion is achieved by converting variables to binary and eliminating constraints. The resulting problem has no constraints and a higher-order polynomial objective function. This combines several converters: IntegerToBinary, InequalityToPenalty, EqualityToPenalty, and MaximizeToMinimize, while preserving higher-order terms in the objective function. The resulting HUBO problem can be directly mapped to an Ising Hamiltonian using the to_ising() function.
Examples
>>> from qiskit_addon_opt_mapper.problems import OptimizationProblem >>> from qiskit_addon_opt_mapper.converters import OptimizationProblemToHubo >>> problem = OptimizationProblem() >>> # define a problem >>> conv = OptimizationProblemToHubo() >>> problem2 = conv.convert(problem)
Init method.
- 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.
- __init__(penalty=None)[source]¶
 Init method.
- 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.
- Return type:
 None
Methods
__init__([penalty])Init method.
convert(problem)Convert an optimization problem into a HUBO form.
get_compatibility_msg(problem)Checks whether the given problem is compatible with HUBO conversion.
interpret(x)Convert the result of the converted problem back to that of the original problem.
is_compatible(problem)Checks whether a given problem can be solved with the optimizer implementing this method.
Attributes
Returns the penalty factor used in conversion.
- convert(problem)[source]¶
 Convert an optimization problem into a HUBO form.
The new problem has no constraints and the objective function is higher order polynomial.
- Parameters:
 problem (OptimizationProblem) – An optimization problem to be converted.
- Returns:
 A new optimization problem in the HUBO form.
- Raises:
 OptimizationError – If the input problem is invalid.
- Return type:
 OptimizationProblem
- static get_compatibility_msg(problem)[source]¶
 Checks whether the given problem is compatible with HUBO conversion.
A problem is compatible if it can be converted to a HUBO (Higher-order Unconstrained Binary Optimization). If not, this function returns a message explaining the incompatibility.
The following problems are not compatible: - Continuous variables are not supported. - Constraints with float coefficients are not supported, because inequality constraints cannot be converted to equality constraints using integer slack variables.
- Parameters:
 problem (OptimizationProblem) – The optimization problem to check compatibility.
- Returns:
 A message describing the incompatibility.
- Return type:
 
- interpret(x)[source]¶
 Convert the result of the converted problem back to that of the original problem.
Done by applying the interpret method of each converter in reverse order.