:bee: beecol
A simple Artificial Bee Colony (ABC) algorithm library for Python.
Features
- Pure Python implementation of the Artificial Bee Colony (ABC) algorithm
- Simple API for continuous optimization problems
- Easily extensible and customizable
- Only dependency:
numpy
Installation
pip install beecol
Or clone this repository and use locally:
git clone https://github.com/atasoglu/beecol.git
cd beecol
pip install .
Usage
import numpy as np
from beecol import ArtificialBeeColony
# Define your fitness function (to maximize)
def fit_func(x):
# Example: Sphere function (min at 0, but ABC maximizes, so use negative)
return -np.sum(x**2)
# Set up the optimizer
abc = ArtificialBeeColony(
fit_func=fit_func,
dim=5, # Number of parameters
bounds=(-5, 5), # Search space bounds
n_bees=20, # Number of bees (food sources)
)
# Run optimization
for i in range(100):
best_solution, best_fitness = abc.step()
print(f"Iteration {i}: Best fitness = {best_fitness}")
print("Best solution found:", best_solution)
Example: Knapsack Problem
A full example is provided in examples/knapsack.py, including plotting and a custom fitness function for the 0/1 knapsack problem.
To run:
cd examples
python knapsack.py
Citation
- Karaboga, D., & Basturk, B. (2007). A powerful and efficient algorithm for numerical function optimization: artificial bee colony (ABC) algorithm. Journal of Global Optimization, 39(3), 459–471.
- Karaboga, D., & Basturk, B. (2007). Artificial Bee Colony (ABC) optimization algorithm for solving constrained optimization problems. In Foundations of Fuzzy Logic and Soft Computing, LNCS 4529, 789–798.
Contributing
Contributions are welcome! Feel free to open issues or submit pull requests to help improve pygena.
License
MIT
Metadata
Release files for beecol 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| beecol-0.1.0.tar.gz | 5.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| beecol-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.6 kB
Release files / beecol-0.1.0.tar.gz
| Download URL | beecol-0.1.0.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
78fe64f0c4918b73bf236ca99aa8ad393324a74e9b2685e4160dc3ee34ec382c
|
|
BLAKE2b-256 checksum How to use checksums |
b28e6267ff5ecca4a11b6dba29dc5735a4f19d01404a50160982e79bb026bb88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.7
|
Release files / beecol-0.1.0-py3-none-any.whl
| Download URL | beecol-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
001dd11ea7f34ff4e1c792ffce05042221602bc382f994845c38da0c930c0736
|
|
BLAKE2b-256 checksum How to use checksums |
1bbb1710302f6f8ded37240c13692c2642dc2f8a26207e831d8c6d864f1261f8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.7
|