XOR Binary Gravitational Search Algorithm

In this paper, an XOR binary gravitational search algorithm is introduced. Gravitational search algorithms, a physics inspired optimization algorithm, have previously been successfully applied to different real-valued optimization problems. In their binary version, the definition of a velocity vector changes to probability of change in corresponding dimensions. However, analysis shows that existing velocity vector update equation for binary gravitational search algorithm do not direct the particle towards better particle in certain cases. To apply this algorithm to binary optimization problems we introduce an XOR operator in the acceleration term. After a mathematical comparison to existing binary gravitational search algorithms it is shown that the proposed modification complies more with the definition of change in each dimension. Extensive simulations are performed showing the superiority of the proposed algorithm over other existing algorithms such as binary particle swarm optimization and an existing version of binary gravitational search algorithm.


I. INTRODUCTION
Calculus of variations, gradient based optimization methods and linear programming approaches are among the most successful computational methods to optimize a nonlinear function. However, there are some cases in which the cost function is not explicitly defined and/or it is difficult or even impossible to calculate derivatives due to high dimensionalities. In such cases, nature inspired optimization algorithms that rely on implicit functions may be viable choices. These optimization algorithms start the process from multiple points and they are less probable to fall in local minima. Evolutionary based optimization algorithms [1], swarm based optimization methods [2] and physic inspired optimization algorithms [3] are different categories of metaheuristic optimization methods applied in these cases.
In evolutionary based optimization methods, each solution is decoded to a chromosome with its dimension being the same as the number of genes in chromosome. Inspired by nature, these artificial chromosomes are subject to crossover, mutation and natural selection models to find the optimum value of a function. In swarm based optimization algorithms that try to model the graceful and unpredictable movement of birds and fish, a position vector represents every solution. Position vectors are then updated using a velocity vector that has different terms showing tendency towards the best experience of the whole swarm and the best individual experience of each member of the swarm. Physics inspired optimization algorithms, unlike evolutionary optimization algorithms and swarm based optimization methods, which try to model the behavior of living species, imitate the interaction between objects in real life. Examples of physics inspired optimization algorithms are central force optimization algorithm [4] and gravitational search algorithm (GSA) [5]. The latter is a stochastic search algorithm benefiting from superior exploration capability that may results in superior performance.
GSA, an optimization algorithm inspired by the interaction between masses in space from Newton gravitational law, has been successfully applied to different engineering fields such as optimal design of power systems [6], allocation of power devices [7] etc. According to Newton's gravitational law, the gravitational force between two masses in space is directly proportional to the multiplication of two mass and inversely proportional with the Euclidean distance between them. By studying the acceleration of two different masses, one can show that the acceleration of each mass towards another one is proportional to the mass of the other object. In this case, the small object moves with higher acceleration towards the big one. This acceleration causes lighter objects to accelerate towards heavier ones. In GSA, heavier masses are assigned to particles with superior cost functions values that causes the particles with poorer cost functions to be pushed towards them while scanning the whole space. Meanwhile, if any other solutions come up with better performance, a big value of mass is assigned to that particle making it attract other particles.
The original GSA is designed for real-valued optimization problems with position and velocity vector being real-valued. Continuously evolving product design emerges automated task planning, task assignment and programing individual tasks for production elements including robots that may give rise to using intelligent optimization algorithms. In such examples, decision variables may be binary rather than real values and the goal may be to achieve less energy consumption, minimum time and possibly lower cost. Examples of such applications are process-planning problem [8], assembly sequence planning [9] and assembly line design problems [10]. To solve discrete binary optimization problems, the values of decision variables in a binary optimization problem are either zero or one and a vector representing the probability of change in each dimension is defined instead of velocity vector [11,12]. The main aim of the vector representing the probability of change is to direct a particle towards a particle with better cost function. However, the analysis presented in this paper show that this does not happen using current update formula for BGSA.

