GroverOptimizer#

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

ベースクラス: OptimizationAlgorithm

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

パラメータ:
  • num_value_qubits (int) – The number of value qubits.

  • num_iterations (int) – The number of iterations the algorithm will search with no improvement.

  • 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.

  • penalty (float | None) – The penalty factor used in the default QuadraticProgramToQubo converter

  • sampler (BaseSampler | None) – A Sampler to use for sampling the results of the circuits.

例外:
  • 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)[ソース]#

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.

パラメータ:

problem (QuadraticProgram) – The optimization problem to check compatibility.

戻り値:

A message describing the incompatibility.

戻り値の型:

str

is_compatible(problem)#

Checks whether a given problem can be solved with the optimizer implementing this method.

パラメータ:

problem (QuadraticProgram) – The optimization problem to check compatibility.

戻り値:

Returns True if the problem is compatible, False otherwise.

戻り値の型:

bool

solve(problem)[ソース]#

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.

パラメータ:

problem (QuadraticProgram) – The problem to be solved.

戻り値:

The result of the optimizer applied to the problem.

例外:
戻り値の型:

OptimizationResult