Firefly Mating Algorithm for Continuous Optimization Problems

This paper proposes a swarm intelligence algorithm, called firefly mating algorithm (FMA), for solving continuous optimization problems. FMA uses genetic algorithm as the core of the algorithm. The main feature of the algorithm is a novel mating pair selection method which is inspired by the following 2 mating behaviors of fireflies in nature: (i) the mutual attraction between males and females causes them to mate and (ii) fireflies of both sexes are of the multiple-mating type, mating with multiple opposite sex partners. A female continues mating until her spermatheca becomes full, and, in the same vein, a male can provide sperms for several females until his sperm reservoir is depleted. This new feature enhances the global convergence capability of the algorithm. The performance of FMA was tested with 20 benchmark functions (sixteen 30-dimensional functions and four 2-dimensional ones) against FA, ALC-PSO, COA, MCPSO, LWGSODE, MPSODDS, DFOA, SHPSOS, LSA, MPDPGA, DE, and GABC algorithms. The experimental results showed that the success rates of our proposed algorithm with these functions were higher than those of other algorithms and the proposed algorithm also required fewer numbers of iterations to reach the global optima.


Introduction
Optimization is a process of finding the most desirable solution to the problem of interest. Optimization problems can be divided into two main categories depending on the types of variables involved (discrete or continuous). A problem with discrete variables is known as a combinatorial optimization problem while a problem with continuous variables is known as a continuous optimization problem. The optimization algorithm proposed in this paper only emphasizes solving continuous optimization problems. Optimization algorithms are of many varieties ranging from simple search to much more complex ones that require a great deal of computational time. At present, among the widely researched types of optimization algorithms, self-organized algorithms employing procedures that emulate animal swarm behavior are very popular. Brief overviews of recent metaheuristic algorithms based on firefly, ant, fish, bird, and bee are presented in the next paragraph.
Yang [1] developed a swarm intelligent algorithm based on the flashing behavior of fireflies. In nature, the firefly flashes its light to attract other fireflies for mating. The less bright firefly is attracted and moves towards the one that flashes brighter light. The experimental results in Yang's paper showed that the firefly algorithm outperformed both genetic algorithm and particle swarm optimization on the tested benchmarks. Similar results were also obtained by Baykasoglu and Ozsoydan [2]. Even though the algorithm is very promising, further investigation is needed to improve on the convergence of the algorithm and to prevent trapping in local optima. Farahani et al. [3] proposed an improved firefly algorithm called Gaussian distribution firefly (GD-FF) algorithm. Three new strategies were introduced: (i) an adaptive step length that changes with time, (ii) a directed 2 Computational Intelligence and Neuroscience movement towards the global best solution when there is no brighter firefly within its vicinity, and (iii) a social behavior that changes the position of each firefly based on a Gaussian distribution. The authors found that their algorithm got better result and converged to the global optimum faster than the original firefly algorithm. Rizk-Allah et al. [4], on the other hand, improved the firefly algorithm in a different way; they combined it with an ant colony optimization (ACO) algorithm. First, this hybrid algorithm is initialized using the ACO algorithm. Then the firefly algorithm is put to work as a local search to refine the solutions found by the ants. The hybrid was proven successful. Shin and Kita [5] improved the performance of particle swarm optimization (PSO) by including the information of the second global best and second personal best particles in their developed algorithm. The algorithm's performance was found to be better than the original PSO. Another variant of PSO was an algorithm called Levy flight particle swarm optimization (LFPSO) [6]. This algorithm combined PSO with Levy flight. Experimental results showed that the LFPSO clearly outperformed the original PSO and other PSO variants in terms of solution quality and robustness. A different kind of swarm intelligent algorithm based on the behavior of bees in finding food sources, called bee colony optimization (BCO), was also further developed by assigning two weights to each food source. One is a global weight and the other is a local weight. As a result, the proposed algorithm, named weighted bee colony optimization (wBCO) [7], performed better than the original BCO and many state-of-the-art algorithms. Artificial bee colony (ABC), another bee-inspired algorithm, was modified by Gao and Liu [8]. In their proposed algorithm, Levy flight, differential evolution, and particle swarm optimization were incorporated into the original ABC algorithm. Experimental results showed that the proposed algorithm achieved better performance than the original ABC algorithm and many of its variants. Niu et al. [9] proposed an improved version of the original fruit fly optimization algorithm (FOA), called DFOA. They modified the expression of the smell concentration judgement value and introduced DE/best/1 mutation strategy to replace the random search. The results showed that DFOA was superior to seven other evolutionary computation methods. Chen et al. [10] presented a new PSO variant called particle swarm optimization with an aging leader and challengers (ALC-PSO). In ALC-PSO, the leader of the swarm has a lifespan. If the leader is trapped in a local optimum, it will age quickly and new challengers will emerge to replace the old leader. As a result, ALC-PSO has an ability to escape from local optima and to find global optima in a short period of time. Genetic algorithm (GA) was also developed further by Thakur [11] who proposed a new crossover operator, called double Pareto crossover operator (DPX). DPX was used in combination with power mutation (PM) operator. He tested this algorithm with multimodal nonlinear functions and found that its success rate was higher than that of the standard GA.
In this paper, a swarm intelligence algorithm called firefly mating algorithm (FMA) is presented. In FMA, GA is used as the core of the algorithm. A new mating pair selection method, inspired by the mating behavior of fireflies in nature, is introduced and incorporated into GA.
The rest of the paper is organized as follows: Sections 2 and 3 briefly discuss the original firefly algorithm and genetic algorithm, respectively; in Section 4, the biological background of the proposed algorithm is explained; in Section 5, the proposed model with a detailed description of each step is presented; in Section 6, a description of the experiments is given; in Section 7, experimental results are shown and compared; finally, Section 8 is the conclusion.

