A research toolkit for the Bees algorithm in Python
Project description
pybees: Python optimization toolkit using the bees algorithm
What is it?
pybees is a Python package for function optimization. It uses the nature inspired bees algorithm, proposed by Pham et al. and is built on top of SciPy. pybees is distributed under the 3-Clause BSD license.
The bees algorithm is a swarm based search algorithm, which mimics the food foraging behaviour of honey bees. The basic algorithm is suitable for both continuous and combinatorial optimization problems, which is demonstrated in the basic examples section.
Main features
-
High-level API to optimize continuous functions (training a multilayer perceptron).
-
High-level API to optimize discrete functions (traveling salesperson problem).
-
Built in single-objective cost functions.
-
plotly plotting tools for 2D and 3D (both continuous and discrete).
-
Extensible API for developing new ideas.
Where to get it
If all dependencies are already installed, then the easiest way to install pybees is using pip.
pip install pybees
How to use it
Please visit the examples folder to view the demonstration examples. These include.
- Continuous function optimization (levy, drop_wave and michalewicz)
- Combinatorial function optimization (travelling salesperson problem)
Future examples will include
- Multilayer perceptron
Dependencies
pybees requires:
- numpy >= 1.17.4
- scipy >= 1.3.2
- plotly >= 4.4.1
- tqdm >= 4.40.2
- sklearn >= 0.22
- pandas >= 0.25.3
License
Basic Examples
Continuous function optimization
import pybees as pb
sbc = pb.SimpleBeesContinuous(
n_scout_bees = 50,
elite_site_params = (15, 40),
best_site_params = (15, 30),
bounds = (-10,10),
n_dim = 2,
nbhd_radius = 2
)
This operation returns a scipy.optimize.OptimizeResult. fun represents the value of the objective function (lowest point). nit represents the number of iterations taken. x represents the coordinates of the value found for the objective function.
>>> sbc.optimize(pb.levy)
fun: 1.007063464503951e-06
nit: 100
x: array([0.99905553, 0.99967304])
The results may also be visualised by using the following
sbc.plot(global_min = (1, 1))
Combinatorial optimization (e.g. travelling salesperson problem)
import pybees as pb
sbd = pb.SimpleBeesDiscrete(
n_scout_bees = 50,
elite_site_params = (15, 40),
best_site_params = (15, 30),
coordinates = np.random.randint(10, size=[10, 2])
)
This operation returns a scipy.optimize.OptimizeResult result. res.coordinates represents sbd.coordinates reordered, resulting from the optimization of some objective function. In this example, tour_distance was minimized. As such, coordinates represents the sequence, corresponding to the shortest path between all coordinates (i.e. travelling salesperson problem). fun represents the value of the objective function (shortest distance). nit represents the number of iterations taken. x represents the permutation of the original sequence passed to SimpleBeesDiscrete which gives the shortest distance.
>>> sbd.optimize(pb.tour_distance)
coordinates: array([
[7., 8.],
[4., 8.],
[2., 6.],
[0., 5.],
[1., 0.],
[3., 2.],
[2., 4.],
[3., 4.],
[5., 4.],
[7., 4.]])
fun: 27.228009718084742
nit: 100
x: array([1., 9., 7., 5., 0., 3., 4., 6., 2., 8.])
The results may also be visualised by using the following
sbd.plot()
Project details
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 pybees-0.0.4.tar.gz.
File metadata
- Download URL: pybees-0.0.4.tar.gz
- Upload date:
- Size: 29.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7c22142f9fdcde81acb1809770e71ab2de221e235ddc54aeef501412bfe0c1e
|
|
| MD5 |
8454fcbf1a5c9d3c41c1e1fa404e0c34
|
|
| BLAKE2b-256 |
e5813bc5b5916a0e22c4b798236c0342535be6096c6fb150bc22a6e4ce7e910b
|
File details
Details for the file pybees-0.0.4-py3-none-any.whl.
File metadata
- Download URL: pybees-0.0.4-py3-none-any.whl
- Upload date:
- Size: 37.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2331969044cda9eca344bcadd4af88e000b11dc7b72ed44faebaf4de23414170
|
|
| MD5 |
a29cd9b01a33d30ac2ad2f94d36f976c
|
|
| BLAKE2b-256 |
3482a6de5458cf005a2747ab366d361b74076b012f1bf1bd89f79a9812a48081
|