See discussions, stats, and author profiles for this publication at: [Link]
net/publication/340540442
The Bat Algorithm: An Introduction
Presentation · April 2020
CITATIONS READS
2 1,534
1 author:
Xin-She Yang
Middlesex University
633 PUBLICATIONS 78,614 CITATIONS
SEE PROFILE
All content following this page was uploaded by Xin-She Yang on 10 April 2020.
The user has requested enhancement of the downloaded file.
The Bat Algorithm: An Introduction
Xin-She Yang
Middlesex University London
For details, please read my book:
Nature-Inspired Optimization Algorithms, Elsevier, (2014).
Matlab codes are downloadable from
[Link]
Xin-She Yang Book/Slides 1 / 15
Bat Algorithm Almost Everything is Optimization
Almost Everything is Optimization
Almost everything is optimization ... or needs optimization ...
Maximize efficiency, accuracy, profit, performance, sustainability, ...
Minimize costs, wastage, energy consumption, travel distance/time,
CO2 emission, impact on environment, ...
Mathematical Optimization
Objectives: maximize or minimize f (x) = [f1 (x), f2 (x), ..., fm (x)],
x = (x1 , x2 , ..., xD ) ∈ RD ,
subject to multiple equality and/or inequality design constraints:
hi (x) = 0, (i = 1, 2, ..., M ),
gj (x) ≤ 0, (j = 1, 2, ..., N ).
In case of m = 1, it becomes a single-objective optimization problem.
Xin-She Yang Book/Slides 2 / 15
Bat Algorithm
Optimization problems can usually be very difficult to solve, especially large-scale,
nonlinear, multimodal problems.
In general, we can solve only 3 types of optimization problems:
Linear programming
Convex optimization
Problems that can be converted into the above two
Everything else seems difficult, especially for large-scale problems.
For example, combinatorial problems tend to be really hard – NP-hard!
Deep Learning
The objective in deep nets may be convex, but the domain is not convex and it’s a
high-dimensional problem.
n i2
1 Xh
Minimize E(w) = ui (xi , w) − ȳi ,
n i=1
subject to various constraints.
Xin-She Yang Book/Slides 3 / 15
Bat Algorithm Key Components for Optimization
Key Components for Optimization
Algorithm
Select Handle
Optimization
Solutions Constraints
Evaluate
Objectives
Xin-She Yang Book/Slides 4 / 15
Optimization Techniques Optimization Techniques
Optimization Techniques
There are a wide spectrum of optimization techniques and tools.
Traditional techniques
Linear programming (LP) and mixed integer programming.
Convex optimization and quadratic programming.
Nonlinear programming: Newton’s method, trust-region method, interior
point method, ..., barrier Method, ... etc.
But most real-world problems are not linear or convex, thus traditional techniques
often struggle to cope, or simply do not work...
New Trends – Nature-Inspired Metaheuristic Approaches
Evolutionary algorithms (evolutionary strategy, genetic algorithms)
Swarm intelligence (e.g., ant colony optimization, particle swarm
optimization, firefly algorithm, cuckoo search, ...)
Stochastic, population-based, nature-inspired optimization algorithms
Xin-She Yang Book/Slides 5 / 15
The Essence of an Algorithm The Essence of an Algorithm
The Essence of an Algorithm
Essence of an Optimization Algorithm
To generate a better solution point x(t+1) (a solution vector) from an existing
solution x(t) . That is, x(t+1) = A(x(t) , α) where α is a set of parameters.
x(1)
x(t)
?
x(0) x(t+1)
Population-based algorithms use multiple, interacting paths.
Different algorithms
Different ways for generating new solutions!
Xin-She Yang Book/Slides 6 / 15
The Essence of an Algorithm Main Problems with Traditional Algorithms
Main Problems with Traditional Algorithms
What’s Wrong with Traditional Algorithms?
Traditional algorithms are mostly local search, thus they cannot guarantee
global optimality (except for linear and convex optimization).
Results often depend on the initial starting points (except linear and convex
problems). Methods tend to be problem-specific (e.g., k-opt, branch and
bound).
Struggle to cope problems with discontinuity.
Nature-Inspired Optimization Algorithms
Heuristic or metaheuristic algorithms (e.g., ant colony optimization, particle
swarm optimization, firefly algorithm, bat algorithm, cuckoo search, differential
evolution, flower pollination algorithm, etc) tend to be a global optimizer so as to
Increase the probability of finding the global optimality (as a global optimizer)
Solve a wider class of problems (treating them as a black-box)
Draw inspiration from nature (e.g., swarm intelligence)
But they can be potentially more computationally expensive.
Xin-She Yang Book/Slides 7 / 15
The Essence of an Algorithm Bat Algorithm (Yang, 2010)
Bat Algorithm (Yang, 2010)
BBC Video at Youtube [Click to start]
Microbats use echolocation for hunting
Ultrasonic short pulses as loud as 110dB with a short period of 5 to 20 ms.
Frequencies of 25 kHz to 100 kHz.
Bats usually speed up their pulse-emission rate and increase their loudness when
homing at a prey.
Frequencies are varied/tuned so as to increase the detection resolution (by reducing
wavelengths of the signals).
Xin-She Yang, A new metaheuristic bat-inspired algorithm, Nature-Inspired Cooperative Strategies for
Optimization (NICSO 2010), pp. 65-74, Springer.
Xin-She Yang Book/Slides 8 / 15
The Essence of an Algorithm
Sound velocity (v) = frequency (f ) × wavelength (λ). So λ = v/f ∼ 2 mm to 14 mm.
Echolocation of Microbats and Idealization (Yang, 2010)
All bats use echolocation to sense distance, and they also “know” the direction of
the food/prey.
Bats fly randomly with velocity v i at position xi . They can automatically adjust
the frequency (or wavelength) of their emitted pulses and adjust the rate of pulse
emission r ∈ [0, 1], depending on the proximity of their target.
Although the loudness can vary in many ways, we assume that the loudness varies
from a large (positive) A0 to a minimum value Amin .
Search Domain
Bat i with xti
varying fi
Target (e.g., x∗ )
Move towards x∗
Moving with varying A and r
xi is the solution vector (or position of nest i) and x∗ is the current best (target, food).
Xin-She Yang Book/Slides 9 / 15
The Essence of an Algorithm Bat Algorithm
Bat Algorithm
Algorithmic equations
fi = fmin + (fmax − fmin )β, β ∈ [0, 1] (random),
xt+1
i = xti + v t+1
i , v t+1
i = v ti + (xti − x∗ ) fi .
If the switch condition is true (based on rand> ri and rand< Ai ), we have
xnew = x∗ + σ t At
Here, t is a random number in [0,1], and σ is a scaling factor.
x∗ =best solution found so far. At is the averaged loudness.
Variations of Loudness (A) and Pulse Rate (r)
At+1
i = αAti , α ∈ (0, 1],
rit+1 = ri0 [1 − exp(−γt)], γ ∈ (0, 1).
Thus, Ati → 0 and rit → r0 as t → ∞.
[X. S. Yang and X. He, Bat Algorithm: Literature Review and Applications, Int. J. Bio-Inspired Computation,
vol.5, no. 3, 141-149 (2013). ]
Xin-She Yang Book/Slides 10 / 15
The Essence of an Algorithm Bat Algorithm Pseudocode
Bat Algorithm Pseudocode
Algorithm 1: Bat algorithm.
Data: Objective functions f (x)
Result: Best or optimal solution
1 Initialize the bat population xi and v i (i = 1, 2, ..., n);
2 Initialize frequencies fi , pulse rates ri and the loudness Ai ;
3 while (t <Max number of iterations) do
4 Generate new solutions by adjusting frequency;
5 Update velocities and locations/solutions;
6 if (rand > ri ) then
7 Select a solution among the best solutions;
8 Generate a local solution around the selected best solution;
9 end
10 Generate a new solution by flying randomly;
11 if (rand < Ai & f (xi ) < f (x∗ )) then
12 Accept the new solutions;
13 Increase ri and reduce Ai ;
14 end
15 Rank the bats and find the current best x∗ ;
16 end
Xin-She Yang Book/Slides 11 / 15
The Essence of an Algorithm
Typical Parameter Values
Population size: n = 20 to 40 (up to 100 if necessary).
Frequency: fmin = 0, fmax = O(1) (typically fmax = 1 or 2).
Loudness: A0 = 1, α = 0.9 to 0.99 (typically α = 0.97).
Pulse emission rate: r0 = 1, γ = 0 to 0.5 (typically γ = 0.1). Scaling: σ = 0.5.
Number of iterations tmax = 100 to 1000.
Demo: Eggcrate Function
f (x, y) = x2 + y 2 + 25(sin2 x + sin2 y), (x, y) ∈ [−2π, 2π]2 .
Optimal solution fmin = 0 at (0, 0).
Bat Algorithm (Demo video at Youtube) [Please click to start]
Xin-She Yang Book/Slides 12 / 15
The Essence of an Algorithm
Beale Function
f (x, y) = (1.5 − x − xy)2 + (2.25 − x + xy 2 )2 + (2.625 − x + xy 3 )2 , (x, y) ∈ [−4.5, 4.5]2 .
Its landscape is relatively flat with fmin = 0 at (3,0.5).
Bat Algorithm (Demo video at Youtube) [Please click to start]
Xin-She Yang Book/Slides 13 / 15
The Essence of an Algorithm Multi-objective Bat Algorithm (MOBA)
Multi-objective Bat Algorithm (MOBA)
For example, the so-called ZDT function with D = 30 dimensions
minimize f1 (x) = x1 , and f2 (x) = g(x)h(x), x ∈ [0, 1]30 ,
where s
D=30
9 X f1 f1
g(x) = 1 + xj , h(x) = 1 − − sin(10πf1 ),
29 j=2 g g
has a nonconvex Pareto front in the domain 0 ≤ xi ≤ 1 where i = 1, 2, ..., 30.
Bat Algorithm (Demo video at Youtube) [Please click to start]
Xin-She Yang Book/Slides 14 / 15
The Essence of an Algorithm Bat Algorithm (Demo Codes) and References
Bat Algorithm (Demo Codes) and References
Bat Algorithm Demo Codes
The standard BA demo in Matlab can be found at the Mathswork File Exchange
[Link]
The multi-objective bat algorithm (MOBA) code is also available at
[Link]
Some References
Xin-She Yang, A new metaheuristic bat-inspired algorithm, in: Nature-Inspired Cooperative Strategies
for Optimization (NICSO 2010), Springer, pp. 65–74 (2010).
Xin-She Yang, Bat algorithm for multi-objective optimisation, Int. J. Bio-Inspired Computation, vol. 3,
no. 5, 267–274 (2011).
Xin-She Yang, Amir Gandomi, Bat algorithm: a novel approach for global engineering optimization,
Engineering Computations, vol. 29, no. 5, 464–483 (2012).
Xin-She Yang, Xingshi He, Bat algorithm: literature review and applications, Int. J. Bio-Inspired
Computation, vol. 5, no. 3, 141–149 (2013).
Xin-She Yang, Cuckoo Search and Firefly Algorithm: Theory and Applications, Springer, (2013).
Xin-She Yang, Nature-Inspired Optimization Algorithms, Elsevier Insights, (2014).
View publication stats
Xin-She Yang Book/Slides 15 / 15