Firefly Algorithm
This section describes the original firefly algorithm. Firefly algorithm (FA) is a reliable and efficient metaheuristic algorithm capable of solving many real-world problems such as scheduling, optimization problems in dynamic environments, and economic load dispatch problem. This algorithm is influenced by the flashing behavior of fireflies to attract one another. It is constructed based on three rules [12]: (i) All fireflies are unisex so that one firefly is attracted to all other fireflies.
(ii) The attractiveness of a firefly is proportional to its brightness. For any two fireflies, the dimmer one is attracted by (and thus moves towards) the brighter one. However, if there are no fireflies brighter than a given firefly, that firefly will move randomly.
(iii) The brightness of a firefly decreases as the distance from it increases. This is because light is absorbed when it passes through the medium. Therefore, the brightness (also attractiveness) of the firefly seen by the firefly is defined in (1).
where is a light absorption coefficient of the medium, is the Euclidean distance between the firefly and the firefly , (0) is the brightness of the firefly at = 0, and and are the locations of the fireflies and , respectively.
If the firefly is the brighter one, the value of its attractiveness regulates the movement of the firefly according to the following equation: where is a randomization parameter and rand is a uniform random number in the range [−0.5, 0.5]. The function of the second term in (3) is to move the firefly towards the firefly . The function of the third term in (3) is to move the solution away from a local optimum when such incident takes place.

Genetic Algorithm
Genetic algorithm (GA) is an optimization technique inspired by the process of natural selection. GA starts with Computational Intelligence and Neuroscience 3 an initial population which consists of a number of randomly generated chromosomes. A new population is created from the current one by means of 3 genetic operators: selection, crossover, and mutation. The selection operator stochastically chooses chromosomes to be included in the mating pool; the ones with higher fitness values are more likely to be chosen. Crossover operator selectively chooses some genes from the chromosomes of the parents and combines them into the offspring. Mutation operator randomly changes some genes of the offspring. This evolution process is repeatedly performed until any of the stopping criteria is met. The commonly used stopping criteria are as follows: (i) a predefined number of iterations is reached, (ii) the best solution does not improve for a predefined number of iterations, and (iii) a large percentage of the chromosomes in the population is the same.