XOR Binary Gravitational Search Algorithm
Mojtaba Ahmadieh Khanesar, David Branson III In this paper, BGSA and its update formulas for acceleration, velocity and position are fully analyzed and the motivation behind writing this paper is established utilizing mathematical models. It is shown that in the existing BGSA, the update equation for the probability vector of BGSA does not direct particles towards better particles as it is expected from the algorithm. To solve the problems with BGSA, the velocity vector is modified using an XOR operator. The proposed optimization algorithm is validated in simulation against a number of benchmark optimization problems. It is shown that the proposed algorithm is capable of optimizing various benchmark optimization problems including unimodal and multi-modal cost functions with several local optimum points, resulting in superior performance when it is compared to BGSA [12], novel binary particle swarm optimization (NBPSO) [13], improved binary swarm optimization (IBPSO) [14] and binary particle swarm optimization (BPSO) [11]. This paper is organized as follows. In Section II, realvalued GSA is discussed. The current version of BGSA is presented and analyzed in Section III. In Section IV, the proposed XOR BGSA is introduced and analyzed. The proposed algorithm is then compared with several existing optimization algorithms for the optimization of several benchmark examples. Finally, the concluding marks are presented in Section V.

II. GRAVITATIONAL SEARCH ALGORITHM
GSA is a population based optimization method which imitates the behaviour of interaction between masses due to universal gravitational forces between them. Unlike the basic version of particle swarm optimization (PSO) in which each particle is represented by its position and velocity, particles used in GSA benefit from more features such as acceleration and mass [5]. As particles with better cost functions are assigned higher values of mass they attract other particles. The particles with worse cost functions are absorbed by better particles which results in exploiting the search space. The mass of particles is continuously updated based on their cost function, if during exploitation, the cost function corresponding to a particle becomes better than the previously found better solution, a larger value is assigned to its mass which results in other particles to be accelerated towards newly updated better solution. After a few iterations, all solutions are converged towards the heaviest mass resulting in termination of the algorithm. The algorithm is described mathematically using the following few lines.
The solution to problem is defined as the positions of particles in ݀ −dimensional search space as: where ‫ݔ‬ is the ݆ ௧ component of the position of the particle and ܰ is the total number of populations. The mass of particles are updated and normalized at ‫ݐ‬ ௧ iteration as [5]: where ݉ ‫)ݐ(‬ is non-normalized mass value corresponding to ݅ ௧ particle at iteration number ‫ݐ‬which represents the quality of solution and is defined as [5]: where ݂ ௪ ௦௧ ‫)ݐ(‬ is the fitness function value corresponding to the worst particle and ݂ ௦௧ ‫)ݐ(‬ represents the best fitness function observed by any of the particles. The parameters ݂ ௪ ௦௧ ‫)ݐ(‬ and ݂ ௦௧ ‫)ݐ(‬ are updated at every iteration as: It is to be noted that in this case the best and worst particles are defined based on minimization problem. Furthermore, ݇ best solutions are selected at each iteration as the masses which absorb the other masses. Hence, in this case ݉ ‫)ݐ(‬ belongs to the interval of [0, 1] which ݉ ‫)ݐ(‬ = 0 being the mass of the worst particle which does not absorb any particle and ݉ ‫)ݐ(‬ = 1 represents the mass of the best particle.
The overall gravitational force acting on the ݅ ௧ particle is obtained as: where ݇ represents the number of best solution selected, ∥. ∥ stands for Euclidean norm, ߝ is a small value added to prevent division by ‫,ݎ݁ݖ‬ ‫ݎ‬ is the power considered for the Euclidean distance between two particles, ‫)ݐ(ܩ‬ is the gravitational constant and ‫ݎ‬ ∈ [0, 1] is a uniform random value. The gravitational constant is updated at each iteration using the following equation.
where ‫ܩ‬ has a constant real value and ‫ݐ‬ ௫ is the maximum value of the iterations of the algorithm. According to Newton's second law of motion the acceleration of particles are calculated by dividing the applied force to ݅ ௧ mass by its value of mass as: Considering the fact that velocity of particle can be calculated as the discrete integral of its acceleration, the following equation is obtained for the velocity of the particles.
is a uniform random number. Finally, the newer position of each particle is updated as:

III. BINARY GRAVITATIONAL SEARCH ALGORITHM
A. Description of the algorithm Similar to BPSO [10] in BGSA the velocity in each direction changes its meaning to the probability of change in each dimension. In other words, a large absolute value for velocity in a dimension means that the current state is not suitable and needs to be changed to result in a better solution. Based on such a description, the function ܲሺܸ ) is defined to implement an approach as [12]: ܲ൫ܸ ൯ൌ ݄݊൫ห ܸ ห ൯ǡ ݅ൌ ͳǡǥ ǡܰ ǡ ݆ൌ ͳǡǤǤǤǡ݀ (10) where ‫݄݊ܽݐ‬ሺǤሻ represents hyperbolic tangent function and is defined as: Calculating the ܲሺܸ ), the probability of change in every dimension, the next state in each dimension is calculated as [12]: where ‫ݔ‬ ሺ‫ݐ‬ሻrepresents the complement of ‫ݔ‬ ሺ‫ݐ‬ሻand ‫ݎ‬ ∈ [0, 1] has a uniform random value.

