Skip to main content

Implementation of Firefly Algorithm in Python

Project description


Firefly Algorithm --- Implementation of Firefly algorithm in Python


PyPI Version PyPI - Python Version PyPI - Downloads Downloads AUR package GitHub license GitHub commit activity Average time to resolve an issue Percentage of issues still open GitHub contributors

About 📋

This package implements a nature-inspired algorithm for optimization called Firefly Algorithm (FA) in Python programming language. 🌿🔍💻

Installation 📦

Install FireflyAlgorithm with pip:

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:

$ 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. 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.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fireflyalgorithm-0.4.2.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fireflyalgorithm-0.4.2-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file fireflyalgorithm-0.4.2.tar.gz.

File metadata

  • Download URL: fireflyalgorithm-0.4.2.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.12.0 Linux/6.6.3-200.fc39.x86_64

File hashes

Hashes for fireflyalgorithm-0.4.2.tar.gz
Algorithm Hash digest
SHA256 5809de8ad09533e5370bf03453f851be6979593b7e081be023b9bd7a63f8b754
MD5 9232aae636d73d7f0fb81d6b556d69eb
BLAKE2b-256 3637b4ee040cc8dd2cd9826129d4a1b518ae6273f078f78e787370d5f56d56d6

See more details on using hashes here.

File details

Details for the file fireflyalgorithm-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: fireflyalgorithm-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.12.0 Linux/6.6.3-200.fc39.x86_64

File hashes

Hashes for fireflyalgorithm-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1c1e520621e8922d4c0a2905c6eba4dd4a2cf152b08189fd6b3953e2fda81cd4
MD5 8cc9da6a05d192a466c6a1e70649376a
BLAKE2b-256 46a339ef6577b591f8766666d764d5b3293a9690adde676638e760458611878d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page