Keywords

1 Introduction

The Firefly Algorithm (FA) [1, 2] is one of a typical representative of swarm intelligence (SI) group. This algorithm tries to bring the fireflies mating behavior into optimization. Nevertheless, like many others SI-based as well as other non-bio-inspired algorithms, the FA has some drawbacks. One of those is quite dreadful premature convergence and rapid stagnation of population and decrease of its diversity. Many algorithms are struggling with this issue. Another typical member of SI, which is the Particle Swarm Optimization (PSO) algorithm [3], has attracted many researchers and several different advanced techniques have been developed over the years [4] to deal with the aforementioned issue.

In this paper, we are trying to improve the FA through the analysis of complex network [5] non-trivial features (attributes). For example, those can be the degree distribution, clustering coefficient, centralities, betweenness and much more [6, 7]. These attributes provide partly a clear description of a state or a health of the population (population diversity, that we are trying to improve), and partly the insight into the internal communication between particles, in this case between fireflies. Finally, the complex network analyses for metaheuristic algorithms have already been successfully adapted [8,9,10,11].

Choosing the most suitable technique for improving the FA algorithm is a certainly challenging task. In this research, we are analyzing different steps to select the best one possible. Starting with the selection of a partial population restart technique, continuing over the complex network attribute readings and ending with assembling of all steps together. The paper is structured as follows. The FA is briefly described in the next section. The proposed method with complex network description and implementation follows afterward. Later, a description of the test functions for the verification of proposed method, results and conclusions are given.

2 Firefly Algorithm

FA was firstly introduced in 2008 by Yang [1, 2]. This nature-based algorithm tries to simulate the mating behavior of fireflies at night. Every firefly emits flashing light to lure appropriate mating partner. For the formulation of the FA, the flashing light is associated with the objective function value that is optimized. For simplicity, the three following rules are used:

  • All fireflies are sexless (each firefly can attract, or be attracted by, any of the remaining ones).

  • The attractiveness of fireflies is proportional to their brightness. Thus the less bright firefly will move toward the brighter one. The brightness decreases with the distance between fireflies. If there is no brighter firefly, the particular one will move randomly.

  • The firefly brightness is based on the objective function value.

The brightness I (1) of firefly consists of three factors: the objective function value, the distance between two compared fireflies and absorption of media in which the fireflies are

$$ I\left( r \right) = \frac{{I_{0} }}{{1 + \lambda r^{m} }} $$
(1)

where I(r) is the brightness of particular firefly based on distance r. I 0 is the initial brightness or in this case the objective function value. The λ is the light absorption coefficient of media and the m ≥ 1.

The attractiveness β(r) (2) is proportional to brightness as mentioned before and then very similar to previous equation

$$ \beta \left( r \right) = \frac{{\beta_{0} }}{{1 + \lambda r^{m} }} $$
(2)

where β(r) is the attractiveness between fireflies based on their distance r. The β 0 is the initial attractiveness. The r is defined as a Euclidean distance between two fireflies as (3)

$$ r_{ij} = \sqrt {\sum\nolimits_{k = 1}^{d} {\left( {x_{i,k} - x_{j,k} } \right)^{2} } } $$
(3)

where r ij is Euclidean distance between fireflies i and j. The d is dimension size of the optimized problem.

The movement of a firefly i is then defined as (4)

$$ x_{i} = x_{i} + \beta \left( r \right) \cdot \left( {x_{j} - x_{i} } \right) + \alpha \cdot sign $$
(4)

where x i and x j are fireflies i and j. The variable α serves as a randomization parameter. The sign provides a random sign or direction. The pseudo-code below summarizes the FA.

figure a

3 Proposed Complex Network Approach

To improve the search ability of the FA, we have chosen a verified technique, which is a partial population restart [12]. Several ways of population restarts can be performed and selection of the most appropriate and suitable approach is a difficult task. The selection of the best technique encompasses several minor but necessary steps. In this chapter, all the relevant steps are compared and hybridized together to get the most suitable population restart method. All the preliminary tests were performed on Rastrigin function (f 3 ) (See Sect. 4) and for dimension size 10 with a population size of 30 particles.

The partial population restart will be dependent on the complex network analysis. Respectively on one of its non-trivial features (attributes). The choosing of the applicable feature is given in next sub chapters.

