Skip to content

Optimization and QUBO

qiskit-optimization

Maintained by Qiskit

Qiskit Optimization is a focused entry point into optimization modeling and hybrid workflows within the larger Qiskit ecosystem.

PythonApache-2.0FlagshipQtangl relevant
qiskit-optimization illustration

Resource snapshot

Category

Optimization and QUBO

Stars

281

Last pushed

Apr 1, 2026Updated 5mo ago

Open issues

22

Quickstart

Get running in a few lines.

Quickstart
from docplex.mp.model import Model

from qiskit_optimization.algorithms import MinimumEigenOptimizer
from qiskit_optimization.translators import from_docplex_mp
from qiskit_optimization.utils import algorithm_globals
from qiskit_optimization.minimum_eigensolvers import QAOA
from qiskit_optimization.optimizers import SPSA

from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit_aer import AerSimulator
from qiskit_aer.primitives import SamplerV2

# Generate a graph of 4 nodes
n = 4
edges = [(0, 1, 1.0), (0, 2, 1.0), (0, 3, 1.0), (1, 2, 1.0), (2, 3, 1.0)]  # (node_i, node_j, weight)

# Formulate the problem as a Docplex model
model = Model()

# Create n binary variables
x = model.binary_var_list(n)

# Define the objective function to be maximized
model.maximize(model.sum(w * x[i] * (1 - x[j]) + w * (1 - x[i]) * x[j] for i, j, w in edges))

# Fix node 0 to be 1 to break the symmetry of the max-cut solution
model.add(x[0] == 1)

# Convert the Docplex model into a `QuadraticProgram` object
problem = from_docplex_mp(model)

# Run quantum algorithm QAOA on qasm simulator
seed = 1234
algorithm_globals.random_seed = seed

spsa = SPSA(maxiter=250)
sampler = SamplerV2(seed=seed, default_shots=10000)
pass_manager = generate_preset_pass_manager(optimization_level=1, backend=AerSimulator())
qaoa = QAOA(sampler=sampler, optimizer=spsa, reps=5, pass_manager=pass_manager)
algorithm = MinimumEigenOptimizer(qaoa)
result = algorithm.solve(problem)
print(result.prettyprint())  # prints solution, x=[1, 0, 1, 0], the cost, fval=4

What it is

For readers trying to understand where optimization fits inside a major framework, this package is an important waypoint. It makes the optimization story inspectable inside an ecosystem many developers already recognize.

That is useful both educationally and strategically. It helps people compare whether they want a framework-embedded optimization package or a more specialized tool built around the problem class itself.

Who it's for

Developers already working in Qiskit or anyone comparing framework-embedded optimization tooling with standalone libraries.

What you can build or learn

  • Inspect how a major SDK packages optimization concepts for developers.
  • Compare embedded optimization workflows with specialized tools like OpenQAOA or dimod.
  • Use the package as a reference for framework-integrated hybrid experimentation.

Plays well with

License

Apache-2.0

SPDX identifier detected from the repository metadata or license files.

Repository README

Preview from the project README.

Rendered as Markdown inside a scrollable preview. Long READMEs stay contained; expand or open on GitHub for the full document.

~845 words · about 4 min readOpen on GitHub

Qiskit Optimization

[!WARNING] Qiskit Optimization is no longer officially supported by IBM. While you may continue to use or extend it under the Apache 2.0 license, please note that it is provided as-is and without official support. For a fully supported solution and extended mapping features, migrate to the qiskit-addon-opt-mapper library.

Qiskit Optimization is an open-source framework that covers the whole range from high-level modeling of optimization problems, with automatic conversion of problems to different required representations, to a suite of easy-to-use quantum optimization algorithms that are ready to run on classical simulators, as well as on real quantum devices via Qiskit.

The Optimization module enables easy, efficient modeling of optimization problems using docplex. A uniform interface as well as automatic conversion between different problem representations allows users to solve problems using a large set of algorithms, from variational quantum algorithms, such as the Quantum Approximate Optimization Algorithm QAOA, to Grover Adaptive Search using the GroverOptimizer, leveraging fundamental algorithms. Furthermore, the modular design of the optimization module allows it to be easily extended and facilitates rapid development and testing of new algorithms. Compatible classical optimizers are also provided for testing, validation, and benchmarking.

Installation

We encourage installing Qiskit Optimization via the pip tool (a python package manager).

pip install qiskit-optimization

pip will handle all dependencies automatically and you will always install the latest (and well-tested) version.

If you want to work on the very latest work-in-progress versions, either to try features ahead of their official release or if you want to contribute to Optimization, then you can install from source. To do this follow the instructions in the documentation.


