A package for QAOA Maxcut calculations
Project description
qaoalib
A package for QAOA Max-cut Calculations.
Packages required:
- numpy
- networkx
- matplotlib
- qiskit
How to install
You can install from the PyPI:
pip install --upgrade qaoalib
Usage
Calculate Max-cut expectation with Qmc
or QmcFastKron
(faster version):
import networkx as nx
from qaoalib.qaoa import Qmc, QmcFastKron
G = nx.fast_gnp_random_graph(10, 0.5) # Random graph with 10 nodes
params = [0.2, 0.4, 0.3, 0.5] # 4 params, depth = 2
qmc = Qmc(G, params) # or QmcFastKron(G, params)
qmc.run()
print(qmc.expectation)
Plot landscapes of the QAOA Max-cut expectation function:
import networkx as nx
from qaoalib.qaoa.landscape import HybridFast
G = nx.fast_gnp_random_graph(10, 0.5)
prev_params = [0.1, 0.2] # previous parameters (gamma1, beta1)
ins = HybridFast(G, prev_params) # plots the landscape wrt gamma2 and beta2 with previous parameters given.
ins.create_grid()
ins.show_landscape()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
qaoalib-0.2.1.tar.gz
(9.0 kB
view details)
Built Distribution
File details
Details for the file qaoalib-0.2.1.tar.gz
.
File metadata
- Download URL: qaoalib-0.2.1.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c151c63338a7b0f7321d33ba91580b4e8db56e8ce0f9bd7e673ce0f01b049ee |
|
MD5 | 0ce4c489fec1b22445e49179b6540c69 |
|
BLAKE2b-256 | 8b99c19c2d056107f1f5424a26b5ec7fd01cfaa24af40a9564051134352ac5ef |
File details
Details for the file qaoalib-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: qaoalib-0.2.1-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3e81d2914bbb20939882ff0879624cbde8ca14e78322af70cd14f88e435e269 |
|
MD5 | eb922afff5041355a2651b135d724993 |
|
BLAKE2b-256 | ae4b186e384e22a8120d6fd5d06f95bdd072533d7332e05c5da21990c992a230 |