qpso
A Python implementation of quantum particle swarm optimization (QPSO).
pip install qpso
This is a black-box optimization package built upon the quantum paricle swarm optimization [1].
Quickstart
The usage of this package is very simple. For example, the following code shows how to solve a 10-dimensional opmitzation problem by using QPSO with Delta potential well (QDPSO) proposed in [1].
import numpy as np
from qpso import QDPSO
def sphere(args):
f = sum([np.power(x, 2.) for x in args])
return f
def log(s):
best_value = [p.best_value for p in s.particles()]
best_value_avg = np.mean(best_value)
best_value_std = np.std(best_value)
print("{0: >5} {1: >9} {2: >9} {3: >9}".format("Iters.", "Best", "Best(Mean)", "Best(STD)"))
print("{0: >5} {1: >9.3E} {2: >9.3E} {3: >9.3E}".format(s.iters, s.gbest_value, best_value_avg, best_value_std))
NParticle = 40
MaxIters = 1000
NDim = 10
bounds = [(-2.56, 5.12) for i in range(0, NDim)]
g = 0.96
s = QDPSO(sphere, NParticle, NDim, bounds, MaxIters, g)
s.update(callback=log, interval=100)
print("Found best position: {0}".format(s.gbest))
Bibliography
[1] Jun Sun, Bin Feng and Wenbo Xu, "Particle swarm optimization with particles having quantum behavior," Proceedings of the 2004 Congress on Evolutionary Computation (IEEE Cat. No.04TH8753), Portland, OR, USA, 2004, pp. 325-331 Vol.1. doi: 10.1109/CEC.2004.1330875
Metadata
Release files for qpso 0.0.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 | Provenance | |
|---|---|---|---|---|
| qpso-0.0.1.tar.gz | 3.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| qpso-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.3 kB
Release files / qpso-0.0.1.tar.gz
| Download URL | qpso-0.0.1.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ec94246bfce5c1d7679ddd1b28c5170a8fb5d0b630605683e571cbcf0e2c88c5
|
|
BLAKE2b-256 checksum How to use checksums |
2e0dbb91d3d5b142873f011bbb9afff1683a0ea83ecb3f7e080d680003e28f50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
|
Release files / qpso-0.0.1-py3-none-any.whl
| Download URL | qpso-0.0.1-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4c9cd1162335d1fedcfec8132c2813c88c81f8d4507128a25d1f4cb31f76dab3
|
|
BLAKE2b-256 checksum How to use checksums |
c79fb3f491c02b35d6109c623363c397c689702c7b3678044c122b7ef5db620d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
|
Security for qpso 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.