Implementation of Firefly Algorithm in Python
Project description
Firefly Algorithm --- Implementation of Firefly algorithm in Python
📋 About • 📦 Installation • 🚀 Usage • 📚 Reference Papers • 📄 Cite us • 🔑 License
📋 About
This package implements a nature-inspired algorithm for optimization called Firefly Algorithm (FA) in Python programming language. 🌿🔍💻
📦 Installation
To install FireflyAlgorithm with pip, use:
pip install fireflyalgorithm
To install FireflyAlgorithm on Fedora, use:
dnf install python-fireflyalgorithm
To install FireflyAlgorithm on Arch Linux, please use an AUR helper:
$ yay -Syyu python-fireflyalgorithm
To install FireflyAlgorithm on Alpine Linux, use:
$ apk add py3-fireflyalgorithm
🚀 Usage
from fireflyalgorithm import FireflyAlgorithm
from fireflyalgorithm.problems import sphere
FA = FireflyAlgorithm()
best = FA.run(function=sphere, dim=10, lb=-5, ub=5, max_evals=10000)
print(best)
Test functions 📈
In the fireflyalgorithm.problems
module, you can find the implementations of 33 popular optimization test problems. Additionally, the module provides a utility function, get_problem
, that allows you to retrieve a specific optimization problem function by providing its name as a string:
from fireflyalgorithm.problems import get_problem
# same as from fireflyalgorithm.problems import rosenbrock
rosenbrock = get_problem('rosenbrock')
For more information about the implemented test functions, click here.
Command line interface 🖥️
The package also comes with a simple command line interface which allows you to evaluate the algorithm on several popular test functions. 🔬
firefly-algorithm -h
usage: firefly-algorithm [-h] --problem PROBLEM -d DIMENSION -l LOWER -u UPPER -nfes MAX_EVALS [-r RUNS] [--pop-size POP_SIZE] [--alpha ALPHA] [--beta-min BETA_MIN] [--gamma GAMMA] [--seed SEED]
Evaluate the Firefly Algorithm on one or more test functions
options:
-h, --help show this help message and exit
--problem PROBLEM Test problem to evaluate
-d DIMENSION, --dimension DIMENSION
Dimension of the problem
-l LOWER, --lower LOWER
Lower bounds of the problem
-u UPPER, --upper UPPER
Upper bounds of the problem
-nfes MAX_EVALS, --max-evals MAX_EVALS
Max number of fitness function evaluations
-r RUNS, --runs RUNS Number of runs of the algorithm
--pop-size POP_SIZE Population size
--alpha ALPHA Randomness strength
--beta-min BETA_MIN Attractiveness constant
--gamma GAMMA Absorption coefficient
--seed SEED Seed for the random number generator
Note: The CLI script can also run as a python module (python -m fireflyalgorithm ...).
📚 Reference Papers
I. Fister Jr., X.-S. Yang, I. Fister, J. Brest, D. Fister. A Brief Review of Nature-Inspired Algorithms for Optimization. Elektrotehniški vestnik, 80(3), 116-122, 2013.
I. Fister Jr., X.-S. Yang, I. Fister, J. Brest. Memetic firefly algorithm for combinatorial optimization in Bioinspired Optimization Methods and their Applications (BIOMA 2012), B. Filipic and J.Silc, Eds. Jozef Stefan Institute, Ljubljana, Slovenia, 2012
I. Fister, I. Fister Jr., X.-S. Yang, J. Brest. A comprehensive review of firefly algorithms. Swarm and Evolutionary Computation 13 (2013): 34-46.
📄 Cite us
Fister Jr., I., Pečnik, L., & Stupan, Ž. (2023). firefly-cpp/FireflyAlgorithm: 0.4.3 (0.4.3). Zenodo. https://doi.org/10.5281/zenodo.10430919
🔑 License
This package is distributed under the MIT License. This license can be found online at http://www.opensource.org/licenses/MIT.
Disclaimer
This framework is provided as-is, and there are no guarantees that it fits your purposes or that it is bug-free. Use it at your own risk!
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
File details
Details for the file fireflyalgorithm-0.4.5.tar.gz
.
File metadata
- Download URL: fireflyalgorithm-0.4.5.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.4 Linux/6.9.12-200.fc40.x86_64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0175e8281d31790a586bba04c4e0bb91769bd03dae3de74a4bfefba6c05eddc |
|
MD5 | df9f91c4b46c0e4d56ef30433a98b176 |
|
BLAKE2b-256 | 945f4a768db4574cb6a12e793dd7d2a73a6263617b52bc3722ad471f59e628ea |
File details
Details for the file fireflyalgorithm-0.4.5-py3-none-any.whl
.
File metadata
- Download URL: fireflyalgorithm-0.4.5-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.4 Linux/6.9.12-200.fc40.x86_64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3473dd2fe30d9d4789a7c4eb78b09c528e2a87b4a9ca7af543c4f1ac00ac27c1 |
|
MD5 | 4d5090d907966b3ce19ef3563616d98d |
|
BLAKE2b-256 | ef74671611987d702f43fbebe770706691eac48ba7fb90c9fd824f885f3b8b57 |