Biological Inspiration of the Proposed Algorithm
There are over 2,000 species of fireflies around the world, but most of them are found in the tropical zone. They live under the water when they are larvae and on the ground and in the air when they are adults. Fireflies are social animals. They stay in a swarm on tree branches and lay eggs on the ground around the trees. The fascinating thing when observing fireflies is their light flash. The light emitted from their abdomens is a cold light through chemical reactions within their bodies. Fireflies emit flashing light for communication, luring preys, repelling predators, and attracting mates. Note that this research only focuses on the mating behavior of the firefly; therefore, the detailed relation of the flashing light signal to the mate selection process is further discussed in the next paragraph.
In the mating season, female fireflies release pheromones into the air to signal their readiness to mate. The pheromones are carried away in the direction controlled by the wind [13]. Male fireflies follow the pheromone trail and approach the females from a downwind direction [13]. More males are attracted to females who release more pheromones. Males then fly around the trees that the females perch on and flash courtship signal to attract females [14]. Females are more attracted to brighter males and response to those males by flashing their own lights. Then many rounds of mating take place during the night [15]. Males mate until they run out of sperm in their sperm reservoir while females can hold only a certain amount of sperms in their spermatheca. Sperms from fitter males are more likely to be chosen to fertilize a female's eggs; this is due to the following two explanations: (i) females have ways to discard low-quality sperms, including destroying them by their internally produced chemicals [16,17]; (ii) one male's seminal fluid can incapacitate rival males' sperm within the female reproductive tract [16,18]. It is nature's way of selective breeding.

Our Proposed Algorithm
This section describes a firefly mating algorithm (FMA), which is built on top of the GA. FMA incorporates a new mating feature, inspired by the mating behavior of fireflies in nature, into GA. This new feature, which will be discussed in Section 5.2, significantly contributes to the capability of the proposed FMA.
FMA consists of three main processes: (i) a male selects a female according to the level of her released pheromone that he senses which changes according to wind speed and direction; (ii) a female selects a male according the light intensity of his flash; and (iii) a male or a female mates repeatedly until he runs out of sperms or her spermatheca is full, producing more able offspring for the next generation. This algorithm proceeds from the first step to the last in the 6 following steps.

5.1.
Initialization. An initial population of fireflies is randomly generated; half are assigned as males and the other half are females. Each firefly consists of genes (which is equal to the number of variables in the problem). Additionally, the sizes of each female's spermatheca and each male's sperm reservoir, which are real numbers between 0 and 1, are randomly generated. Lastly, the fitness value of each firefly is calculated.

Selection of Mating
Pairs. This step features a new method for determining the mating pairs. Unlike in the GA where mating pairs are selected by using a roulette wheel selection technique, our proposed algorithm introduces a new selection method based on a process of firefly mate selection. First, male fireflies are drawn to a female's location by following the pheromone that the female releases. Second, the female selects males based on their brightness. Finally, mating pairs are formed based on the mutual attraction of each pair. By introducing this concept to the algorithm, it provides a way to overcome the problem of getting stuck in local optima, as is often the case with the roulette wheel selection technique. A detail of this new selection method is described in the following subsection.

Determination of Female Sex Appeal.
Female sex appeal is directly proportional to the amount of pheromone released by the female. The pheromone released by the female firefly diffuses downwind and reaches each male firefly in unequal amounts depending on 2 factors: (i) the distance and (ii) the speed and direction of the wind. In this subsection, therefore, the male fireflies determine the concentration level of each female's pheromone reaching them. A highly fit female that is farther away from a male can get selected by the male if her highly concentrated pheromone gets carried along by a highspeed wind towards the male. The concentration level of the female 's pheromone reaching the male , , is calculated by using where is the fitness value of a female firefly , ⃗ is the wind vector which is randomly generated in each iteration, and ⃗ is the difference vector between the position vector of a male and that of the female.

4
Computational Intelligence and Neuroscience

Determination of Male Sex Appeal.
In this subsection, the female fireflies determine the appeal of each male in their vicinity. Similar to the original FA, the appeal of a male firefly is directly proportional to his brightness. Thus, by imitating (1), the appeal of the male firefly seen by the female firefly is calculated according to the following equation: where is the appeal of the male firefly seen by the female firefly , is a constant in the range [0, 1], is the Euclidean distance between the male and the female (calculated according to (2)), and is the fitness value of the male firefly .

Calculation of the Mutual Attraction.
According to the degree of mutual attraction, a number of males and females are paired together as potential parents. A pair whose mutual attraction value is the highest among all pairs is selected as the first mating pair. The mutual attraction between the female firefly and the male firefly , MA , is defined as After each mating, the numbers of sperms in the male's sperm reservoir and in the female's spermatheca are updated. The update procedure is described in the next subsection. Next, the pair with the next highest value is selected if its male member still has some sperms left in the sperm reservoir and the female's sperm bucket has not become full yet.
where is the number of sperms transferred to the female at the time of mating, is the number of sperms in the sperm reservoir, and is the fitness value of a female firefly . It stands to reason that a fitter female should get more sperms because, then, she would produce more offspring that are fitter than those produced by other females. After mating, the number of sperms in each male's sperm reservoir and the space of each female's spermatheca are checked. Once a male runs out of sperm or a female's spermatheca is full, he/she will be disqualified from mating in the next round. Equations (8) and (9) are used to update the number of sperms in a male's sperm reservoir and a female's spermatheca, respectively.
Mating goes on until there is no qualified firefly left to form the mating pair.

Crossover Operation.
When a male and a female mates, some of their genes are crossed over to form two new offspring. One of the two following cases is applied with a specific crossover procedure as follows.
Case 1. If the parents have never been mated before, the 2-point crossover operator (Figure 1) is used to create the offspring. The 2-point crossover operator starts from randomly selecting a start position and an end position in the parent chromosomes to be crossed over, and then the genes between these two positions are crossed over and placed in the same position in the chromosomes of the two offspring, each having the original genes from each parent before the crossover.

Case 2.
If either of the parents has been mated before, the -point crossover operator (Figure 2) is used to create the offspring. The -point crossover operator starts from randomly selecting /2 pairs of back-to-back start and end positions, then crossing over the genes from the parents between each pair of start and end position. The rest of the genes are retained.

Mutation Operation.
After an incipient offspring is produced from mating, some of its genes are randomly changed (mutated) to new values within the range of the variables as shown in Figure 3. The mutation is performed in order to promote diversity of the population and to help avoid getting stuck in local optima.

Selection of the Population for the Next Generation.
After all offspring are mutated, the best fireflies out of the combined population of parents and offspring are selected to replace the old population of parents; in effect, only the more effective fireflies are selected to be the population of the next generation. The selection is done by sorting members by their fitness values and then selecting only the members with the higher fitness values that make up the total number of members of the initial population.

Termination.
After the selection of a new population for the next generation, the current iteration is completed. The algorithm then moves on to perform the next iteration until the specified maximum number of iterations is reached or the best solution does not improve for a predefined number of iterations.
Computational Intelligence and Neuroscience 5  Computational Intelligence and Neuroscience

Description of the Experiments
Our FMA algorithm was performance-tested on Core-i7 computers, and the test results were compared against those of firefly algorithm (FA) and 11 other widely cited algorithms in the literature, namely, ALC-PSO [10], COA [19], MCPSO [20], LWGSODE [21], MPSODDS [22], DFOA [9], SHPSOS [23], LSA [24], MPDPGA [25], DE [26], and GABC [27]. These algorithms were chosen as benchmarks because they are variants of the prominent bioinspired algorithms such as particle swarm optimization, genetic algorithm, differential evolution algorithm, and artificial bee colony algorithm. Moreover, from the literature, their performance was superior to that of their original counterparts. Twenty wellknown standard test functions ( 1 -20 ) were employed to test whether these algorithms would be able to solve all common types of problems. In particular, 1 -16 are high-dimensional (30 dimensions) that represent computationally complex tasks while 17 -20 are two-dimensional multimodal functions. The descriptions of the test functions are shown in Table 1. Table 1 provides the following information about each test function: function ID, equation, dimension ( ), search domain ( ), and optimum value ( min ). For each test function, five experimental repetitions were performed with different initial populations each time. Since the performance of the metaheuristic algorithms strongly depends on proper selection of system parameters, as most of other intelligent systems, the parameters of FMA are varied to a wide extent in order to get the best out of the algorithm. As a result, the best value for each parameter is shown in Table 2. The performance of FMA was tested in terms of the following 3 aspects: (i) the best solution that an algorithm found, (ii) the average number of iterations to reach the global optimum (in the case that an algorithm has found it), and (iii) the success rate or the number of times that an algorithm was able to find the global optimum divided by the total number of trials.

