v. testing of our proposed algorithm

advertisement
International Journal of Advanced Computer Engineering and Communication Technology (IJACECT)
_______________________________________________________________________________________________
Solving Numerical Integration Using Firefly Optimization
1
Mithun Roy, 2Debaditya Kundu, 3Subhashis Majumder
1,3
Dept. of Computer Science and Engineering, 2Dept. of Information Technology
1,2
Siliguri Institute of Technology Siliguri, India
3
Heritage Institute of Technology Kolkata, India
Email: 1mathmithunroy@gmail.com, 2debaditya.kundu@gmail.com, 3subhashis.majumder@heritageit.edu
Abstract—Firefly Algorithm is one of the meta-heuristic
algorithms that are capable of performing optimization
quite efficiently. It is a relatively new concept being
inspired by the flashing behavior of fireflies. In this work,
we have used it effectively in calculation of definite
integrals, especially when the integrands have prismitives
that cannot be expressed using elementary functions. Our
application gives results that are more exact than the
results obtained by classical numerical methods even when
the number of intervals used by us is small. Our
implementation takes little time to run and hence can be
used efficiently for practical purposes.
Index Terms—Definite Integral,
Solution Vec-tor, Fitness Function.
Firefly
II. BACKGROUND OF THE PROBLEM
Let f(x) be a continuous function on which we want to
calculate the definite integral I, over the interval [a, b].
𝐛
𝐈(𝐟) = ∫𝐚 𝐟(𝐱) 𝐝𝐱
Let us divide the interval [a, b] into k number of
subintervals each of width 𝐡 = (𝐛 − 𝐚)/𝐡. Let the
intervals be [𝐱 𝟎 , 𝐱 𝟏 ], [𝐱 𝟏 , 𝐱 𝟐 ], … , [𝐱 𝐤−𝟏 , 𝐱 𝐤 ] with 𝐱 𝐫 −
𝐱 𝐫−𝟏 = 𝐡 where 𝟏 ≤ 𝐫 ≤ 𝐤 . According to the definition
of the definite integ-ral we have
𝐛
Algorithm,
I. INTRODUCTION
Definite Integration is the one of the most important tools
that is required in most of the fields like physics,
chemistry and other scientific domains. Exact analytical
calculation of definite integrals is often impossible. Many
𝟐
of the functions like 𝐲 = 𝐞𝐬𝐢𝐧(𝐥𝐨𝐠(𝐱 )) [4] do not have
primitives that can be expressed analytically. By
symbolic integration, it is much more difficult to find out
the exact value of the given integration, there is no
suitable algorithm to solve this problem.
Traditionally, many algorithms are used to calculate
definite integral using classical numerical method.
However, in most of the cases the integrand f(x) is
replaced by a different function g(x) which is easier to
integrate and that is why results are not exact compared
to analytical calculations.
(1)
𝐫
∫𝐚 𝐟(𝐱)𝐝𝐱 = ∑𝐤𝟏 ∫𝐫−𝟏 𝐟(𝐱)𝐝𝐱
(2)
Let F'(x) = f(x). Then the Mean Value Theorem (MVT)
states that there exists c in [a, b] such that
𝐅′(𝐜) or equi-valently 𝐅(𝐛) − 𝐅(𝐚) = 𝐅
which implies
(𝐅(𝐛)−𝐅(𝐚)
(𝐛−𝐚)
′ (𝐜)(𝐛
=
− 𝐚)
𝐛
∫𝐚 𝐟(𝐱)𝐝𝐱 = 𝐟(𝐜)(𝐛 − 𝐚), for some c with 𝐚 ≤ 𝐜 ≤
𝐛 (3)
This is known as the Mean Value Theorem for integrals.
The point f(c) is then called the average value of f(x) on
[a, b].
Let pi be any point in the interval [𝐱 𝐢−𝟏 , 𝐱 𝐢 ] for each i,
then
we
define
the
following
integral
sum 𝐒(𝐩𝟏 , 𝐩𝟐 , … , 𝐩𝐤 )[ 4].
𝐒(𝐩𝟏 , 𝐩𝟐 , … , 𝐩𝐤 ) = ∑𝐤𝟏 𝐟(𝐩𝐢 ) (𝐱 𝐢 − 𝐱 𝐢−𝟏 )
(4)
In this paper, we have proposed a new method for
performing numerical integration, which does not require
the knowledge of the primitive of the integrand as it is
based on the Firefly Algorithm.
III. GEOMETRIC
INTERPRETATION
This is a novel method for performing numerical
integration and it also expands the area of applicability of
Firefly Algorithm, which is generally used for solving
optimization problems.
The integral sum 𝐒(𝐩𝟏 , 𝐩𝟐 , … , 𝐩𝐤 ) represents the area
bounded by the curve y = f(x). Note that we have chosen
a set of ‘k’ random points taking one from each interval.
However it is approximately equal to the value of the
_______________________________________________________________________________________________
ISSN (Print): 2319-2526, Volume-3, Issue-2, 2014
36
International Journal of Advanced Computer Engineering and Communication Technology (IJACECT)
_______________________________________________________________________________________________
definite integral given by equation (1), and the
calculation error does not exceed the
error given by the rectangular method. If another set of
points pi is selected the integral sum will be different but
the approximate value will be still equal to the integral’s
value.
3.
If there are no fireflies brighter than a given
firefly, it will move randomly.
The brightness should be associated with the objective
function. In Proposed Algorithm, we state below our
algorithm to find the value of a Definite Integral
(Single).
For a maximization problem, the brightness can simply
be proportional to the value of the objective function.
Other forms of brightness can be defined in a similar
way to the fitness function in genetic algorithms [4].
B. Fitness Function
Fig. 1. Geometrical representation of the integral sum S
[4]
For large value of N the average value of the integral
sum S’ will converge to the value of the integral (1).
Thus when N tends to infinity [4].
𝐛
∫𝐚 𝐟(𝐱)𝐝𝐱 = 𝐥𝐢𝐦 𝐒 ′ = 𝐥𝐢𝐦
𝐧→∞
𝐧→∞
∑𝐍
𝟏 𝐒𝐍
𝐍
For definition of fitness function, we will calculate the
integrat-ed sum of each solution vector using (4). In an
optimization problem, we want to minimize the
difference between the integrated sum and the value of
the integral (1). If the value of the integral sum S is close
to the average value S′ of all integ-rated sums, then the
objective function is given by equation (5) [4].
So our fitness function F will be
(5)
𝐅(𝐩𝟏 , 𝐩𝟐 , … , 𝐩𝐤 ) = |𝐒(𝐩𝟏 , 𝐩𝟐 , … , 𝐩𝐤 ) − 𝐒′|
(6)
The integral sum S is close to the average sum S′
whereas S is very close to the exact value of the integral
given by equation (1). So we have reduced the problem
of calculation of integral with reasonable accuracy to an
optimization problem of finding some random points
𝐩𝟏 , 𝐩𝟐 , … , 𝐩𝐤 over the interval [xr−1, xr] for each r.
IV. DESCRIPTION OF THE
FIREFLY ALGORITHM
The Firefly Algorithm [1][6] was introduced by Dr. Xin
She yang at Cambridge University in 2007, which was
inspired by the mating or flashing behavior of fireflies.
There are about two thousand fireflies produce short &
rhythmic flashes. The pattern of flashes is often unique
for a particular species. The flashing light produced by a
process of bioluminescence and the true functions of
such signaling systems are still being debated [6].
Although the algorithm has many similarities with other
swarm based algorithms such as Particle Swarm
Optimization [2][8] or Artificial Bee Colony
Optimization [3], the Firefly Algorithm has proved to be
much simpler both in concept and implementation and
hence has been accepted by the community as a
worthwhile optimization technique.
A. Concept
In Firefly Algorithm, there are three idealized rules:
1. A firefly will be attracted by to all other fireflies
regardless of their sex.
2. Attractiveness is proportional to their brightness
and
brightness decreases as the distance among them
increases.
Where S' is the average sum (depends on number of
solution vectors, that is number of fireflies) of all the
integrated sums (depends on each solution vector).The
algorithm stops when the leading firefly does not change
during several moves.
Proposed Algorithm:
𝐛
Solving ∫𝐚 𝐟(𝐱)𝐝𝐱 using Firefly optimization
Input: y = f(x), Lower limit, Upper limit, Number of
Intervals
Define the objective function
𝐈 = 𝐅(𝐩𝟏 , 𝐩𝟐 , … , 𝐩𝐤 ) = |𝐒(𝐩𝟏 , 𝐩𝟐 , … , 𝐩𝐤 ) − 𝐒′|
Compute width of the each interval.
Initialize the N solution vectors and each vector has k
random points between each interval.
Set the all required parameters such as α, γ, δ
while (t ≤ MaxGeneration) do
i=1
while (i ≤ N) do
j=1
while (j ≤ N) do
Calculate the distance between two fireflies.
if (Ii <Ij ) then
Calculate the variation of the distance.
Update the solution vector.
end if
end while
end while
Evaluate new solutions and update light intensity.
Rank the fireflies and find the current best.
end while
Calculate the definite integral value for the best solution
vector.
_______________________________________________________________________________________________
ISSN (Print): 2319-2526, Volume-3, Issue-2, 2014
37
International Journal of Advanced Computer Engineering and Communication Technology (IJACECT)
_______________________________________________________________________________________________
C. Initial Solution Vector
The solution is the ordered set of k points within interval
(𝐛−𝐚)
[a, b] and the length of the each interval 𝐡 =
. It is
𝐤
important that there is only one point pi lying in the
interval [xi−1, xi] for each i where 1 ≤ i ≤ k.
.
Fig. 2. Initial solution vector
So each solution vector is a sequence of k numbers, such
as p1, p2, ..., pk.
D. Formulation of the Light Intensity and Attractiveness
We formulate the light intensity I as the objective
function F. In our case, we assume I = F, i.e. equation
(6).
In the Firefly Algorithm, there are two important issues
including variation of light intensity and the formulation
of the attractiveness [5]. We know, the light intensity
varies acco-rding to the inverse square law, i.e.
𝐈(𝐫) =
𝐈𝐒
where I(r) is the light intensity at a distance r and Is is the
intensity at the source. To avoid the singularity at r = 0 in
equation (7) [5], the equations can be approximated in
the following Gaussian form:
𝐈(𝐫) = 𝐈𝟎 𝐞−𝛄𝐫
𝟐
(8)
As we know, that the attractiveness of a firefly is
proportional to the light intensity seen by adjacent
fireflies, the attractiveness β of a firefly is determined by
equation (9) where β0 is the attractiveness at r = 0 and γ
is the light absorption coefficient at the source [5].
𝟐
𝛃 = 𝛃𝟎 𝐞−𝛄𝐫 , 𝐫 ≥ 𝟏
(9)
E. Distance
The Cartesian distance between any two fireflies i and j
present at xi and xj respectively is determined by
equation (10) [5].
𝐫𝐢,𝐣 = √∑𝐍𝐤=𝟏(𝐱 𝐢,𝐤 − 𝐱 𝐣,𝐤 )𝟐
G. Convergence
For any large number of fireflies N, if N > M, where M
is the number of local optima of an optimization
problem, the convergence of the algorithm can be
achieved. Here, the initial location of N fireflies is
distributed uniformly in the entire search space [1][6].
As the iterations of the algorithm conti-nue, fireflies
converge into all the local optima. By compare-ing the
best solutions among all these optima, the global optimum can be achieved.
V. TESTING OF OUR PROPOSED
ALGORITHM
The quality of result of a proposed algorithm depends on
the number of points in a partition of a segment and also
the parameters of the Firefly Algorithm, such as the
number of fireflies, different other parameter values and
the stopping
criteria. The relative error of any result is calculated by
the formula:
(7)
𝐫𝟐
parameter α and rand is the random number generator,
whose generated numbers are uniformly distributed in
the interval [0, 1].
∆=(
𝐄𝐀 − 𝐄𝐓
𝐄𝐓
) 𝐗 𝟏𝟎𝟎
(12)
where EA is the value received from our algorithm and
ET is the value received from some classical numerical
method. During the testing only one parameter of the
Firefly Algorithm is changed. It is the number of points
in a partition of a segment, all other parameters remain
fixed.
As a typical example, we consider an integral with a
𝟑
𝟏
monotonic continuous integrand such as ∫𝟐.𝟑 𝐱 𝟓 𝐝𝐱 =
0.8502. It is important to note that the result (correct up
to 4 decimal places) given by our algorithm is much
closer than the ones given by known numerical
algorithms such as top-right corner approximation, topleft corner approximation, midpoint app- roximation,
trapezoidal rule, simpson’s 1/3 rule, especially when the
number of intervals is small.
(10)
where N is the number of dimensions or number of
solution vectors.
F. Movement
The movement of a firefly i that is attracted to another
more attractive firefly j is determined by [5]
(a)
(b)
Fig. 3.
𝟐
𝟏
𝐱 𝐢+𝟏 = 𝐱 𝐢 + 𝛃𝟎 𝐞−𝛄𝐫 (𝐱 𝐣 − 𝐱 𝐢 ) + 𝛂(𝐫𝐚𝐧𝐝 − )
𝟐
(11)
where the second term is for attraction, while the third
term is for randomization including randomization
𝟏
a) Area bounded by the curve 𝐲 = 𝐱 𝟓 from x = 2.3 to 3.
b) Graph representing percentage of error given by
proposed algorithm and other numerical methods.
_______________________________________________________________________________________________
ISSN (Print): 2319-2526, Volume-3, Issue-2, 2014
38
International Journal of Advanced Computer Engineering and Communication Technology (IJACECT)
_______________________________________________________________________________________________
In case of quickly oscillating functions our Firefly
Algorithm gives more exact result than the other known
classical numerical integration methods. For example,
𝟏
𝟏
we consider ∫𝟎.𝟎𝟏 𝐜𝐨𝐬( 𝟐 ) 𝐝𝐱 = −0.0925
𝐱
We briefly present the results of our experiments in
Table 1 and before also show the comparison with an
implementation using Genetic Algorithm (GA). Our
proposed algorithm performs consistently better both in
terms of accuracy as well as running time. In Table 2,
we show a few cases with Double Integrals, where also
the results are encouraging.
Integration
(a)
Approx
. Value
Firefly
Algorithm
Runtim
e
Error
( in
sec)
∫ x 3 dx
0.2496
0.0004
0.89
0.0001
3.18
0.1277
0.0000
0.08
0.0069
2.51
0.7068
0.0000
0.14
0.0401
2.07
2.5658
0.0001
0.06
0.0001
2.16
2.3962
0.0001
0.64
0.0003
3.17
0
Fig. 4.
0.6
𝟏
a) Area bounded by the curve y = 𝐜𝐨𝐬 ( 𝟐 ) from x =
𝐱
0.01 to 1
b) Graph representing the percentage of error given by
proposed algorithm and other numerical methods.
If the number of intervals increases, the operating time
of the Firefly Algorithm also increases, but not too
much. In case of some of the integration problems,
which are not possible to be solved analytically, our
Firefly Algorithm gives exact result. For example we
𝟐
𝟏
consider ∫𝟎.𝟎𝟓 𝐞𝐬𝐢𝐧(𝐥𝐨𝐠(𝐱 )) 𝐝𝐱 = 0.7625
∫
0.02
1
sin ( ) dx
x
1
2
∫ e−x dx
0
π
∫ sin(x)
0
+ cos(x 2 ) dx
π
∫ √sin(x) dx
0
Table 1: Comparison of results for Single Integrals
Integration
1
Approx.
Value
Firefly
Algorithm
Runtim
Error
e
( in sec)
0.0417
0.000
0
0.06
17.0000
0.000
0
0.08
2.1394
0.000
0
0.14
(1−x)
∫ ∫
xy dydx
0 (1−x2 )
6 1
∫ ∫ (x + y 3 )dydx
2 0
1 1
(b)
∫ ∫ (x 2
Fig. 5.
a) Area bounded by the curve 𝐲 = 𝐞
=0.05 to 1.
0
𝐬𝐢𝐧(𝐥𝐨𝐠(𝐱𝟐 ))
from x
b) Graph representing the percentage of error given by
proposed algorithm and other numerical methods.
The following things were observed.
1.
2.
3.
Error
Runt
ime
( in
sec)
1
(b)
(a)
Genetic
Algorithm
When the population size increases the amount of
error monotonically decreases, however the speed
of convergence decreases.
If the number of points within segment [a, b]
increas-es, then the amount of error decreases but
the opera-ting time of the algorithm increases.
The algorithm stops when the error is greater than
the previous value of error, otherwise it improves
the result continuously till the maximum number of
iterations.
0
2
+ y )dydx
Table 2: Results on Double Integrals
VI. CONCLUSION
In this paper, we have successfully used the Firefly
Algorithm to calculate Definite Integrals. For brevity,
we did not show the comparisons with the results
obtained by classical numerical methods or other soft
computing techniques [4].
However, it was observed that our implementation using
Firefly Algorithm gave more accurate results compared
to all of them.
Although, the Firefly Algorithm has advantages of being
easily
implementable,
precise,
robust,
and
accommodates parallel implementation, it also has
_______________________________________________________________________________________________
ISSN (Print): 2319-2526, Volume-3, Issue-2, 2014
39
International Journal of Advanced Computer Engineering and Communication Technology (IJACECT)
_______________________________________________________________________________________________
disadvantages like chances of being trapped into local
optima and lack of memorization capability.
[4]
V. Morozenko, I. Pleshkova, Numerical
Integration by Genetic Algorithm: Information
Theories and Applications, Volume 20, Number
3, 2013
[5]
X. S. Yang, Nature-Inspired meta-heuristic
Algorithms, Luniver Press, 2008
[6]
X. S. Yang, Firefly algorithms for multimodal
optimaza-tion, 5th Symposium on stochastic
Algorithms, Foundations and Applications,
SAGA 2009, Eds. O. Watanable & T. Zeugmann, LNCS, 5792, 169-178(2009).
[7]
D. E. Goldberg, Genetic Algorithm in Search,
Optimiza-tion and Machine Learning, Reading,
Mass, Addison Wesley (1989)
[8]
J. Kennedy, R. C. Eberhart, Y. Shi, Swarm
intelligence, Academic Press, (2001).
REFERENCES
[1]
X. S. Yang, Firefly Algorithm: Stochastic Test
Functions and Design Optimization: Int. J. BioInspired Computation, 2010, Volume. 2, No. 2,
pp. 78-84.
[2]
R. Poli, J. Kennedy, T. Blackwell, Particle swarm
optima-zation: An overview (Springer Science
and Business Media, LLC 2007).
[3]
Pei-Wei Tsai, Jeng-Shyang Pan, Bin-Yih Liao,
Shu-Chuan Chu, Enhanced Artificial Bee Colony
Optimization:
Internati-onal
Journal
of
Innovative Computing, Information and Control,
Volume 5, Number 12, December 2009.

_______________________________________________________________________________________________
ISSN (Print): 2319-2526, Volume-3, Issue-2, 2014
40
Download