A Hybridization of Dragonfly Algorithm Optimization and Angle Modulation Mechanism for 0-1 Knapsack Problems

The dragonfly algorithm (DA) is a new intelligent algorithm based on the theory of dragonfly foraging and evading predators. DA exhibits excellent performance in solving multimodal continuous functions and engineering problems. To make this algorithm work in the binary space, this paper introduces an angle modulation mechanism on DA (called AMDA) to generate bit strings, that is, to give alternative solutions to binary problems, and uses DA to optimize the coefficients of the trigonometric function. Further, to improve the algorithm stability and convergence speed, an improved AMDA, called IAMDA, is proposed by adding one more coefficient to adjust the vertical displacement of the cosine part of the original generating function. To test the performance of IAMDA and AMDA, 12 zero-one knapsack problems are considered along with 13 classic benchmark functions. Experimental results prove that IAMDA has a superior convergence speed and solution quality as compared to other algorithms.


Introduction
Being some of the most important and widely used algorithms, gradient-based traditional optimization algorithms are relatively mature and have advantages like high computational efficiency and strong reliability. However, traditional optimization methods have critical limitations when applied to complex and difficult optimization problems because (i) they often require that the objective function is convex, continuous and differentiable and the feasible region is a convex set, and (ii) their ability to process non-deterministic information is poor.
Over the years, plenty of algorithms based on artificial intelligence, sociality of biological swarms, or the laws of natural phenomena have emerged and been proved to be good alternative tools for solving such complex problems. This type of optimization algorithms can be roughly divided into the following five categories: (i) Evolutionary algorithms (EAs); (ii) swarm intelligence; (iii) simulated annealing [1]; (iv) tabu search [2,3]; and (v) neural networks. EAs include genetic algorithms (GA) [4,5], differential evolution [6], and immune system [7]. Among these three algorithms, GA is based on the concept of survival of the fittest mentioned in Darwin's theory of evolution. GA and DE can be considered as the most standard form of EAs. The swarm intelligence algorithms include classic particle swarm optimization (PSO) [8], bat algorithm [9], artificial bee colony [10], ant colony algorithm [11], firefly algorithm [12], artificial fish-swarm algorithm [13], fruit fly optimization algorithm [14], and so on. These algorithms mentioned above are based on social activities of birds, bats, honey bees, ants, fireflies, fish, and fruit flies, respectively. They are far less perfect in theory than the traditional optimization algorithms at present, and often fail to ensure the optimality of the solution. However, considering the perspective of practical applications, this kind of budding algorithms generally do not require the continuity and convexity of the objective function and constraints, and they also have excellent ability to adapt to data uncertainty.
The dragonfly algorithm (DA) is a new swarm intelligence optimization algorithm that was proposed by Mirjalili [15] in 2015. It is inspired by two unique clusters of dragonflies found in nature: Foraging groups (also known as static groups) and migratory groups (also known as dynamic groups). These two group behaviors of dragonflies are very similar to the two terms of group intelligence (global search and local development). In the static group, dragonflies will be divided into several sub-dragonfly groups to fly in different areas, which is the main target of the global search. In the dynamic group, dragonflies will gather into a large group and fly in one direction, which is advantageous for the local development. Since the principle of DA is simple, easy to implement, and possesses good optimization capabilities, it has shown promising results when applied to multi-objective optimization [15], image segmentation problem [16], and parameter optimization of support vector machines [17]. Moreover, DA has also been successfully applied to the accurate prediction model of power load [18], power system voltage stability evaluation [19], power flow management of smart grid system [20], economic dispatch [21], synthesis of concentric circular antenna arrays [22], and traveling salesman problem [23]. Further, based on a large number of numerical tests, Mirjalili proved that DA performs better than GA [4,5] and PSO [8].
It must be noted that DA was used to solve the continuous optimization problem, while many optimization problems have existed in binary search spaces. This suggests that the continuous version of the optimization algorithm can no longer meet the requirements of the binary optimization problems. A binary version of DA(BDA) was proposed by Mirjalili et al. [15] and successfully applied to the feature selection problems [24]. Like binary PSO (BPSO) [25] and binary BA [26], BDA used a transfer function to map the continuous search space into binary space. In [27], Hammouri et al. proposed three improved versions of BDA, named Linear-BDA, Quadratic-BDA, and Sinusoidal-BDA, for feature selection. By using different strategies to update main coefficients of the dragonfly algorithm, the three algorithms outperform the original BDA. However, such binary algorithms were still developed by using transfer functions, which may be limited in some high-dimensional optimization problems owing to slow convergence speed and poor algorithm stability.
To avoid such problems, intelligent optimization algorithms based on the angle modulation technique, originated in signal processing [28], were proposed recently such as angle modulated PSO [29], angle modulated DE [30], and angle modulated bat algorithm [31]. Inspired by these algorithms, an angle modulated dragonfly algorithm (AMDA) is proposed in this paper to make DA work more efficiently in binary-valued optimization spaces. By using a trigonometric function with four coefficients to generate n-dimensional bit strings, AMDA is observed from the experiments on benchmark functions and 0-1 knapsack problems to have better performance as compared to other optimization algorithms such as BPSO and BDA. Further, by adding a control coefficient to adjust the vertical displacement of the cosine part of the generating function, an improved angle modulated dragonfly algorithm (IAMDA) is proposed to enhance convergence performance and algorithm stability.
The rest of this paper is arranged as follows. The standard DA and the binary DA (BDA) are elaborated in Section 2. In Section 3, the proposed AMDA and IAMDA are explained. Further, Section 4 presents the analysis of the experimental results on 13 benchmark test functions and 12 0-1 knapsack problems. Finally, Section 5 discusses and concludes the performance of IAMDA with respect to BPSO, BDA, and AMDA.

