A simple Artificial Bee Colony (ABC) library for Python.
Project description
: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
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 beecol-0.1.0.tar.gz.
File metadata
- Download URL: beecol-0.1.0.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78fe64f0c4918b73bf236ca99aa8ad393324a74e9b2685e4160dc3ee34ec382c
|
|
| MD5 |
ee9afe5c6c1ea6981eaf4491cf9111f7
|
|
| BLAKE2b-256 |
b28e6267ff5ecca4a11b6dba29dc5735a4f19d01404a50160982e79bb026bb88
|
File details
Details for the file beecol-0.1.0-py3-none-any.whl.
File metadata
- Download URL: beecol-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
001dd11ea7f34ff4e1c792ffce05042221602bc382f994845c38da0c930c0736
|
|
| MD5 |
8663a7241a3a4f3a33334461a51db572
|
|
| BLAKE2b-256 |
1bbb1710302f6f8ded37240c13692c2642dc2f8a26207e831d8c6d864f1261f8
|