Optional Installs

  • IBM CPLEX may be installed using pip install 'qiskit-optimization[cplex]' to enable the reading of LP files and the usage of the CplexOptimizer, wrapper for cplex.Cplex. CPLEX is a separate package and its support of Python versions is independent of Qiskit Optimization, where this CPLEX command will have no effect if there is no compatible version of CPLEX available (yet).

  • CVXPY may be installed using the command pip install 'qiskit-optimization[cvx]'. CVXPY being installed will enable the usage of the Goemans-Williamson algorithm as an optimizer GoemansWilliamsonOptimizer.

  • Matplotlib may be installed using the command pip install 'qiskit-optimization[matplotlib]'. Matplotlib being installed will enable the usage of the draw method in the graph optimization application classes.

  • Gurobipy may be installed using the command pip install 'qiskit-optimization[gurobi]'. Gurobipy being installed will enable the usage of the GurobiOptimizer.

Creating Your First Optimization Programming Experiment in Qiskit

Now that Qiskit Optimization is installed, it's time to begin working with the optimization module. Let's try an optimization experiment to compute the solution of a Max-Cut. The Max-Cut problem can be formulated as quadratic program, which can be solved using many several different algorithms in Qiskit. In this example, the MinimumEigenOptimizer is employed in combination with the Quantum Approximate Optimization Algorithm (QAOA) as minimum eigensolver routine.

from docplex.mp.model import Model

from qiskit_optimization.algorithms import MinimumEigenOptimizer
from qiskit_optimization.translators import from_docplex_mp
from qiskit_optimization.utils import algorithm_globals
from qiskit_optimization.minimum_eigensolvers import QAOA
from qiskit_optimization.optimizers import SPSA

from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit_aer import AerSimulator
from qiskit_aer.primitives import SamplerV2

# Generate a graph of 4 nodes
n = 4
edges = [(0, 1, 1.0), (0, 2, 1.0), (0, 3, 1.0), (1, 2, 1.0), (2, 3, 1.0)]  # (node_i, node_j, weight)

# Formulate the problem as a Docplex model
model = Model()

# Create n binary variables
x = model.binary_var_list(n)

# Define the objective function to be maximized
model.maximize(model.sum(w * x[i] * (1 - x[j]) + w * (1 - x[i]) * x[j] for i, j, w in edges))

# Fix node 0 to be 1 to break the symmetry of the max-cut solution
model.add(x[0] == 1)

# Convert the Docplex model into a `QuadraticProgram` object
problem = from_docplex_mp(model)

# Run quantum algorithm QAOA on qasm simulator
seed = 1234
algorithm_globals.random_seed = seed

spsa = SPSA(maxiter=250)
sampler = SamplerV2(seed=seed, default_shots=10000)
pass_manager = generate_preset_pass_manager(optimization_level=1, backend=AerSimulator())
qaoa = QAOA(sampler=sampler, optimizer=spsa, reps=5, pass_manager=pass_manager)
algorithm = MinimumEigenOptimizer(qaoa)
result = algorithm.solve(problem)
print(result.prettyprint())  # prints solution, x=[1, 0, 1, 0], the cost, fval=4

Further examples

Learning path notebooks may be found in the optimization tutorials section of the documentation and are a great place to start.


Contribution Guidelines

If you'd like to contribute to Qiskit, please take a look at our contribution guidelines. This project adheres to Qiskit's code of conduct. By participating, you are expected to uphold this code.

We use GitHub issues for tracking requests and bugs. Please join the Qiskit Slack community and for discussion and simple questions. For questions that are more suited for a forum, we use the Qiskit tag in Stack Overflow.

Authors and Citation

Optimization was inspired, authored and brought about by the collective work of a team of researchers. Optimization continues to grow with the help and work of many people, who contribute to the project at different levels. If you use Qiskit, please cite as per the provided BibTeX file.

License

This project uses the Apache License 2.0.

Read on GitHub

Activity

Latest release

—

Watchers

9

Python support

—

How this relates to Qtangl

Qiskit Optimization is directly relevant to Qtangl because it sits at the intersection of developer familiarity and optimization experimentation. It is part of the practical comparison set for how planning-style problems might be modeled, tested, and explained when a product wants to remain credible about hybrid research steps.

Learn digest

Get monthly updates when library entries change.

Monthly digest: new library entries, updated flagships, and one editorial pick.

Related resources

Keep exploring nearby tools.

dwavesystems

dwave_sapi_dimod

dimod wrapper for D-Wave's SAPI Client Library

PythonApache-2.0Archive

9 stars · Updated 8y ago

cda-tum

mqt-qmap

MQT QMAP - A tool for Quantum Circuit Mapping written in C++

C++MITFlagshipQtangl relevant

138 stars · Updated 3mo ago

entropicalabs

openqaoa

Multi-backend SDK for quantum optimisation

PythonMITFlagshipQtangl relevant

139 stars · Updated 2y ago

dwavesystems

penaltymodel

Utilities and interfaces for using penalty models.

PythonApache-2.0Archive

19 stars · Updated 1y ago

jtiosue

qubovert

The one-stop package for formulating, simulating, and solving problems in boolean and spin form

PythonApache-2.0FlagshipQtangl relevant

41 stars · Updated 4mo ago

goodchemistryco

Tangelo

A python package for exploring end-to-end chemistry workflows on quantum computers and simulators.

PythonApache-2.0Qtangl relevant

137 stars · Updated 8mo ago