Background
The dragonfly algorithm (DA) is a budding algorithm inspired by the social behavior of dragonflies, and this section gives a brief introduction about DA and its binary version.

The Dragonfly Algorithm
The dragonfly algorithm is an advanced swarm-based algorithm inspired by the static and dynamic clustering behaviors of dragonflies in nature. By simulating the behaviors of dragonflies looking for prey, mathematical modeling of the algorithm is done. During the modeling, the life habits of dragonflies, such as finding food, avoiding natural enemies, and choosing the flight routes are considered. The dragonfly population is divided into two groups: migratory swarm (also known as a dynamic swarm) and feeding swarm (also known as a static swarm). A large number of dragonfly clusters migrate in a common orientation for long distances intending to seek a better living environment in the dynamic swarm whereas, in a static swarm, each group is composed of a small group of dragonflies that fly back and forth in a small area to find other flying prey. The migration and feeding behaviors of dragonflies can be regarded as two main phases in meta-heuristics algorithm optimization: exploitation and exploration. Dragonflies gather into a large group and fly in one direction in a dynamic swarm, which is beneficial in the exploitation phase. In a static swarm, however, to find other flying prey, small groups of dragonflies fly back and forth in a small range, which is beneficial to the exploration of search agents. The dynamic and static groups of dragonflies proposed by Mirjalili [15] are demonstrated in Figure 1.

