Code
qcr:2606.85248.1

Grover Adaptive Search Optimizer

This Qiskit Optimization tutorial implements the GroverOptimizer, which uses Grover Adaptive Search (GAS) to solve quadratic unconstrained binary optimization (QUBO) problems via amplitude amplification rather than the variational approach. The method reframes optimization as repeated search: it maintains a threshold on the objective value and uses a Grover-based oracle to amplify and find solutions whose objective is better than the current threshold, then lowers the threshold to that newly-found value and repeats, adaptively converging toward the optimum. The tutorial shows how to construct the GroverOptimizer for a QuadraticProgram, configure the number of value-encoding qubits and iteration limits, run it through Qiskit's Sampler primitive, and read back the optimal variable assignment. It explains how GAS provides a quadratic speedup in the search over candidate solutions compared to brute force, and contrasts it with variational optimizers like QAOA. By applying Grover's amplitude amplification to optimization, the tutorial demonstrates an alternative, search-based route to quantum combinatorial optimization in Qiskit.
Optimization
Qubit
Circuit-based
Uploaded 3 days ago
11
Views
Citing this entry? Use this QCR ID
Uploaded by
QL
QCR Librarian

Overview

qiskit-community/qiskit-optimization
282149
In [ ]:
# --- Setup cell added by QCR (not part of the original tutorial) ---
# Source: qiskit-community/qiskit-optimization @ 0.7.0, Apache License 2.0.
# Installs the example's dependencies. If a later cell still reports a missing
# package, restart the runtime/kernel and run again from the top.
%pip install -q qiskit-optimization==0.7.0 docplex

Grover Optimizer

Introduction

Grover Adaptive Search (GAS) has been explored as a possible solution for combinatorial optimization problems, alongside variational algorithms such as Variational Quantum Eigensolver (VQE) and Quantum Approximate Optimization Algorithm (QAOA). The algorithm iteratively applies Grover Search to find the optimum value of an objective function, by using the best-known value from the previous run as a threshold. The adaptive oracle used in GAS recognizes all values above or below the current threshold (for max and min respectively), decreasing the size of the search space every iteration the threshold is updated, until an optimum is found.

In this notebook we will explore each component of the GroverOptimizer, which utilizes the techniques described in GAS, by minimizing a Quadratic Unconstrained Binary Optimization (QUBO) problem, as described in [1]

References

[1] A. Gilliam, S. Woerner, C. Gonciulea, Grover Adaptive Search for Constrained Polynomial Binary Optimization, arXiv preprint arXiv:1912.04088 (2019).

Grover Adaptive Search

Grover Search, the core element of GAS, needs three ingredients:

  1. A state preparation operator to construct a superposition of all states in the search space.

  2. An oracle operator , that recognizes the states of interest and multiplies their amplitudes by -1.

  3. The Grover diffusion operator , that multiplies the amplitude of the state by -1.

While implementations of GAS vary around the specific use case, the general framework still loosely follows the steps described below.



GroverOptimizer uses QuadraticProgramToNegativeValueOracle to construct such that it prepares a -qubit register to represent the equal superposition of all and a -qubit register to (approximately) represent the corresponding . Then, all states with negative should be flagged by . Note that in the implementation discussed, the oracle operator is actually independent of , but this is not a requirement. For clarity, we will refer to the oracle as when the oracle is independent of .

Put formally, QuadraticProgramToNegativeValueOracle constructs an and such that:



where is the binary encoding of the integer .

At each iteration in which the threshold is updated, we adapt such that the function values are shifted up or down (for minimum and maximum respectively) by . For example, in the context of finding the minimum, as the value of decreases, the search space (negative values) also decreases, until only the minimum value remains. A concrete example will be explored in the next section.

Find the Minimum of a QUBO Problem using GroverOptimizer

The following is a toy example of a minimization problem.

For our initial steps, we create a docplex model that defines the problem above, and then use the from_docplex_mp() function to convert the model to a QuadraticProgram, which can be used to represent a QUBO in Qiskit Optimization.