Various ways for building and analysis of the complex network are possible [13]. The basic oriented network was chosen here. Each firefly represents a node in the network. The edge between nodes emerges thanks to the successful interaction between fireflies; i.e. when one firefly gets improved, it flies toward another firefly. Such a kind of network is shown in Fig. 1.

Fig. 1.
figure 1

An example of a basic oriented network for a population of 30 fireflies.

3.1 Centralities

Various features can be calculated on the complex network [14]. Centralities, in general, can identify the most important nodes within a graph, in our case the most influential firefly in the population. It means that these centralities can be useful to determine the stagnation of population of fireflies.

In general, there are many different centralities, which can be considered - closeness centrality, betweenness centrality, degree centrality and much more. Each of these centralities assigns a value for every node in the network. For our approach (and maximal simplicity), it is beneficial to observe only one value. Following statistical values for centralities are compared: max (a node with a maximal value is controlled), min (controlled node is the one with a minimal value), median (controlled is a median value of all nodes) and standard deviation (a standard deviation of values from all nodes is controlled).

The comparison itself is given in Fig. 2, where the orange line with filling to axis shows a diversity of population over the time (fitness evaluation), the blue line represents an eigenvector centrality, the red line is a closeness centrality, the green line is a betweenness centrality, and the last one is a degree centrality that is depicted in brown color. All presented values in graphs have been rescaled for easy comparison.

Fig. 2.
figure 2

Comparison of different statistical methods on various centralities.

Some conclusions can be obtained from the data in Fig. 2. If we select to analyze only max value, the most promising centralities are an eigenvector and a betweenness centrality. In the case of minimal value, the optimal seems to be a closeness centrality.

For a median value, the comparisons have given interesting findings. The most suitable seem to be again an eigenvector centrality since the other centralities seem to show radical change quite a bit early during the metaheuristic run, and by using such data, the decrease of exploitation ability can occur. The last graph in Fig. 2 shows that the most promising centralities are: eigenvector, betweenness, and degree centrality. Based on the data in Fig. 2 one important question arose. Why focus on the features of the complex network when the similar data can be achieved from population diversity value? The answer can be formulated as follows. The population diversity only measures the distribution of particles over the optimized landscape. On the other hand, the centralities are also covering the communication between fireflies. This feature is quite beneficial as the communication (active searching in the space of solutions) between fireflies can stop or at least decrease, but at the same time, the diversity remains unchanged.

The eigenvector centrality in particular [14] has been chosen based on the analysis given above. This feature measures the influence of a node (firefly) in a network. Higher centrality value is assigned to the nodes that are connected with many other well-connected nodes. We can assume that presence of high values of this eigenvector centrality over the network represents active communication between fireflies i.e. the search or optimization process is currently running. On the other side, the decrease of these values serves as a hint that the optimization process is stopping or the swarm is stuck in the local optima. The median value of eigenvector centrality has been selected because it showed the greatest degree of change in the short period of time.

3.2 Partial Population Restart Control

Next step lies in the decision of how to use the centrality based knowledge to control the partial population restart. We decided to compare the eigenvector median from previous evaluation t  1 with a median of an actual evaluation t. If the median of iteration t is a greater than the median t  1, the number ‘+1’ is stored in a FIFO (First In First Out) memory of size n. Otherwise, the ‘−1’ value is stored in this memory. Thus, if the sum in the memory is a negative number or equal to zero, the partial population restart is activated. This procedure is shown in Fig. 3, where the orange line with filling to an axis shows population diversity again, the blue line represents a median of eigenvector value and the last one, the red line, is reflecting an activation of population restart (logical 0 or 1). This figure is only outlining the simulation of partial population restart without real execution. Specifically showing the time when the partial population restart should be done according to this metric (given by the logical 1 peak of the red line).

Fig. 3.
figure 3

Simulation of partial population restart.

The last two things remain to answer. Firstly, how big should the FIFO memory be - what is the ideal size of n. Secondly, what is the most efficient population size determined for restarting? Figure 4 depicts the influence of restarting to population diversity and comparison of adaptive memory sizes.

Fig. 4.
figure 4

Influence of restarting to population diversity. (Left image: influence of memory size; right image: influence of proportion of population determined to restart)

The tested versions for the adaptive size of memory (See Fig. 4, left graph) are:

  • 1% of FEs (blue line),

  • 0.5% of FEs (red line),

  • 0.25% of FEs (green line),

  • 0.1% of FEs (brown line).