The Dragonfly Algorithm
The dragonfly algorithm is an advanced swarm-based algorithm inspired by the static and dynamic clustering behaviors of dragonflies in nature. By simulating the behaviors of dragonflies looking for prey, mathematical modeling of the algorithm is done. During the modeling, the life habits of dragonflies, such as finding food, avoiding natural enemies, and choosing the flight routes are considered. The dragonfly population is divided into two groups: migratory swarm (also known as a dynamic swarm) and feeding swarm (also known as a static swarm). A large number of dragonfly clusters migrate in a common orientation for long distances intending to seek a better living environment in the dynamic swarm whereas, in a static swarm, each group is composed of a small group of dragonflies that fly back and forth in a small area to find other flying prey. The migration and feeding behaviors of dragonflies can be regarded as two main phases in metaheuristics algorithm optimization: exploitation and exploration. Dragonflies gather into a large group and fly in one direction in a dynamic swarm, which is beneficial in the exploitation phase. In a static swarm, however, to find other flying prey, small groups of dragonflies fly back and forth in a small range, which is beneficial to the exploration of search agents. The dynamic and static groups of dragonflies proposed by Mirjalili [15] are demonstrated in Figure 1. Separation, alignment, and cohesion are three main principles in the insect swarms introduced by Reynolds [32] in 1987. The degree of separation refers to the static collision avoidance of the individuals from other individuals in the neighborhood, the degree of alignment indicates the velocity matching of individuals to that of other individuals in the neighborhood, and the degree of cohesion reflects the tendency of individuals toward the center of the mass of the neighborhood.
Every swarm in DA follows the principle of survival, and each dragonfly exhibits two separate behaviors: looking for food and avoiding the enemies in the surrounding. The positioning movement of dragonflies consists of the following five behaviors: (1) Separation. The separation between two adjacent dragonflies is calculated as follows: Separation, alignment, and cohesion are three main principles in the insect swarms introduced by Reynolds [32] in 1987. The degree of separation refers to the static collision avoidance of the individuals from other individuals in the neighborhood, the degree of alignment indicates the velocity matching of individuals to that of other individuals in the neighborhood, and the degree of cohesion reflects the tendency of individuals toward the center of the mass of the neighborhood.
Every swarm in DA follows the principle of survival, and each dragonfly exhibits two separate behaviors: looking for food and avoiding the enemies in the surrounding. The positioning movement of dragonflies consists of the following five behaviors: (1) Separation. The separation between two adjacent dragonflies is calculated as follows: where S i is the separation of the i-th individual, X i is the location of the i-th individual, X j indicates the location of the j-th neighboring individual, and N is the number of neighborhoods. (2) Alignment. The alignment of dragonflies is calculated as follows: where A i indicates the alignment of i-th individual, V j indicates the velocity of the j-th neighboring individual, and N is the number of neighborhoods.
(3) Cohesion. The cohesion is derived as follows: where C i indicates the cohesion of the i-th individual, X i is the position of the i-th individual, N represents the number of neighboring individuals, and X j shows the location of the j-th neighboring individual.
(4) Attraction. The attraction toward the source of food is calculated as follows: where F i shows the food source of the i-th individual, X i indicates the location of the i-th individual, and X + represents the location of the food source.
(5) Distraction. The distraction from an enemy is derived as follows: where E i represents the position of an enemy of the i-th individual, X i is the location of the i-th individual, and X − indicates the location of the natural enemy. The above five swarming behaviors in the positioning movement of dragonflies are pictorially demonstrated in Figure 2. where i S is the separation of the i-th individual, i X is the location of the i-th individual, j X indicates the location of the j-th neighboring individual, and N is the number of neighborhoods.
(2) Alignment. The alignment of dragonflies is calculated as follows: (2) where i A indicates the alignment of i-th individual, j V indicates the velocity of the j-th neighboring individual, and N is the number of neighborhoods.
(3) Cohesion. The cohesion is derived as follows: where i C indicates the cohesion of the i-th individual, i X is the position of the i-th individual, N represents the number of neighboring individuals, and j X shows the location of the j-th neighboring individual.
(4) Attraction. The attraction toward the source of food is calculated as follows: where i F shows the food source of the i-th individual, i X indicates the location of the ith individual, and + X represents the location of the food source. (5) Distraction. The distraction from an enemy is derived as follows: where i E represents the position of an enemy of the i-th individual, i X is the location of the i-th individual, and − X indicates the location of the natural enemy. The above five swarming behaviors in the positioning movement of dragonflies are pictorially demonstrated in Figure 2.

Seperation Alignment Cohesion
Attraction to food Distraction from enemy  To update the location of dragonflies in a search space and to simulate their movements, two vectors are considered: step vector (∆X) and position vector (X). The step vector suggests the direction of the movement of dragonflies and can be formally defined as follows: where s is the separation weight, S i is the separation of the i-th individual, a shows the alignment weight, A i indicates the alignment of i-th individual, c is the cohesion weight, C i indicates the cohesion of the i-th individual, f represents the food factor, F i shows the food source of the i-th individual, e indicates the enemy factor, E i represents the position of an enemy of the i-th individual, w represents the inertia weight, and t represents the iteration count.
According to the calculation of the above step vector, the position vector can be updated by using Equation (7): If there are no neighboring solutions, the positon vectors are calculated by using the following equation: where dim is the dimension of the position vector. Levy function can be described as follows: where r 1 and r 2 are random numbers within [0,1], β is a constant, and: The basic steps of DA can be summarized as the pseudo-codes highlighted in Figure 3. Update neighboring radius if a dragonfly has at least one neighboring dragonfly Update step vector using Equation (6) Update position vector using Equation (7) else Update position vector using Equation (

Binary Dragonfly Algorithm
In the traditional DA, a search agent can easily change its position by introducing a step vector. However, in the discrete spaces, since a position vector can only be updated to 0 or 1, it is impossible to update a position vector according to the original method. Mirjalili et al. [15] first proposed the binary dragonfly algorithm (BDA) to solve the binary optimization problems. BDA adopted the following transfer function to derive the probability of changing positions of all the search agents: x Δ

Binary Dragonfly Algorithm
In the traditional DA, a search agent can easily change its position by introducing a step vector. However, in the discrete spaces, since a position vector can only be updated to 0 or 1, it is impossible to update a position vector according to the original method. Mirjalili et al. [15] first proposed the binary dragonfly algorithm (BDA) to solve the binary optimization problems. BDA adopted the following transfer function to derive the probability of changing positions of all the search agents: Further, the position vectors can be updated by the following formula: where r is a random number between [0,1].

AMDA
In this paper, the angle modulation technique is used for the homomorphic mapping of DA to convert the complex binary optimization problem into a simpler continuous problem. Different from the traditional BDA, the angle modulated dragonfly algorithm (AMDA) uses a trigonometric function to generate bit strings. The trigonometric function can be expressed as: where x = 0, 1, . . . , n b − 1, denotes the regular intervals at which the generating function is sampled, where n b is the length of the required binary solution; the four coefficients (a, b, c, and d) are within [-1,1] at initialization. Then, the standard DA is used for evolving a quadruple composed of (a, b, c, d), and this leads each dragonfly to generate a position vector of the form X i = (a, b, c, d). To evaluate a dragonfly, the coefficients from the dragonfly's current position are substituted into the generating function in Equation (13). Each sampled value at x is then mapped to a binary digit as follows: The main steps of AMDA are simplified as the pseudo-code givens in Figure 4. To evaluate a dragonfly, the coefficients from the dragonfly's current position are substituted into the generating function in Equation (13). Each sampled value at x is then mapped to a binary digit as follows: The main steps of AMDA are simplified as the pseudo-code givens in Figure 4.

IAMDA
The prime advantage of AMDA is that it only needs four coefficients instead of the original n-dimensional bit strings. Thus, the computational cost will be significantly reduced. AMDA's generating function is a composite of a sine wave and a cosine wave. The vertical displacement of the sine wave can be controlled by the coefficient d in Equation (13) but the vertical displacement of the cosine wave cannot be corrected, which results in a large variance of the entire generating function value. In addition, if the initialization range of DA parameters is small, DA will encounter some difficulties while searching for

IAMDA
The prime advantage of AMDA is that it only needs four coefficients instead of the original n-dimensional bit strings. Thus, the computational cost will be significantly reduced. AMDA's generating function is a composite of a sine wave and a cosine wave. The vertical displacement of the sine wave can be controlled by the coefficient d in Equation (13) but the vertical displacement of the cosine wave cannot be corrected, which results in a large variance of the entire generating function value. In addition, if the initialization range of DA parameters is small, DA will encounter some difficulties while searching for a binary solution.
To alleviate the problem of the inability and control the vertical displacement of the cosine wave in the original generating function, this paper proposed an improved AMDA, called IAMDA. IAMDA uses one more coefficient k to control the degree of disturbance of the generating function in the mapping space: where the five coefficients (a, b, c, d, and k) are within [−1,1] at initialization. The standard DA is used for evolving a quintuple composed of (a, b, c, d, k), and this led each dragonfly to generate a position vector of the form X i = (a, b, c, d, k). To evaluate a dragonfly, the coefficients from the dragonfly's current position are substituted into Equation (15) and each sampled value is then mapped to a binary digit according to Equation (14).
In the original generating function, if the value of d is not large enough, the generating function will always be above or below 0, which will make the bit string only contain bit 0 or 1. Hence, a coefficient k is added to generate a bit string containing both 0 and 1 bits. The coefficient k is introduced to compensate for the insufficient disturbance in trigonometric function as well as to adjust vertical displacement of the cosine function. The comparison between the original and modified generating functions is presented in Figure 5. It can be observed from Figure 5 that the original generating function with the vertical displacement d = 0.2 is almost above 0. In this manner, it is easier to generate solutions that are mostly 0s or 1s. In the modified generating function, the displacement coefficient k increases the diversity of the solutions so that IAMDA may achieve better solutions even if the vertical displacement d is not large enough. In order to demonstrate the mapping procedure, Figure 6 shows the procedure of using the modified trigonometric function to map a continuous five-dimensional search space into an n-dimensional binary search space. The main procedures of IAMDA are described as the following pseudo-codes given in Figure 7.

i-th dragonfly
Step vector In order to demonstrate the mapping procedure, Figure 6 shows the procedure of using the modified trigonometric function to map a continuous five-dimensional search space into an n-dimensional binary search space. The main procedures of IAMDA are described as the following pseudo-codes given in Figure 7. In order to demonstrate the mapping procedure, Figure 6 shows the procedure of using the modified trigonometric function to map a continuous five-dimensional search space into an n-dimensional binary search space. The main procedures of IAMDA are described as the following pseudo-codes given in Figure 7.

BINARY SEARCH SPACE i-th dragonfly
Step vector Position vector Bit-vector solution

Test Functions and Parameter Settings
To verify the performance and stability of IAMDA, two sets of benchmark test functions and 0-1 knapsack problems are selected. To efficiently compare the performance of each algorithm, the original AMDA, the basic BDA [15], and the BPSO [25] were selected to deal with the test problems. The average solution, median, and standard deviation are taken into consideration to evaluate each algorithm.
In this paper, the population size of IAMDA, AMDA, BDA, and BPSO is set to be 30 [15,33,34] and the number of iterations is set to be 500. Other parameter settings are listed in Table 1. To avoid the resulting bias caused by chance, the algorithms run independently on each function 30 times. Moreover, in this paper, each continuous variable is represented by 15 bits in binary. It should be noted that in order to indicate the sign of each functions' variable, one bit should be reserved. Hence, the dimension of each dragonfly, that is, the dimension of each generated bit string can be calculated as follows:

Test Functions and Parameter Settings
To verify the performance and stability of IAMDA, two sets of benchmark test functions and 0-1 knapsack problems are selected. To efficiently compare the performance of each algorithm, the original AMDA, the basic BDA [15], and the BPSO [25] were selected to deal with the test problems. The average solution, median, and standard deviation are taken into consideration to evaluate each algorithm.
In this paper, the population size of IAMDA, AMDA, BDA, and BPSO is set to be 30 [15,33,34] and the number of iterations is set to be 500. Other parameter settings are listed in Table 1. To avoid the resulting bias caused by chance, the algorithms run independently on each function 30 times. Moreover, in this paper, each continuous variable is represented by 15 bits in binary. It should be noted that in order to indicate the sign of each functions' Entropy 2021, 23, 598 9 of 24 variable, one bit should be reserved. Hence, the dimension of each dragonfly, that is, the dimension of each generated bit string can be calculated as follows: Dim dragon f ly = Dim f unction × 15 (16) where Dim dragon f ly and Dim f unction represent the dimension of each dragonfly in IAMDA and the dimension of a specific benchmark function, respectively. Simulation environment: The processor is an Intel(R) Core (TM) i5-6500 2.40GHz, with 4.0GB RAM, Windows10 operating system, and the simulation software is Matlab2016a.

IAMDA Performance on Unimodal and Multimodal Benchmark Functions
The test functions are categorized into two groups: unimodal functions (f 1~f 7 ) and multimodal functions (f 8~f 13 ) [15,35,36]. To solve the optimal function, IAMDA is compared with several other algorithms on the 13 standard test functions. Each unimodal benchmark function has a single optimal value and it is easy to benchmark the convergence speed and optimization capability of an algorithm. On the contrary, multimodal benchmark functions have multiple optimal values, which makes them more complex as compared to unimodal functions. There is only one global optimal value among many optimal values, and an algorithm ought to avoid all local optimal approximations and tend to find the global optimal value. Hence, the multimodal test function can efficiently benchmark the exploration of the algorithm and the avoidance of local optima. The specific conditions about unimodal functions as well as multimodal functions are highlighted in Tables 2 and 3, respectively. Here, 'Function' indicates the test functions, 'n' represents the number of variables in the test function, 'Range' demonstrates the search scope of the test function, and 'f min ' indicates the global optimal value of the test function. Figure 8 represents the convergence curves of the above four algorithms on different unimodal functions and Figure 9 shows the convergence curves of the above algorithms on various multimodal functions. Table 4 lists the average, median values, and standard deviation of IAMDA, AMDA BDA, and BPSO while testing the benchmark functions.

Function
Expression n Range f min Step [−50,50] 0 Penalized 1.2  Figure 9 shows the convergence curves of the above algorithms on various multimodal functions. Table 4 lists the average, median values, and standard deviation of IAMDA, AMDA BDA, and BPSO while testing the benchmark functions.
(a)      Figures 8 and 9, respectively, represent the average convergence curves of the four algorithms on 7 unimodal functions and 6 multimodal functions after performing 30 experiments. The convergence curves in Figures 8 and 9 indicate that the convergence speed of IAMDA is significantly faster than that of the other three algorithms. For example, from Figure 8e, Figure 9a,e,f, it can be observed that the convergence of IAMDA can reach the optimal value at about 100 iterations.
In order to test whether IAMDA is statistically significant compared to other algorithms, statistical student's t-test [37] has been performed. The t value can be calculated by the following formula: where X 1 , SD 1 , and n 1 represent the mean value, standard deviation, and size of the first sample (AMDA, or BDA, or BPSO), respectively; X 2 , SD 2 , and n 2 indicate the mean value, standard deviation, and size of the second sample (IAMDA), respectively. In this work, n 1 = n 2 = Dim dragon f ly . The positive t value means that IAMDA has better solutions compared to AMDA (or BDA or BPSO). The negative t value means that AMDA (or BDA or BPSO) produced better solutions than IAMDA. In our study, the confidence interval has been set at 95% which indicates t 0.05 = 1.96. When t > 1.96, the difference between two samples is significant and IAMDA is superior to AMDA (or BDA or BPSO). When t < −1.96, AMDA (or BDA or BPSO) is superior to IAMDA. The t values calculated by Equation (17) over the selected 13 benchmark functions are presented in Tables 5 and 6. In the presented tables, 'N.S.' represents 'Not Significant', which means that the compared algorithms do not differ from each other significantly. Note that all the data in Table 4 are average values over 30 experiments. From the experimental results in Table 4, it can be analyzed that as compared to AMDA, BDA, and BPSO, IAMDA has obvious advantages in the optimization results of the 13 standard test functions. Judging from Table 5, IAMDA can find the optimal solutions in most cases of unimodal functions, which means that IAMDA has better exploitation capability. Additionally, according to the t values calculated in Table 6, IAMDA and AMDA exhibit similar exploration capability and have better performance than BDA and BPSO on multimodal functions. In brief, IAMDA has better exploitation and exploration capability. This proves that the introduction of the coefficient k in the angle modulation mechanism is beneficial for improving the convergence accuracy of the algorithm. Hence, according to the average convergence curves in Figures 8 and 9, and test data in Tables 4-6, it can be concluded that IAMDA outperforms the AMDA, BDA, and BPSO.

Conclusions
To make the dragonfly algorithm work efficiently in the binary space, this paper applies an angle modulation mechanism to the dragonfly algorithm. AMDA uses the trigonometric function to generate bit strings corresponding to the binary problem solutions instead of directly running on the high-dimensional binary spaces. Thus, AMDA can significantly reduce the computational cost as compared to the traditional BDA using transfer functions. However, AMDA also has some limitations such as poor algorithm stability and slow convergence speed due to the lack of control on the vertical displacement of the cosine part in the generating function.
To deal with the limitations, this paper proposes an improved angle modulated dragonfly algorithm (IAMDA). Based on AMDA, one more coefficient is added to adjust the vertical displacement of the cosine part in the original generating function. From the test results of unimodal and multimodal benchmark functions and 12 low-dimensional and high-dimensional zero-one knapsack problems, it can be concluded that IAMDA outperforms AMDA, BDA, and BPSO in terms of stability, convergence rate, and quality of the solution. Additionally, it significantly reduces the computational time as compared to BDA. For future advancements, our studies may include multidimensional zero-one knapsack problems, multi-objective optimization problems, and so on. Furthermore, our research will be applied to practical applications such as feature selection and antenna topology optimization.