Results and Discussion
The performance of all compared algorithms in finding the optimal solutions of 20 test functions is shown in Table 3.

8
Computational Intelligence and Neuroscience   The number shown in each cell of the table is the best result obtained by each algorithm. The symbol "-" denotes that the algorithm was not tested on that function. Compared to other algorithms, FMA surpassed them all with respect to the percentage of functions in which the algorithm successfully found the global optima. FMA was able to find the global optima in 16 out of 20 functions tested (shown in bold typeface in Table 3). FA found the global optima of 9 out of 20 test functions. It failed to find the global optima of test functions 3 , 4 , 6 , 8 , 10 , 12 , 13 , 14 , 15 , 17 , and 18 . ALC-PSO found the global optima of test functions 6 , 8 , and 10 but failed to find the global optima of test functions 1 , 2 , 5 , 7 , 9 , and 13 . COA found the global optima of test functions 1 , 2 , 6 , 7 , 10 , and 20 but failed to find the global optima of test functions 4 , 5 , 9 , 12 , 13 , and 19 . MCPSO found the global optima of test functions 1 and 2 but failed to find the global optima of test functions 5 , 7 , 9 , 10 , 12 , and 18 . LWGSODE and MPSODDS were not able to locate the global optima in any of the functions tested. DFOA successfully found the global optimum of only 1 out of 10 functions tested. SHPSOS found the global optima of test functions 1 , 2 , 3 , 6 , 7 , 8 , and 16 but failed to find the global optima of test functions 4 , 9 , 10 , 12 , 13 , 17 , and 18 . LSA found the global optima of test functions 6 and 20 but failed to find the global optima of test functions 1 , 2 , 4 , 5 , 7 , 9 , 10 , 12 , 13 , and 19 . MPDPGA found the global optima of test functions 1 , 7 , and 11 but failed to find the global optima of test functions 5 , 9 , and 10 . DE found the global optima of test functions 1 , 2 , 5 , 6 , 7 , 10 , and 20 but failed to find the global optima of test functions 4 , 9 , 12 , and 13 . DFOA successfully found the global optimum of only 1 out of 9 functions tested.
Besides being very effective, FMA also has good convergence performance. Table 4 shows the comparative convergence performance of FMA and FA on the following 2 aspects: the average number of iterations to reach the global optimum (in the case that an algorithm has found it) and the success rate (the number of times that an algorithm was able to find the global optimum divided by the total number of trials). "N/A" denotes that the algorithm was unable to find the optimal solution for that function. By examining the results, the following are summaries of the finding. First, FMA achieved 100% success rate for 15 out of 16 functions in which FMA found the global optima. This means that FMA almost always found the global optimum regardless of the difference in the initial population of each experimental trial. Second, as mentioned earlier, FMA was able to find the global optima in 16 out of 20 functions while FA only found 9. Therefore, only eight functions ( 1 , 2 , 5 , 7 , 9 , 11 , 16 , and 20 ) in which both FMA and FA found the global optima have been analyzed. Out of the 8 functions, FMA can achieve the global optima with far fewer iterations than FA for the functions 2 , 7 , 9 , 11 , 16 , and 20 , while FA has better convergence rate for the functions 1 and 5 .
The distinct advantage of FMA is the rich diversity of offspring that it generates. Two main causes for this kind of diversity are that FMA enables fireflies to perform multiple mating and that the level of female pheromone that a male senses depends not only on the distance between them but also on the wind speed and direction which is randomly selected for each iteration. As a result, FMA is better able to converge to a global optimum of a function that has a wide and complex search space.

Conclusion
In this paper, a new mating pair selection technique, inspired by the mating behavior of fireflies in nature, is proposed and incorporated into the original firefly algorithm and genetic algorithm. The performance of FMA was tested with sixteen 30-dimensional benchmark functions and four 2dimensional functions against several widely accepted algorithms. The test results showed that it was able to converge to the global optima in 16 of them. Moreover, compared to the firefly algorithm, FMA required fewer numbers of iterations for most of the functions tested. Because of this initial success, FMA is worth further investigation and application to combinatorial optimization problems.

Conflicts of Interest
The authors declare that they have no conflicts of interest.