In [1]:
from docplex.mp.model import Model
from qiskit.primitives import StatevectorSampler
from qiskit_optimization.algorithms import GroverOptimizer, MinimumEigenOptimizer
from qiskit_optimization.minimum_eigensolvers import NumPyMinimumEigensolver
from qiskit_optimization.translators import from_docplex_mp
In [2]:
model = Model()
x0 = model.binary_var(name="x0")
x1 = model.binary_var(name="x1")
x2 = model.binary_var(name="x2")
model.minimize(-x0 + 2 * x1 - 3 * x2 - 2 * x0 * x2 - 1 * x1 * x2)
qp = from_docplex_mp(model)
print(qp.prettyprint())
Problem name: docplex_model1

Minimize
  -2*x0*x2 - x1*x2 - x0 + 2*x1 - 3*x2

Subject to
  No constraints

  Binary variables (3)
    x0 x1 x2

Next, we create a GroverOptimizer that uses 6 qubits to encode the value, and will terminate after there have been 10 iterations of GAS without progress (i.e. the value of does not change). The solve() function takes the QuadraticProgram we created earlier, and returns a results object that contains information about the run.

In [3]:
grover_optimizer = GroverOptimizer(6, num_iterations=10, sampler=StatevectorSampler(seed=123))
results = grover_optimizer.solve(qp)
print(results.prettyprint())
objective function value: -6.0
variable values: x0=1.0, x1=0.0, x2=1.0
status: SUCCESS

This results in the optimal solution , , and the optimal objective value of (most of the time, since it is a randomized algorithm). In the following, a custom visualization of the quantum state shows a possible run of GroverOptimizer applied to this QUBO.



Each graph shows a single iteration of GAS, with the current values of (= iteration counter) and (= threshold/offset) shown in the title. The X-axis displays the integer equivalent of the input (e.g. '101' 5), and the Y-axis shows the possible function values. As there are 3 binary variables, there are possible solutions, which are shown in each graph. The color intensity indicates the probability of measuring a certain result (with bright intensity being the highest), while the actual color indicates the corresponding phase (see phase color-wheel below). Note that as decreases, we shift all of the values up by that amount, meaning there are fewer and fewer negative values in the distribution, until only one remains (the minimum).


Check that GroverOptimizer finds the correct value

We can verify that the algorithm is working correctly using the MinimumEigenOptimizer in Qiskit optimization.

In [4]:
exact_solver = MinimumEigenOptimizer(NumPyMinimumEigensolver())
exact_result = exact_solver.solve(qp)
print(exact_result.prettyprint())
objective function value: -6.0
variable values: x0=1.0, x1=0.0, x2=1.0
status: SUCCESS
In [5]:
import tutorial_magics

%qiskit_version_table
%qiskit_copyright

Version Information

SoftwareVersion
qiskit2.1.1
qiskit_optimization0.7.0
System information
Python version3.11.13
OSDarwin
Mon Aug 18 14:19:53 2025 JST

This code is a part of a Qiskit project

© Copyright IBM 2017, 2025.

This code is licensed under the Apache License, Version 2.0. You may
obtain a copy of this license in the LICENSE.txt file in the root directory
of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.

Any modifications or derivative works of this code must retain this
copyright notice, and modified files need to carry a notice indicating
that they have been altered from the originals.

In [ ]:

Join the Discussion

Comments (0)

No comments yet. Be the first to share your thoughts!

Indexed by QCR Librarian

This entry was created automatically from publicly available records. QCR links to public sources and only stores repository content where the license permits redistribution.

Publication

doi:10.48550/arxiv.1912.04088
Grover Adaptive Search for Constrained Polynomial Binary Optimization

Austin Gilliam, Stefan Woerner, Constantin Gonciulea

Versions

v1 Latest
Jun 15, 2026
qcr:2606.85248.1

Cite all versions? Use the base QCR ID to always reference the latest version of this entry.

Tools used

Qiskit

Keywords

grover-adaptive-search
optimization
amplitude-amplification
qiskit
qubo

You may also like5