WarmStartQAOAOptimizer#
- class WarmStartQAOAOptimizer(pre_solver, relax_for_pre_solver, qaoa, epsilon=0.25, num_initial_solutions=1, warm_start_factory=None, aggregator=None, penalty=None, converters=None)[source]#
Bases:
MinimumEigenOptimizer
A meta-algorithm that uses a pre-solver to solve a relaxed version of the problem. Users must implement their own pre solvers by inheriting from the base class.
References
- [1]: Daniel J. Egger et al., Warm-starting quantum optimization.
- Initializes the optimizer. For correct initialization either
epsilon
orcircuit_factory
must be passed. If onlyepsilon
is specified (either an explicit value or the default one), then an instance ofWarmStartQAOACircuitFactory
is created. Ifcircuit_factory
is specified then this instance is used in the implementation andepsilon
value is ignored.
- Parameters:
pre_solver (OptimizationAlgorithm) – An instance of an optimizer to solve the relaxed version of the problem.
relax_for_pre_solver (bool) – True if the problem must be relaxed to the continuous case before passing it to the pre-solver.
qaoa (QAOA) – A QAOA instance to be used in the computations.
epsilon (float) – the regularization parameter that changes the initial variables according to xi = epsilon if xi < epsilon xi = 1-epsilon if xi > epsilon. The regularization parameter epsilon should be between 0 and 0.5. When it is 0.5 then warm start corresponds to standard QAOA. If
circuit_factory
is specified then this parameter is ignored. Default value is 0.25.num_initial_solutions (int) – An optional number of relaxed (continuous) solutions to use. Default value is 1.
warm_start_factory (WarmStartQAOAFactory | None) – An optional instance of the factory to warm start QAOA. This factory is used to create circuits for initial state and mixer. If
None
is specified then a default one, an instance ofWarmStartQAOACircuitFactory
is created using the value of theepsilon
parameter.aggregator (BaseAggregator | None) – Class that aggregates different results. This is used if the pre-solver returns several initial states.
penalty (float | None) – The penalty factor to be used, or
None
for applying a default logic.converters (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 of
QuadraticProgramToQubo
will be used.
- Raises:
QiskitOptimizationError – if
epsilon
is not in the range [0, 0.5].
Attributes
- min_eigen_solver#
Returns the minimum eigensolver.
Methods
- 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.
- Returns:
A message describing the incompatibility.
- Return type:
- 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.
- Returns:
Returns True if the problem is compatible, False otherwise.
- Return type:
- solve(problem)[source]#
Tries to solves the given problem using the optimizer.
The pre-solver is run to warm-start the solver. Next, the optimizer is run to try to solve the optimization problem.
- Parameters:
problem (QuadraticProgram) – The problem to be solved.
- Returns:
The result of the optimizer applied to the problem.
- Raises:
QiskitOptimizationError – If problem not compatible or the presolver can’t solve a problem.
- Return type: