• Stars
    star
    228
  • Rank 175,267 (Top 4 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created almost 4 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Quantum Optimization

Qiskit Optimization

LicenseBuild StatusCoverage Status

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 provided by Qiskit 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. Currently there is no python 3.9 version of CPLEX. In this case, the CPLEX install command will have no effect.

  • 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.primitives import Sampler

from qiskit_algorithms.utils import algorithm_globals
from qiskit_algorithms import QAOA
from qiskit_algorithms.optimizers import SPSA

# 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 = Sampler()
qaoa = QAOA(sampler=sampler, optimizer=spsa, reps=5)
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.

More Repositories

1

qiskit-community-tutorials

A collection of Jupyter notebooks developed by the community showing how to use Qiskit
Jupyter Notebook
710
star
2

qiskit-machine-learning

Quantum Machine Learning
Python
668
star
3

qiskit-aqua

Quantum Algorithms & Applications (**DEPRECATED** since April 2021 - see readme for more info)
Python
572
star
4

qiskit-nature

Qiskit Nature is an open-source, quantum computing, framework for solving quantum mechanical natural science problems.
Python
301
star
5

qiskit-metal

Quantum Hardware Design. Open-source project for engineers and scientists to design superconducting quantum devices with ease.
Python
288
star
6

IBMQuantumChallenge2020

Quantum Challenge problem sets
Jupyter Notebook
252
star
7

qiskit-finance

Quantum Finance
Python
237
star
8

qiskit-ignis

Ignis (deprecated) provides tools for quantum hardware verification, noise characterization, and error correction.
Python
168
star
9

ibm-quantum-challenge-2024

For IBM Quantum Challenge 2024 (5-14 June 2024)
Jupyter Notebook
159
star
10

qiskit-experiments

Qiskit Experiments
Python
156
star
11

ibm-quantum-challenge-2021

For IBM Quantum Challenge 2021 (May 20 - 26)
Jupyter Notebook
155
star
12

ibm-quantum-challenge-spring-2023

For IBM Quantum Challenge Spring 2023
Jupyter Notebook
150
star
13

qiskit-translations

Home of Qiskit documentation translations
Shell
143
star
14

ibm-quantum-challenge-fall-2021

For IBM Quantum Challenge Fall 2021
Jupyter Notebook
139
star
15

may4_challenge_exercises

Original versions of the exercises
Jupyter Notebook
121
star
16

ibm-quantum-challenge-fall-22

For IBM Quantum Fall Challenge 2022
Jupyter Notebook
120
star
17

qiskit-algorithms

A library of quantum algorithms for Qiskit.
Python
115
star
18

qiskit-js

⚛️ Qiskit (Quantum Information Science Kit) for JavaScript
JavaScript
114
star
19

qiskit-dynamics

Tools for building and solving models of quantum systems in Qiskit
Python
103
star
20

ibm-quantum-spring-challenge-2022

Jupyter Notebook
98
star
21

qgss-2023

All things Qiskit Global Summer School 2023: Theory to Implementation - Lecture notes, Labs and Solutions
Jupyter Notebook
97
star
22

open-science-prize-2021

Jupyter Notebook
84
star
23

quantum-explorers

A self-paced, quantum computing learning journey for high school students and above.
Jupyter Notebook
83
star
24

qiskit-qec

Qiskit quantum error correction framework
Python
81
star
25

qiskit-presentations

Awesome Qiskit presentations
Jupyter Notebook
79
star
26

qgss-2024

Qiskit Global Summer School 2024: The Path to Utility
Jupyter Notebook
74
star
27

qiskit-research

Research using Qiskit.
Python
67
star
28

open-science-prize-2022

Jupyter Notebook
67
star
29

qiskit-braket-provider

Qiskit-Braket provider to execute Qiskit programs on quantum computing hardware devices through Amazon Braket.
Python
58
star
30

mapomatic

Automatic mapping of compiled circuits to low-noise sub-graphs
Python
56
star
31

qiskit-application-modules-demo-sessions

Demo notebooks for Qiskit application modules demo sessions (Oct 8 & 15):
Jupyter Notebook
49
star
32

ibm-quantum-challenge-africa-2021

For IBM Quantum Challenge Africa 2021, 9 September (07:00 UTC) - 20 September (23:00 UTC).
Jupyter Notebook
49
star
33

Quantum-Challenge-Grader

Grading client for the IBM Quantum Challenges
Python
44
star
34

open-science-prize

Jupyter Notebook
42
star
35

qiskit-ionq

Qiskit provider for IonQ backends
Python
42
star
36

MicroQiskit

Jupyter Notebook
42
star
37

ICPC-Quantum-Challenge-2021

Original version of the exercises for the 2021 ICPC Quantum Computing Challenge
Jupyter Notebook
41
star
38

intro-to-quantum-computing-and-quantum-hardware

intro-to-quantum-computing-and-quantum-hardware
41
star
39

quantum-prototype-template

A template repository for generating new quantum prototypes based on Qiskit
Python
41
star
40

prototype-quantum-kernel-training

Toolkit for training quantum kernels in machine learning applications
Python
40
star
41

qiskit-swift

Qiskit in swift
Swift
39
star
42

lindbladmpo

A matrix-product-operators solver for the dynamics of interacting qubits modeled by a Lindblad master equation, written in C++ and wrapped with an easy-to-use Python interface.
Python
36
star
43

qiskit-hackathon-korea-22

Jupyter Notebook
35
star
44

qiskit-hackathon-korea-21

A repository for Qiskit Hackathon Korea (February 16-19, 2021)
33
star
45

qiskit-hackathon-taiwan-20

32
star
46

qiskit-cold-atom

Tools to control cold-atom-based quantum simulators and quantum computers.
Python
31
star
47

povm-toolbox

A toolbox for the implementation of positive operator-valued measures (POVMs).
Python
30
star
48

prototype-entanglement-forging

A module for simulating chemical and physical systems using a Variational Quantum Eigensolver (VQE) enhanced by Entanglement Forging.
Python
29
star
49

prototype-zne

Zero Noise Extrapolation (ZNE) prototype for error mitigation on the Qiskit Estimator primitive
Python
28
star
50

QuantumBlur

Jupyter Notebook
27
star
51

qiskit-aqt-provider

Qiskit provider for AQT backends.
Python
27
star
52

prototype-qrao

Quantum random access optimization prototype
Python
27
star
53

qiskit-dell-runtime

Qiskit Dell Runtime is a Qiskit Runtime platform that can execute classical-quantum code on both local and on-premise environments. With this platform, hybrid classical-quantum code bundle can be developed and executed. Powered by Qiskit Runtime API, this execution model provides close-integration of classical and quantum execution.
Python
27
star
54

QuantumGraph

Jupyter Notebook
26
star
55

qiskit-app-benchmarks

Qiskit Application Benchmarks
Python
25
star
56

qiskit-qcgpu-provider

A provider which allows Qiskit to use the QCGPU simulator
Python
25
star
57

qopt-best-practices

A collection of guidelines to run quantum optimization algorithms on superconducting qubits with Qiskit, using as reference the Quantum Approximate Optimization Algorithm (QAOA) workflow.
Jupyter Notebook
25
star
58

qiskit-pocket-guide

Code from the Qiskit Pocket Guide book
Jupyter Notebook
23
star
59

ffsim

Faster simulations of fermionic quantum circuits.
Python
22
star
60

qiskit-quantinuum-provider

Qiskit provider for Quantinuum backends.
Python
21
star
61

ml-qem

Library for solving quantum computing problems using machine learning
Python
20
star
62

awesome-qiskit

Awesome Qiskit is a list of projects, tools, utilities, libraries and tutorials from a broad community of developers and researchers.
Python
20
star
63

openshift-quantum-operators

Jupyter Notebook
19
star
64

qiskit-camp-europe-19

18
star
65

qiskit-jku-provider

A local provider which allows Qiskit to use a decision-diagrams quantum simulator from JKU
C++
18
star
66

qiskit-nature-pyscf

Documentation at https://qiskit-community.github.io/qiskit-nature-pyscf/
Python
18
star
67

subgraph-isomorphism

A quantum algorithm for the subgraph isomorphism problem
Python
17
star
68

monodromy

Computations in the monodromy polytope for quantum gate sets
Python
17
star
69

qiskit-qubit-reuse

A Qiskit transpiler stage plugin to enable qubit reuse via mid-circuit measurement and reset.
Python
17
star
70

qiskit_rng

Quantum random number generator with CQC extractor
Python
16
star
71

korean-community

Jupyter Notebook
16
star
72

qiskit-aqua-interfaces

qiskit-aqua-interfaces provides command-line and graphical interfaces for executing experiments using Qiskit Aqua.
Python
16
star
73

qiskit-camp-africa-19

Qiskit Camp Africa - December 11-14, 2019
15
star
74

qiskit-alt

High-performance Qiskit features backed by Julia. A Python front end to algorithms using Pauli and Fermionic operators implemented in Julia.
Python
13
star
75

qiskit-summer-jam-20

12
star
76

quantum-algorithms-benchmarks

Jupyter Notebook
12
star
77

qiskit-hackathon-singapore-19

11
star
78

community.qiskit.org

Home of the Qiskit Community
HTML
11
star
79

qiskit-hackathon-bilbao-19

Main repository for the Quantum Hackathon in Bilbao
10
star
80

quantum-fridays

Jupyter Notebook
10
star
81

repo-monitor

Python
9
star
82

mzm-phase-boundary

This repository contains the code and data from the manuscript "Simulating spectroscopic detection of Majorana zero modes with a superconducting quantum computer."
Jupyter Notebook
9
star
83

qiskit-benchmarks

A performance comparinson of Qiskit contributions
Python
8
star
84

QCHack-2022

8
star
85

qiskit.camp

Qiskit.camp 19 - Bringing together the Qiskit community
CSS
8
star
86

may4_challenge

Happy birthday IQX
Python
7
star
87

dsm-swap

A doubly stochastic matrices-based approach to optimal qubit routing
Python
7
star
88

Qiskit-runtime-primitives-with-MATLAB

Qiskit Runtime Primitives through Matlab
MATLAB
7
star
89

arraylias

A Python library for automatic aliasing of multiple array libraries
Python
7
star
90

qiskit-toqm

Qiskit Terra transpiler passes for the Time-Optimal Qubit Mapping (TOQM) algorithm.
Python
7
star
91

Qiskit-Hackathon-at-World-of-QUANTUM

Jupyter Notebook
6
star
92

quantum-hackathon-korea-22

6
star
93

archiver4qiskit

Tools to help record data from Qiskit jobs
Python
5
star
94

qiskit-quimb

Simulate Qiskit circuits using quimb.
Python
5
star
95

qiskit-nature-psi4

Python
5
star
96

QiskitUnityAsset

Qiskit Unity Asset official repository
C#
5
star
97

qiskit-translations-staging

Home of Staging Site of Qiskit Documentation Translations
5
star
98

qiskit-vue

Qiskit components library for Vue.
HTML
5
star
99

Qiskit-Resources

A curated list of all the Qiskit Resources in a single place
5
star
100

qiskit-bip-mapper

Qiskit transpiler plugin for BIP Mapping routing pass
Python
5
star