A Python implementation of quantum particle swarm optimization (QPSO).
Project description
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
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 qpso-0.0.1.tar.gz.
File metadata
- Download URL: qpso-0.0.1.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec94246bfce5c1d7679ddd1b28c5170a8fb5d0b630605683e571cbcf0e2c88c5
|
|
| MD5 |
00ad57a1a18c9d1a83fa20e9cb93eb28
|
|
| BLAKE2b-256 |
2e0dbb91d3d5b142873f011bbb9afff1683a0ea83ecb3f7e080d680003e28f50
|
File details
Details for the file qpso-0.0.1-py3-none-any.whl.
File metadata
- Download URL: qpso-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c9cd1162335d1fedcfec8132c2813c88c81f8d4507128a25d1f4cb31f76dab3
|
|
| MD5 |
91f38864957db6703e5acffb006d8866
|
|
| BLAKE2b-256 |
c79fb3f491c02b35d6109c623363c397c689702c7b3678044c122b7ef5db620d
|