Skip to main content

Bat algorithm implementation

Project description

Bat Algorithm in Python


The main objective is to create an implementation of bat algorithm in Python programming language.


pip install BatAlgorithm


The following example presents a simple use of bat algorithm. Fun() denotes the objective function that may be changed by the user. Control parameters should be defined within BatAlgorithm() constructor. Order of parameters is as follows: BatAlgorithm(D, NP, N_Gen, A, r, Qmin, Qmax, Lower, Upper, function) where:

  • D denotes dimension of the problem,
  • NP denotes population size,
  • N_Gen denotes number of generations (iterations),
  • A parameter denotes loudness,
  • r parameter denotes pulse rate,
  • Qmin parameter denotes frequency minimum,
  • Qmax parameter denotes frequency maximum,
  • Lower denotes lower bound,
  • Upper denotes upper bound and
  • function passes objective function.


import random
from BatAlgorithm import *

def Fun(D, sol):
    val = 0.0
    for i in range(D):
        val = val + sol[i] * sol[i]
    return val

# For reproducive results

for i in range(10):
    Algorithm = BatAlgorithm(10, 40, 1000, 0.5, 0.5, 0.0, 2.0, -10.0, 10.0, Fun)


Bugs and extension should be send via Github.


Iztok Fister Jr. and Marko Burjek


Yang, X.-S. "A new metaheuristic bat-inspired algorithm." Nature inspired cooperative strategies for optimization (NICSO 2010). Springer Berlin Heidelberg, 2010. 65-74.

Fister, I. Jr., Fister, I., Yang, X.-S., Fong, S., Zhuang, Y. "Bat algorithm: Recent advances." IEEE 15th International Symposium on Computational Intelligence and Informatics (CINTI), IEEE, 2014. 163-167.

Project details

Download files

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

Files for BatAlgorithm, version 0.3.1
Filename, size & hash File type Python version Upload date
BatAlgorithm-0.3.1.tar.gz (3.0 kB) View hashes Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page