B. Analysis of Binary Gravitational Search Algorithm
As mentioned earlier, to be able to apply GSA to binary problems, the meaning of velocity changes based on the probability of change in each dimension while the other equations remain the same. Hence, the acceleration in each dimension is calculated using (7). The analysis of algorithm is done based on this equation.
3) If ܺ ሺ‫ݐ‬ሻൌ ͳǡ ܺ ሺ‫ݐ‬ሻൌ Ͳ, ܺ ሺ‫ݐ‬ሻെ ܺ ሺ‫ݐ‬ሻൌ ͳ which results in positive acceleration term. In this case if the velocity in ݇ ௧ dimension is positive, this acceleration term works fine and adds up to the speed. However, if the velocity in ݇ ௧ dimension is negative, the acceleration term decreases the absolute value of velocity and makes the probability of change smaller which is completely undesirable.

4) If ܺ
ሺ‫ݐ‬ሻൌ Ͳǡ ܺ ሺ‫ݐ‬ሻൌ ͳ, ܺ ሺ‫ݐ‬ሻെ ܺ ሺ‫ݐ‬ሻൌ െͳ which results in negative acceleration term. In this case if the velocity in ݇ ௧ dimension is positive, this acceleration term works decreases the velocity and consequently the probability of change. This case is undesirable. On the other hand, if the velocity in ݇ ௧ dimension is negative, the acceleration term increases the absolute value of velocity and makes the probability of change larger which is desirable.
Motivated by the problems caused in the third and forth case, in this paper, BGSA is modified to have an acceleration term with XOR operator. It will be shown that using such approach, it is possible to avoid undesirable cases which are reviewed previously.

IV. PROPOSED XOR BINARY GRAVITATIONAL SEARCH ALGORITHM
To overcome the aforementioned problems in the analysis part of binary GSA, the algorithm is modified to benefit from an XOR operator in acceleration vector. The acceleration term is modified as: where ⊕ represents the XOR operator acting bitwise on ܺ ሺ‫ݐ‬ሻand ܺ ሺ‫ݐ‬ሻ. The truth table for XOR operator is defined as in Table I.  where ‫݄݊ܽݐ‬ሺǤሻis defined as in (11). The remaining parts of the algorithm remain unchanged and the velocity vector as well as position vector in the XOR BGSA are updated as (8) and (12), respectively. The flowchart of the proposed binary optimization method is depicted in Fig. 1.

A. Analysis of proposed binary optimization algorithm
In this section, the proposed BGSA is analysed to show that the previous problems mentioned in the analysis part of BGSA do not exist any more. Similar to BGSA, in the case of proposed algorithm, since the parameter ܺ ‫,)ݐ(‬ ݇ = 1, . . . , ܰ only accept binary values of ‫ݎ݁ݖ‬ and ‫,݁݊‬ the subtraction ܺ ‫)ݐ(‬ − ܺ ‫)ݐ(‬ in each dimension may have one of four possible conditions. According to (13), in these cases negative acceleration occurs for the dimension ݇ which is quite desirable as it decreases the probability of change.
3) In the case ܺ ‫)ݐ(‬ = 1, ܺ ‫)ݐ(‬ = 0, ܺ ‫)ݐ(‬ ⊕ ܺ ‫)ݐ(‬ = 1 the desired condition is that a positive acceleration which increases the value of velocity vector and consequently results in higher probability of change.

4) In the case when
Similar to the previous case, this term contributes a positive value to the acceleration term and would result in higher change probability. This is highly desirable as the bit in the correponding value of bit in better particle is different than that of current particle. Hence change needs to be accelerated.
Hence in the case of XOR BGSA, the problems visited in the previous version of BGSA do not exist any more.