The ideal setting should have equally distributed ratio between exploration and exploitation phases. The most promising one seems to be an option with 0.25% of FE. The adaptive version could be more useful for situations, where the number of FEs is dependent on the dimension size of an optimization problem.

The very last important setting remains - the number of fireflies determined to restart. The comparison for five possible scenarios is given also in Fig. 4 (right figure), where the options are:

  • 90% of the population (blue line),

  • 75% of the population (red line),

  • 50% of the population (green line),

  • 20% of the population (brown line),

  • 10% of the population (pink line).

Based on the graphical comparison in Fig. 4, the most promising option seems to be a restart of 75% of swarm’s population.

4 Test Functions

A set of 4 standard functions have been chosen for the simulation experiment. This set consists of simple unimodal (f 1 and f 2 ) and multimodal (f 3 and f 4 ) functions:

  • f1, Sphere function (5),

  • f2, Rosenbrock function (6),

  • f3, Rastrigin function (7),

  • f4, Schwefel function (8).

$$ f_{1} \left( \varvec{x} \right) = \sum\nolimits_{i = 1}^{d} {x_{i}^{2} } $$
(5)
$$ f_{2} \left( \varvec{x} \right) = \sum\nolimits_{i = 1}^{d - 1} {\left( {100 \cdot \left( {x_{i + 1} - x_{i}^{2} } \right)^{2} + \left( {x_{i} - 1} \right)^{2} } \right)} $$
(6)
$$ f_{3} \left( \varvec{x} \right) = 10d + \sum\nolimits_{i = 1}^{d} {\left( {x_{i}^{2} - 10 \cdot cos\left( {2\pi x_{i} } \right)} \right)} $$
(7)
$$ f_{4} \left( \varvec{x} \right) = 418.9829d - \sum\nolimits_{i = 1}^{d} {x_{i} \cdot sin\left( {\sqrt {\left| {x_{i} } \right|} } \right)} $$
(8)

5 Results

The performance comparisons of the FA with proposed population restarting method and the canonical FA were carried out on dimensions 2, 5 and 10 for all 4 test functions. The number of function evaluations (FEs) was set to 1500 ∙ d, where d stands for the selected dimension size. Both compared FA versions had fixed number of fireflies (NP) set to 30. The parameters of the FA were set as \( \lambda = 0.01, m = 1, \beta_{0} = 0.5, \alpha = 0.2 \). Table 1 shows simple statistical results for both versions of the FA. The canonical one is labeled as ‘firefly’ and the version with proposed partial population restart is labeled as ‘fireflyCN’. The best obtained results for particular dimension size and test function are highlighted by bold numbers.

Table 1. Statistical results

Table 1 gives some interesting results and observations. Regarding the optimized problem dimension size, the proposed modification of FA seems to be much more successful for smaller dimension settings. From the test function type point of view, the simplest unimodal Sphere function (f 1 ) seems to be better suited for the original version of FA than for the upgraded one. With increasing complexity of the test functions, the results reveal almost equal performance (f 2 and f 3 ) or better performance (f 4 ) in favor of the modified version of the FA.

Overall, the modified version has obtained more good results than the original one, but there are still some exceptions to this statement, and more experiments have to be executed. The experiment results are also supported by Fig. 5, which contains the graphic grid of convergence plots for the selected combinations of dimension setting and test function.

Fig. 5.
figure 5

The convergence plots (minimal average value over time) for selected experiments; where the blue line represents the original FA, and the orange line stands for the improved version.

6 Conclusion

In this paper, the FA has been enhanced with the aid of complex network analysis and one of the network features. This modification was developed with the objective to stop the premature convergence of the population and to prevent the lack of diversity.

This research is aimed at the understanding of difficulties and insights into the internal dynamics leading to successful improvement of an existing metaheuristic algorithm with complex network analysis technique. The paper explains each necessary step and explains the decisions made based on several tests.

Finally, the modified version of the FA is compared to the original one, and the results are discussed in details. Results lend weight to the argument that the modified version provides overall better performance. Nevertheless, in few case studies, the original algorithm performed equally or even better. Those findings fully support the idea that more and detailed studies and complex experiments with complex networks analysis approach and its impact on controlling of the internal dynamics of the swarm based algorithms are required for better understanding of the problem.