qiskit.optimization.algorithms.RecursiveMinimumEigenOptimizer
class RecursiveMinimumEigenOptimizer(min_eigen_optimizer, min_num_vars=1, min_num_vars_optimizer=None, penalty=None, history=<IntermediateResult.LAST_ITERATION: 1>, converters=None)
A meta-algorithm that applies a recursive optimization.
The recursive minimum eigen optimizer applies a recursive optimization on top of MinimumEigenOptimizer
. The algorithm is introduced in [1].
Examples
Outline of how to use this class:
from qiskit.aqua.algorithms import QAOA
from qiskit.optimization.problems import QuadraticProgram
from qiskit.optimization.algorithms import RecursiveMinimumEigenOptimizer
problem = QuadraticProgram()
# specify problem here
# specify minimum eigen solver to be used, e.g., QAOA
qaoa = QAOA(...)
optimizer = RecursiveMinimumEigenOptimizer(qaoa)
result = optimizer.solve(problem)
References
[1]: Bravyi et al. (2019), Obstacles to State Preparation and Variational Optimization
from Symmetry Protection. http://arxiv.org/abs/1910.08980.
Initializes the recursive minimum eigen optimizer.
This initializer takes a MinimumEigenOptimizer
, the parameters to specify until when to to apply the iterative scheme, and the optimizer to be applied once the threshold number of variables is reached.
Parameters
- min_eigen_optimizer (
MinimumEigenOptimizer
) – The eigen optimizer to use in every iteration. - min_num_vars (
int
) – The minimum number of variables to apply the recursive scheme. If this threshold is reached, the min_num_vars_optimizer is used. - min_num_vars_optimizer (
Optional
[OptimizationAlgorithm
]) – This optimizer is used after the recursive scheme for the problem with the remaining variables. - penalty (
Optional
[float
]) – The factor that is used to scale the penalty terms corresponding to linear equality constraints. - history (
Optional
[IntermediateResult
]) – Whether the intermediate results are stored. Default value isLAST_ITERATION
. - converters (
Union
[QuadraticProgramConverter
,List
[QuadraticProgramConverter
],None
]) – The converters to use for converting a problem into a different form. By default, when None is specified, an internally created instance ofQuadraticProgramToQubo
will be used.
Raises
- QiskitOptimizationError – In case of invalid parameters (num_min_vars < 1).
- TypeError – When there one of converters is an invalid type.
__init__
__init__(min_eigen_optimizer, min_num_vars=1, min_num_vars_optimizer=None, penalty=None, history=<IntermediateResult.LAST_ITERATION: 1>, converters=None)
Initializes the recursive minimum eigen optimizer.
This initializer takes a MinimumEigenOptimizer
, the parameters to specify until when to to apply the iterative scheme, and the optimizer to be applied once the threshold number of variables is reached.
Parameters
- min_eigen_optimizer (
MinimumEigenOptimizer
) – The eigen optimizer to use in every iteration. - min_num_vars (
int
) – The minimum number of variables to apply the recursive scheme. If this threshold is reached, the min_num_vars_optimizer is used. - min_num_vars_optimizer (
Optional
[OptimizationAlgorithm
]) – This optimizer is used after the recursive scheme for the problem with the remaining variables. - penalty (
Optional
[float
]) – The factor that is used to scale the penalty terms corresponding to linear equality constraints. - history (
Optional
[IntermediateResult
]) – Whether the intermediate results are stored. Default value isLAST_ITERATION
. - converters (
Union
[QuadraticProgramConverter
,List
[QuadraticProgramConverter
],None
]) – The converters to use for converting a problem into a different form. By default, when None is specified, an internally created instance ofQuadraticProgramToQubo
will be used.
Raises
- QiskitOptimizationError – In case of invalid parameters (num_min_vars < 1).
- TypeError – When there one of converters is an invalid type.
Methods
__init__ (min_eigen_optimizer[, …]) | Initializes the recursive minimum eigen optimizer. |
get_compatibility_msg (problem) | Checks whether a given problem can be solved with this optimizer. |
is_compatible (problem) | Checks whether a given problem can be solved with the optimizer implementing this method. |
solve (problem) | Tries to solve the given problem using the recursive optimizer. |
get_compatibility_msg
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.
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.
solve
solve(problem)
Tries to solve the given problem using the recursive optimizer.
Runs the optimizer to try to solve the optimization problem.
Parameters
problem (QuadraticProgram
) – The problem to be solved.
Return type
OptimizationResult
Returns
The result of the optimizer applied to the problem.
Raises
- QiskitOptimizationError – Incompatible problem.
- QiskitOptimizationError – Infeasible due to variable substitution