A. Implementation of XOR BGSA on various benchmark examples
The proposed XOR BGSA is implemented on binary minimization of several benchmark problems. In all of simulations, 20 bits are used to decode numerical values into binary domain. The number of solutions considered (population size) are selected as to be equal to 50, maximum number of generations are selected to be equal to 1000. The results obtained using the proposed XOR BGSA are compared with that of BGSA [12], NBPSO [13], IBPSO [14] and BPSO [11].
The considered optimization problems are a collection of functions with single optimum problem and functions with multiple local optimums. In these instances, while function number 1 has a single global optimum, function number 6 suffers from multiple local minimums. On the other hand, although function number 10 has a single global minima, the function changes far from the global optimum are very small making it hard to find its global minima. The parameter ܰ represents the dimension of these optimization problems which is considered to be equal to 3, 5 and 10 to test the optimization algorithms for different dimensions. These dimensions are multiplied by the number of bits taken for decoding real values, which results in optimization in 60, 100 and 200 dimensional space. The mathematical formula for the test functions are as: where: The optimization results are presented in Table II, optimization in each case are repeated 10 times and the mean values are reported in tables. It can be seen that the proposed optimization algorithm performs well in optimizing unimodal as well as multi modal optimization problems. Overall table illustrates that XOR BGSA generally outperforms most of other optimization algorithms. In the cases when it is not the best optimization algorithm, it is still very close to the desired results and often outperforms the others. B. Implementation of XOR BGSA on knapsack problem (MKP) For the second class of optimization problem the knapsack problem is considered. In the knapsack problem, it is desirable to maximum the profit while the capacity for resources is limited. Example applications of knapsack problem are databases in a distributed computer system, project selection, cargo loading, and cutting stock problems [15]. The problem is formulated in an explicit way as: where n is the number of items, m is the number of constrains, ‫‬ ≥ 0 represents the profit value for each item, resource consumption is expressed by ‫ݎ‬ and the capacity is denoted by ‫ܥ‬ . The constrained optimization problem can be converted to unconstrained one as: where the parameter ߚ is penalty coefficient considered to be equal to 10 ଵ . There exist several databases for knapsack optimization problem which specify some values for ‫‬ 's, ‫ܥ‬ 's and ‫ݎ‬ 's. Among them weing [16] and weish [17] are selected for performance comparison of the proposed XOR BGSA approach with existing optimization algorithms in literature. The number of particles taken for swarms are selected to be equal to 50 with maximum number of iteration selected equal to 1000. Tables III and IV summarize the results with D being the dimension of the problem and best results made boldfaced. The experiments are repeated 10 times and mean values are reported. Tables III and IV show that the proposed optimization algorithm outperform other binary optimization algorithms specially in cases when the dimension of the cost function is high. It is further observed that in the cases when it does not obtain the best results, the ranking of the proposed algorithm is two within studied algorithms.

A. Conclusions
In this paper, the binary version of GSA has been analysed and some of the cases for which its probability update rule did not behave as expected are discussed. Based on this analysis, a novel version for BGSA is proposed that benefits from an acceleration term with an XOR operator. Analysis shows that such modification can alleviate the shortcomings of BGSA in that in the proposed algorithm particles stochatically approach best particles in all cases. The proposed XOR BGSA is compared with a number of other optimization algorithms on the optimization of number of unimodal and multimodal optimization problems as well as optimizing knapsack problems. It is shown that results obtained using the proposed algorithm outperform BGSA [12], NBPSO [13], IBPSO [14] and BPSO [11] techniques. Hence the modification proposed in this paper will perform well in binary optimization problems.

B. Future Works
In a flexible manufacturing system, automatic task planning of production elements including robots is required to be done automatically in an efficient and minimum time. As a future work, inspired by appreciable results obtained in this paper, the proposed optimization algorithm will be utilized in the task planning of an assembly application. The assembly task to be optimized will include pick and place of objects, such as fastening nuts and bolts, and a sealing operation. The order of performing basic tasks in this process will be important, resulting in a constrained optimization problem.

VII. ACKNOWLEDGEMENTS
This work is funded and supported by the Engineering and Physical Sciences Research Council (EPSRC) under grant number: EP/R021031/1 -New Industrial Systems: Chatty Factories.