Quantum-inspired genetic and evolutionary algorithms for combinatorial optimization.
Project description
qga-py
Quantum-inspired genetic and evolutionary algorithms for combinatorial optimization on classical computers.
This project does not require quantum hardware. It implements practical quantum-inspired optimizers that maintain probability amplitudes or probability-like distributions, sample candidate solutions, evaluate them, and update the distributions toward better solutions.
Installation
For local development:
pip install -e ".[dev]"
After publishing:
pip install qga-py
Usage
Binary optimization:
from qga import BinaryQGA
def fitness(bits, _):
return bits.sum()
optimizer = BinaryQGA(
genome_length=100,
population_size=20,
generations=200,
fitness_func=fitness,
)
result = optimizer.run()
print(result.best_solution, result.best_fitness)
Permutation optimization:
from qga import PermutationQGA
def fitness(route, distance):
length = sum(distance[route[i - 1], route[i]] for i in range(len(route)))
return -length
optimizer = PermutationQGA(
n_items=20,
population_size=40,
generations=300,
fitness_func=fitness,
fitness_inputs=distance,
)
result = optimizer.run()
print(result.best_solution, result.best_fitness)
Included Examples
examples/knapsack_demo.pyexamples/tsp_demo.py
Publishing Checklist
- Update the project URLs in
pyproject.toml. - Run tests with
pytest. - Build with
python -m build. - Upload to TestPyPI first with
python -m twine upload --repository testpypi dist/*. - Install from TestPyPI and verify imports.
- Upload to PyPI with
python -m twine upload dist/*.
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qga_py-0.1.0.tar.gz.
File metadata
- Download URL: qga_py-0.1.0.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6317e67766b1893c119519a18343b7fc0a28753a2d18b4d497e7eb705f4936e
|
|
| MD5 |
59231a9a4bcf72ca20b7c43f1cef6917
|
|
| BLAKE2b-256 |
f9a96056d3ad914817756307fa3cac5f655cf09d1662aebbe606b04b7b6e7d71
|
Provenance
The following attestation bundles were made for qga_py-0.1.0.tar.gz:
Publisher:
publish.yml on williamzpn/qga-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qga_py-0.1.0.tar.gz -
Subject digest:
d6317e67766b1893c119519a18343b7fc0a28753a2d18b4d497e7eb705f4936e - Sigstore transparency entry: 1734975299
- Sigstore integration time:
-
Permalink:
williamzpn/qga-py@818ddb83a8271e0c9ba87254d452eed42f96087d -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/williamzpn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@818ddb83a8271e0c9ba87254d452eed42f96087d -
Trigger Event:
push
-
Statement type:
File details
Details for the file qga_py-0.1.0-py3-none-any.whl.
File metadata
- Download URL: qga_py-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39dec1520765c82ee0907d3c3185cbd771f54e5f5263437a02145296260c5cdd
|
|
| MD5 |
658c78f5263b37eb2b9308991d8ae4a6
|
|
| BLAKE2b-256 |
75578dcaa92a7e716105d0ecd3e13fb40ad952114f37755a511c6ef81dc19851
|
Provenance
The following attestation bundles were made for qga_py-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on williamzpn/qga-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qga_py-0.1.0-py3-none-any.whl -
Subject digest:
39dec1520765c82ee0907d3c3185cbd771f54e5f5263437a02145296260c5cdd - Sigstore transparency entry: 1734975571
- Sigstore integration time:
-
Permalink:
williamzpn/qga-py@818ddb83a8271e0c9ba87254d452eed42f96087d -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/williamzpn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@818ddb83a8271e0c9ba87254d452eed42f96087d -
Trigger Event:
push
-
Statement type: