qaoalib
Implementations of VQA simulations for combinatorial optimization (mainly with graph and Max-cut).
v0.2 works towards adapting the circuit simulations with new Qiskit primitives: Sampler and Estimator (starting from Qiskit 1.0).
How to install
You can install from the PyPI:
pip install --upgrade qaoalib
Usage
Solving Max-cut with VQE:
import networkx as nx
from qaoalib.solver import VQE
from qiskit_optimization.applications import Maxcut
G = nx.random_regular_graph(3, 6) # 3-regular graph wtih 6 nodes
qp = Maxcut(G).to_quadratic_program()
ansatz = # some preferred ansatz
solver = VQE(qp, ansatz)
result = solver.solve()
print(result)
Usage (legacy)
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()
Metadata
Release files for qaoalib 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| qaoalib-0.3.1.tar.gz | 17.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| qaoalib-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 40.5 kB
Release files / qaoalib-0.3.1.tar.gz
| Download URL | qaoalib-0.3.1.tar.gz |
|---|---|
| Size | 17.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dbb573190f67218bdabcfcac9c7b6008ad1cd36ec1ffa399724cf4a2e2490b07
|
|
BLAKE2b-256 checksum How to use checksums |
9079ef4dfae5846b1390c6f434bd9438c4ce5a2edba253935e04ef93136e08d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.4
|
Release files / qaoalib-0.3.1-py3-none-any.whl
| Download URL | qaoalib-0.3.1-py3-none-any.whl |
|---|---|
| Size | 22.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
acb0c8930fa235adbac2a27d00d9263ff34aee8e939eb9c153f61214a8d13423
|
|
BLAKE2b-256 checksum How to use checksums |
fd961e6ce2b272123a7da6f76d7759236059f40fe8b9b52858b77e0c6bce9b78
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.4
|