GroverOptimizer#

class GroverOptimizer(num_value_qubits, num_iterations=3, converters=None, penalty=None, sampler=None)[source]#

Bases: OptimizationAlgorithm

Uses Grover Adaptive Search (GAS) to find the minimum of a QUBO function.

Parameters:
Raises:
  • ValueError – If both a quantum instance and sampler are set.

  • TypeError – When there one of converters is an invalid type.

Methods

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:

str

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:

bool

solve(problem)[source]#

Tries to solve the given problem using the grover optimizer.

Runs the optimizer to try to solve the optimization problem. If the problem cannot be, converted to a QUBO, this optimizer raises an exception due to incompatibility.

Parameters:

problem (QuadraticProgram) – The problem to be solved.

Returns:

The result of the optimizer applied to the problem.

Raises:
Return type:

OptimizationResult