# Adaptive Spiral Flying Sparrow Search Algorithm

Authors: Chengtian Ouyang; Yaxian Qiu; Donglin Zhu
Journal: Scientific Programming
 (2021)

---

## Abstract

The sparrow search algorithm is a new type of swarm intelligence optimization algorithm with better effect, but it still has shortcomings such as easy to fall into local optimality and large randomness. In order to solve these problems, this paper proposes an adaptive spiral flying sparrow search algorithm (ASFSSA), which reduces the probability of getting stuck into local optimum, has stronger optimization ability than other algorithms, and also finds the shortest and more stable path in robot path planning. First, the tent mapping based on random variables is used to initialize the population, which makes the individual position distribution more uniform, enlarges the workspace, and improves the diversity of the population. Then, in the discoverer stage, the adaptive weight strategy is integrated with Levy flight mechanism, and the fusion search method becomes extensive and flexible. Finally, in the follower stage, a variable spiral search strategy is used to make the search scope of the algorithm more detailed and increase the search accuracy. The effectiveness of the improved algorithm ASFSSA is verified by 18 standard test functions. At the same time, ASFSSA is applied to robot path planning. The feasibility and practicability of ASFSSA are verified by comparing the algorithms in the raster map planning routes of two models.


---

## Body

## 1. Introduction

With the continuous development of scientific research, more and more swarm intelligence optimization algorithms have been proposed. The swarm intelligence optimization algorithm basically abstracts a series of formulas based on the life characteristics or behavior rules of organisms or things and finds high-quality solutions in a certain solution space based on these formulas. Scholars have proposed a series of swarm intelligence optimization algorithms through the behaviors of ant, cat, whale, wolf, and others. Among them, the sparrow search algorithm (SSA) [1], which finds optimal solutions through the sparrow foraging process, is a novel swarm intelligence optimization algorithm proposed by two scholars, Xue and Shen in 2020. This algorithm has fewer population roles and simple principles, and it is easy to understand. Compared with gray wolf optimizer (GWO) [2] and particle swarm optimization (PSO) [3], SSA has higher accuracy, stronger convergence, and better optimization capabilities. Moreover, SSA is now more and more applied in practical engineering. However, SSA also has the common shortcomings of swarm intelligence algorithms, such as easy to get stuck in local and excessive randomness during initialization.In order to overcome these shortcomings of the swarm intelligence optimization algorithm, scholars have studied the algorithm and successfully applied to practical engineering problems. Lei et al. [4] applied the Levi flight strategy in SSA to avoid local convergence and improve global optimization capabilities. They combine the improved sparrow search algorithm with DV-Hop to enhance the positioning accuracy in WSN. Xin et al. [5] used tent chaotic sequence to initialize the population in turn, and Gaussian mutation operator and tent chaotic disturbance balance the global individual position. A series of strategies increase the population diversity of the algorithm, strengthen the local search ability of the algorithm, and improve the possibility of jumping out of the local area. Tang et al. [6] introduced a cubic mapping strategy to initialize the population, avoiding the decrease of population diversity in the later iterations. The reverse learning strategy and elite particles are added to effectively prevent the algorithm from falling into a local optimum. The sine and cosine optimization algorithm is incorporated into the follower position update to reduce search blind spots and balance algorithm development and search capabilities. Finally, a Gaussian walk strategy is used to help the algorithm leave the stagnant state. The good search ability of the improved algorithm is tested through experiments. Xin et al. [7] also proposed an improved algorithm, adding the flying thoughts in the bird swarm algorithm to the location update of the discoverer and the follower, ensuring global convergence, increasing the diversity of the population, and being able to jump out of the local optimum. In this paper, the improved algorithm is also applied to the multithreshold image segmentation method, which solves the original low segmentation accuracy and slow segmentation speed. Mao et al. [8] used sin-cosine algorithm, nonlinear dynamic learning factor, and Levy flight strategy to improve the algorithm, speed up the convergence speed, and strengthen the local escape ability. Song et al. [9] proposed to introduce the skew tent map-based chaotic method to initialize the population and strengthen the individual quality of the population. After that, the nonlinear decreasing weight and mutation operator strategies were combined in each stage to dynamically change the search space, increase the diversity of the population, and improve the ability to jump out of the local optimum. Wu and others [10] used tent chaotic mapping, adaptive weight control step size, Cauchy mutation, and Gaussian mutation to improve the original algorithm in turn. Such a series of strategies balance the global search and local search capabilities, enhance the local development capabilities of the algorithm, and improve the search accuracy. Finally, the improved algorithm is applied to the mine intelligent ventilation system, which proves the good optimization effect of the improved algorithm. Zhang and Ding [11] initialized the population by logistic mapping. In the discoverer phase and the early warning phase, adaptive parameters are introduced to expand the search range of the discoverer, dynamically adjust the number of early warning individuals, and better help the sparrow individuals find the best position. The mutation operator strategy is added to the global process to increase the population diversity. The whole improved algorithm enhances the global search capability of SSA. Finally, the improved CSSA is applied to the stochastic configuration network. The results show that CSSA has good performance and improves the regression performance of SCN in solving large-scale data problems. Zhang et al. [12] used the sine cosine strategy to change the way the discoverer updates the location, and improve global and local search capabilities of the algorithm. A labor cooperation structure is added to the discoverer stage and the early warning stage, allowing the discoverer and the early warning individual to share their locations to achieve cooperation, so as to converge to the global optimal solution faster and more stably.Although these improved strategies can better improve the optimization ability of each algorithm, they do not change the search mechanism of each algorithm itself. And they only improved the search ability of the algorithm in the neighborhood space, and the learning rate was not high, resulting in the algorithm still having drawbacks. This means that when faced with high-dimensional complex problems, these algorithms may also be stuck into the local optimal situation. Therefore, based on the research of many scholars, this paper proposes the adaptive spiral flying sparrow search algorithm (ASFSSA).In the following paper, Section2 gives an introduction to the overall work and motivation of the algorithm. Section 3 introduces the sparrow search algorithm. Section 4 illustrates the improvements made by the adaptive spiral flying sparrow search algorithm. Section 5 compares and analyzes the improved algorithm with other intelligent algorithms. In Section 6, the improved algorithm is applied to path planning and compared with the other three algorithms in two different grids. Section 7 summarizes this paper.


## 2. Related Work and Motivation

In order to improve the search speed and convergence accuracy of individual sparrows and reduce the possibility of falling into the local optimum, adaptive weights and Levy flight strategies are used in the discoverer stage. In order to make the individual sparrow search more detailed and get a better position, a variable spiral search strategy is introduced in the follower stage. The higher the quality of the solution, the better the search ability.To verify the convergence and optimization ability of the proposed algorithm, six algorithms are used to compare the optimization effects of 18 test functions. As can be seen from the experimental results, the adaptive spiral flying sparrow search algorithm has more significant advantages than other algorithms. Finally, for the purpose of verifying the practicability and performance of the algorithm better, the four algorithms are applied to the path planning of the robot. The results show that the path planning of the adaptive spiral flying sparrow search algorithm is relatively stable and the cost is the least, which reduces the constraints of the immature and randomness in the path planning of the previous algorithms.


## 3. Sparrow Search Algorithm

The sparrow population is divided into two roles, namely, the discoverer and the follower. They have three behaviors: foraging, following, and reconnaissance. The task of the discoverer is to find food and inform the follower of the location of the food. Therefore, the discoverer needs to search in a large area, and the foraging range of the follower is generally small. This is the formula for updating the position of the discoverer:(1)Xi,jt+1=Xi,jt⋅exp−tα⋅M,ifR2<ST,Xi,jt+Q⋅L,ifR2≥ST.In formula (1), t and M, respectively, denote the current number of iterations and the maximum number of iterations. Xi,j represents the location of the i-th sparrow, and j is the representative dimension. In the above formula, α and R2 are both a random number from 0 to 1 (not zero), and R2 is an important parameter that controls the individual’s flight behavior. ST (ST ∈ [0.5, 1]) is a safety threshold and an important parameter to measure whether the location of the discoverer is safe. L is a 1 × D matrix with all elements of 1. If R2 < ST, it means that the current location is temporarily safe, there are no predators in the surrounding environment, and the discoverer can search for food in a large area. If R2 ≥ ST, it means that the predator’s trace is found at the current location, and the discoverer needs to go to other safe areas for foraging activities at this time.The location update of followers is described as follows:(2)Xi,jt+1=Q⋅expXworstt−Xi,jti2,ifi>n2,XPt+1+Xi,jt−XPt+1⋅A+⋅L,otherwise.In formula (2), XPt+1 refers to the optimal position occupied by the discoverer in the t + 1-th iteration so far (the t + 1-th iteration has not ended) and Xworstt represents the worst position occupied by the group in the t-th iteration. A is a 1 × D matrix, and the elements in the matrix are randomly assigned values of 1 or −1, and A+ = AT(AAT)−1. If i > n/2, this means that the current follower is at the edge of the entire population and has no food. At this time, the follower needs to go elsewhere for food. Otherwise, the follower will go after the pace of the discoverer for food.When being aware of the danger, the sparrow population will make antipredatory behavior:(3)Xi,jt+1=Xbestt+β⋅Xi,jt−Xbestt,iffi≠fg,Xi,jt+K⋅Xi,jt−Xworsttfi−fw+ε,iffi=fg.In formula (3), Xbestt is the global optimal solution obtained in the t-th iteration. In the above formula, β, K, and ε are all parameters in the formula. β is a random number that obeys the standard normal distribution, and it is used to control the step size. K is an arbitrary random number from -1 to 1, it represents the direction in which the individual sparrow moves, and it is also a step control parameter. ε is a relatively small constant, and its function is to prevent the denominator from being zero. fi represents the fitness value of the i-th individual, and fg and fw are the best fitness value and the worst fitness value of the current iteration number, respectively.Iffi > fg, then this indicates that the individual is at the edge of the population and is easily preyed by natural enemies. If fi = fg, then this means that the individual is located in the center of the population. At this time, the sparrow needs to be close to other individuals to reduce the probability of being captured.


## 4. Adaptive Spiral Flying Sparrow Search Algorithm

### 4.1. Tent Chaotic Mapping Based on Random Variables

Because SSA has the shortcoming of large randomness, it is decided to introduce orderly and uniform tent mapping to improve it. Many scholars have applied tent mapping to solve the optimization problem [13]. However, tent mapping is not very stable. In [7], in order to reduce this influence, tent mapping based on random variables was adopted, which has a good effect. Therefore, in this paper, the tent mapping strategy based on random variables is introduced to improve the initialization of SSA, so that the initialization of the population is more orderly, and the controllability of the algorithm is enhanced. Its specific formula is as follows:(4)zi+1=2zi+rand0,1×1N,0≤z≤12,21−zi+rand0,1×1N,12≤z≤1.The expression after the Bernoulli transformation is(5)zi+1=2zimod1+rand0,1×1N.In formula (5), N is the number of particles in the chaotic sequence.According to the characteristics of the tent mapping, the sequence flow for generating chaos in the feasible domain is as follows:(1)
Randomly generate the initial valuez0 in (0, 1), and let i = 1.(2)
Perform iteration by using that formula (5) to generate a z sequence, and i is increased by 1.(3)
Stop if the number of iterations reaches the maximum, and store the generatedz sequence.


### 4.2. Adaptive Weighting

Weight strategies are common in particle swarm optimization algorithms [14]. Generally, the particle swarm algorithm reduces to some extent the trapping into local optimum by adaptively changing between the set maximum and minimum values. Inspired by this, this paper adds an inertia weight w which varies with the number of iterations in the discoverer stage of sparrow optimization. In the initial stage of the algorithm, it weakens the influence of random initialization and balances the Levy flight mechanism below, so as to enhance the local search and global search of the algorithm.The discoverer guides other individuals in the population to search for food, so the introduction of adaptive weights improves the quality of individual locations, enabling other individuals to converge faster to optimal locations, and overall accelerates the convergence rate. Based on the characteristics of sparrows, the formula for adaptive weights is as follows:(6)wt=0.2cosπ2⋅1−titermax.The meaning of formula (6) is that w has the property of nonlinear change between [0, 1]. According to the characteristics of cos function, the weight value is smaller at the beginning of the algorithm, but the optimization speed is faster and the later weight value is larger, but the change speed is slower, so the convergence property of the algorithm is balanced. The improved discoverer location is updated as follows:(7)Xi,jt+1=wt⋅Xi,jt⋅exp−iα⋅itermax,ifR2<ST,wt⋅Xi,jt+Q⋅L,ifR2≥ST.By introducing adaptive weights to dynamically adjust the position changes of sparrows, different guidance modes for the discoverer at different times make the algorithm search flexible. As the number of iterations increases, the individual sparrows converge toward the optimal position, and a larger weight makes the individual move faster, thus increased the convergence speed of the algorithm.


### 4.3. Levy Flight Mechanism

In SSA, there are few roles in the population, and the same role update position formula is the same, which will result in multiple individuals in the same optimal position. Too high solution repetition rate will reduce the efficiency of the algorithm, which is not conducive to the optimization of the algorithm. The discoverer has a wide search range and globality, and the adaptive weighting strategy is introduced to effectively improve the convergence effect. However, when facing the high-dimensional complex problems, there is still a probability of falling into local optimum. Therefore, the Levy flight strategy is introduced to improve the randomness of the algorithm solution, thereby enriching the diversity of population positions. This can also effectively improve the operating efficiency of the algorithm.Levy flight obeys the Levy distribution. Principle [15] and the Levy distribution is shown in Figure 1. It uses a random long- and short-distance mechanism to cover a large area. After adding the Levy flight mechanism, the performance of the proposed algorithm can be improved.Figure 1
Levy flight diagram.The location update format [16] for joining Levy flight strategy is as follows:(8)xi′t=xit+l⊕levyλ.In formula (8), xi(t) represents the position of the i-th individual in the t-th iteration, ⊕ is an arithmetic symbol representing point-to-point multiplication. l denotes a step length control parameter, which is obtained by this formula: l = 0.01(xi(t) − xp). levy(λ) is a path that obeys the Levy distribution, which represents the introduced Levy flight strategy and satisfies the following: levy～u=t−λ,1<λ≤3.Because Levy distribution is very complex, Mantegna algorithm is usually used to simulate it [17, 18]. The formula for calculating the step size is as follows:(9)s=μv1/γ,μ∼N0,σμ2,v∼N0,σv2,σμ=Γ1+γsinπγ/2γ⋅Γγ+1/2⋅2γ+1/21/γ.Among them,σv=1, and γ is generally 1.5.The introduction of the Levy flight strategy makes the sparrows more flexible at this stage and can also lead other individuals to find a better location, free from the constraints of local extremes. Therefore, the combination of Levy flight mechanism and adaptive weights balances the search method, and the quality of each solution obtained is improved to a certain extent, which greatly improves the search ability of the algorithm.


### 4.4. Variable Spiral Search Strategy

Followers update dynamically with the location of the discoverer, which leads to blindness and singularity in the way they search. Inspired by the rotation operation of the whale algorithm [19, 20], a variable spiral location update strategy is introduced to make follower location updates more flexible, develop a variety of search paths for location updates, and balance the global and local search of the algorithm. The spiral search diagram is shown in Figure 2.Figure 2
Schematic diagram of spiral search.In the follower location update process, the helix parameterz cannot be a fixed shape, which results in monotonous search methods and the possibility of falling into local optimum, thus weakens the search ability of the algorithm. The parameter z is designed as an adaptive variable to dynamically adjust the spiral shape of the follower search, which broadens the ability of the follower to explore the unknown region, improves both the search efficiency and the global search performance of the algorithm. The formula for the variable spiral position update strategy is as follows:(10)Xi,jt+1=ezl⋅cos2πl⋅Q⋅expXworstt−Xi,jti2,ifi>n2,XPt+1+Xi,jt−XPt+1⋅A+⋅L⋅ezl⋅cos2πl,otherwise,z=ek⋅cosπ⋅1−i/imax.The parameterz varies according to the number of iterations and is composed of an exponential function based on e. The size and amplitude of the helix are dynamically adjusted according to the properties of cos function. k is the coefficient of change. According to the optimization characteristics of each function, in order to make the algorithm have a suitable search range, k = 5. L is a uniformly distributed random number of [−1, 1]. With the range of follower position updating is from large to small, more quality solutions are found in the early stage, and late optimization reduces the increase of idle work, which improves the global optimal search performance of the algorithm. At the same time, according to the spiral characteristics, the optimization accuracy of the algorithm is improved to a certain extent.


### 4.5. Process for Improving Sparrow Search Algorithm

The sparrow search algorithm has better optimization performance than other algorithms, but it still depends on the initial population so that it is easy to fall into a local optimal state. In order to improve these shortcomings, this paper proposes an adaptive spiral flying sparrow search algorithm. Initially, the population was initialized by tent chaotic mapping based on random variables to provide adequate preparation for the discoverer’s optimization. Then, adaptive weights and Levy flight strategies were introduced to make the discoverer’s position update method more extensive and flexible, and then a variable spiral was proposed. The strategy makes the follower’s search more detailed, avoids premature phenomenon, and speeds up the optimization speed of the algorithm.The specific implementation steps of ASFSSA are as follows:Step 1: initialize the sparrow population parameters, for example, the total population pop, the total number of discoverers pNum, the total number of iterations iter, and the solution accuracyε.Step 2: use tent mapping to initialize the position of population individuals, and generate pop sparrow individuals.Step 3: use the correlation function to calculate the fitness valuefi of each population individual, and find the maximum fitness value fg and the minimum fitness value fw.Step 4: sort the population according to the fitness value.Step 5: select the individuals with the top pNum fitness as the discoverer, and the rest are followers, and use formulas (7) and (8) after adding the strategy to update the position of the discoverer.Step 6: use formula (10) to update the positions of pop-pNum followers.Step 7: use formula (3) to update the position of the sparrow that is aware of the danger.Step 8: after one iteration is completed, recalculate the fitness valuefi of each individual, and update the maximum fitness value fg, the minimum fitness value fw, and the corresponding position.Step 9: judge whether the algorithm has reached the maximum number of iterations or the accuracy of the solution. If it has reached, the optimization result will be output; otherwise, it will return to Step 4.The specific flowchart is shown in Figure3.Figure 3
Algorithm flowchart.


## 4.1. Tent Chaotic Mapping Based on Random Variables

Because SSA has the shortcoming of large randomness, it is decided to introduce orderly and uniform tent mapping to improve it. Many scholars have applied tent mapping to solve the optimization problem [13]. However, tent mapping is not very stable. In [7], in order to reduce this influence, tent mapping based on random variables was adopted, which has a good effect. Therefore, in this paper, the tent mapping strategy based on random variables is introduced to improve the initialization of SSA, so that the initialization of the population is more orderly, and the controllability of the algorithm is enhanced. Its specific formula is as follows:(4)zi+1=2zi+rand0,1×1N,0≤z≤12,21−zi+rand0,1×1N,12≤z≤1.The expression after the Bernoulli transformation is(5)zi+1=2zimod1+rand0,1×1N.In formula (5), N is the number of particles in the chaotic sequence.According to the characteristics of the tent mapping, the sequence flow for generating chaos in the feasible domain is as follows:(1)
Randomly generate the initial valuez0 in (0, 1), and let i = 1.(2)
Perform iteration by using that formula (5) to generate a z sequence, and i is increased by 1.(3)
Stop if the number of iterations reaches the maximum, and store the generatedz sequence.


## 4.2. Adaptive Weighting

Weight strategies are common in particle swarm optimization algorithms [14]. Generally, the particle swarm algorithm reduces to some extent the trapping into local optimum by adaptively changing between the set maximum and minimum values. Inspired by this, this paper adds an inertia weight w which varies with the number of iterations in the discoverer stage of sparrow optimization. In the initial stage of the algorithm, it weakens the influence of random initialization and balances the Levy flight mechanism below, so as to enhance the local search and global search of the algorithm.The discoverer guides other individuals in the population to search for food, so the introduction of adaptive weights improves the quality of individual locations, enabling other individuals to converge faster to optimal locations, and overall accelerates the convergence rate. Based on the characteristics of sparrows, the formula for adaptive weights is as follows:(6)wt=0.2cosπ2⋅1−titermax.The meaning of formula (6) is that w has the property of nonlinear change between [0, 1]. According to the characteristics of cos function, the weight value is smaller at the beginning of the algorithm, but the optimization speed is faster and the later weight value is larger, but the change speed is slower, so the convergence property of the algorithm is balanced. The improved discoverer location is updated as follows:(7)Xi,jt+1=wt⋅Xi,jt⋅exp−iα⋅itermax,ifR2<ST,wt⋅Xi,jt+Q⋅L,ifR2≥ST.By introducing adaptive weights to dynamically adjust the position changes of sparrows, different guidance modes for the discoverer at different times make the algorithm search flexible. As the number of iterations increases, the individual sparrows converge toward the optimal position, and a larger weight makes the individual move faster, thus increased the convergence speed of the algorithm.


## 4.3. Levy Flight Mechanism

In SSA, there are few roles in the population, and the same role update position formula is the same, which will result in multiple individuals in the same optimal position. Too high solution repetition rate will reduce the efficiency of the algorithm, which is not conducive to the optimization of the algorithm. The discoverer has a wide search range and globality, and the adaptive weighting strategy is introduced to effectively improve the convergence effect. However, when facing the high-dimensional complex problems, there is still a probability of falling into local optimum. Therefore, the Levy flight strategy is introduced to improve the randomness of the algorithm solution, thereby enriching the diversity of population positions. This can also effectively improve the operating efficiency of the algorithm.Levy flight obeys the Levy distribution. Principle [15] and the Levy distribution is shown in Figure 1. It uses a random long- and short-distance mechanism to cover a large area. After adding the Levy flight mechanism, the performance of the proposed algorithm can be improved.Figure 1
Levy flight diagram.The location update format [16] for joining Levy flight strategy is as follows:(8)xi′t=xit+l⊕levyλ.In formula (8), xi(t) represents the position of the i-th individual in the t-th iteration, ⊕ is an arithmetic symbol representing point-to-point multiplication. l denotes a step length control parameter, which is obtained by this formula: l = 0.01(xi(t) − xp). levy(λ) is a path that obeys the Levy distribution, which represents the introduced Levy flight strategy and satisfies the following: levy～u=t−λ,1<λ≤3.Because Levy distribution is very complex, Mantegna algorithm is usually used to simulate it [17, 18]. The formula for calculating the step size is as follows:(9)s=μv1/γ,μ∼N0,σμ2,v∼N0,σv2,σμ=Γ1+γsinπγ/2γ⋅Γγ+1/2⋅2γ+1/21/γ.Among them,σv=1, and γ is generally 1.5.The introduction of the Levy flight strategy makes the sparrows more flexible at this stage and can also lead other individuals to find a better location, free from the constraints of local extremes. Therefore, the combination of Levy flight mechanism and adaptive weights balances the search method, and the quality of each solution obtained is improved to a certain extent, which greatly improves the search ability of the algorithm.


## 4.4. Variable Spiral Search Strategy

Followers update dynamically with the location of the discoverer, which leads to blindness and singularity in the way they search. Inspired by the rotation operation of the whale algorithm [19, 20], a variable spiral location update strategy is introduced to make follower location updates more flexible, develop a variety of search paths for location updates, and balance the global and local search of the algorithm. The spiral search diagram is shown in Figure 2.Figure 2
Schematic diagram of spiral search.In the follower location update process, the helix parameterz cannot be a fixed shape, which results in monotonous search methods and the possibility of falling into local optimum, thus weakens the search ability of the algorithm. The parameter z is designed as an adaptive variable to dynamically adjust the spiral shape of the follower search, which broadens the ability of the follower to explore the unknown region, improves both the search efficiency and the global search performance of the algorithm. The formula for the variable spiral position update strategy is as follows:(10)Xi,jt+1=ezl⋅cos2πl⋅Q⋅expXworstt−Xi,jti2,ifi>n2,XPt+1+Xi,jt−XPt+1⋅A+⋅L⋅ezl⋅cos2πl,otherwise,z=ek⋅cosπ⋅1−i/imax.The parameterz varies according to the number of iterations and is composed of an exponential function based on e. The size and amplitude of the helix are dynamically adjusted according to the properties of cos function. k is the coefficient of change. According to the optimization characteristics of each function, in order to make the algorithm have a suitable search range, k = 5. L is a uniformly distributed random number of [−1, 1]. With the range of follower position updating is from large to small, more quality solutions are found in the early stage, and late optimization reduces the increase of idle work, which improves the global optimal search performance of the algorithm. At the same time, according to the spiral characteristics, the optimization accuracy of the algorithm is improved to a certain extent.


## 4.5. Process for Improving Sparrow Search Algorithm

The sparrow search algorithm has better optimization performance than other algorithms, but it still depends on the initial population so that it is easy to fall into a local optimal state. In order to improve these shortcomings, this paper proposes an adaptive spiral flying sparrow search algorithm. Initially, the population was initialized by tent chaotic mapping based on random variables to provide adequate preparation for the discoverer’s optimization. Then, adaptive weights and Levy flight strategies were introduced to make the discoverer’s position update method more extensive and flexible, and then a variable spiral was proposed. The strategy makes the follower’s search more detailed, avoids premature phenomenon, and speeds up the optimization speed of the algorithm.The specific implementation steps of ASFSSA are as follows:Step 1: initialize the sparrow population parameters, for example, the total population pop, the total number of discoverers pNum, the total number of iterations iter, and the solution accuracyε.Step 2: use tent mapping to initialize the position of population individuals, and generate pop sparrow individuals.Step 3: use the correlation function to calculate the fitness valuefi of each population individual, and find the maximum fitness value fg and the minimum fitness value fw.Step 4: sort the population according to the fitness value.Step 5: select the individuals with the top pNum fitness as the discoverer, and the rest are followers, and use formulas (7) and (8) after adding the strategy to update the position of the discoverer.Step 6: use formula (10) to update the positions of pop-pNum followers.Step 7: use formula (3) to update the position of the sparrow that is aware of the danger.Step 8: after one iteration is completed, recalculate the fitness valuefi of each individual, and update the maximum fitness value fg, the minimum fitness value fw, and the corresponding position.Step 9: judge whether the algorithm has reached the maximum number of iterations or the accuracy of the solution. If it has reached, the optimization result will be output; otherwise, it will return to Step 4.The specific flowchart is shown in Figure3.Figure 3
Algorithm flowchart.


## 5. Algorithm Performance Test

To test the optimization capability of the improved algorithm, 18 standard test functions are selected to verify the performance. The test functions are listed in Table1. The first 10 are unimodal functions, the middle 4 are complex multimodal functions, and the last 4 are fixed-dimension function. In order to increase the experimental convincing, it is necessary to compare the particle swarm algorithm (PSO), gray wolf algorithm (GWO), beetle swarm optimization (BSO), SSA, CSSA, and the proposed algorithm optimization effect. Among them, CSSA is an improved sparrow search algorithm in the literature [5], and BSO [21] is a new algorithm which combines beetle antennae search algorithm (BAS) [22] and PSO, and the research on this algorithm is very popular. The complexity and parameters of all algorithms are shown in Table 2.Table 1
Test function table.
FunctionDim (D)IntervalMinF1x=∑i=1nxi230[−100, 100]0F2x=∑i=1nxi+∏i=1nxi30[−10, 10]0F3x=∑i=1n∑j=1nxj230[−100, 100]0F4x=maxixi,1≤i≤n30[−100, 100]0F5x=∑i=1n−1100xi+1−xi22+xi−1230[−30, 30]0F6x=∑i=1nxi+0.5230[−100, 100]0F7=∑i=1dxi2+∑i=1d0.5ixi2+∑i=1d0.5ixi430[−5, 10]0F8x=∑i=1d/4x4i−3+10x4i−22+5x4i−1−x4i2+x4i−2−2x4i−14+10x4i−3−x4i430[−4, 5]0F9x=∑i=1dxii+130[−100, 100]d0F10x=∑i=1nixi4+random0,130[−1.28, 1.28]0F11x=∑i=1n−xisinxi30[−500, 500]-418.9829nF12=418.9829n−∑i=1nxisinxi30[−500, 500]0F13=sin2πw1+∑i=1d−1wi−121+10sin2πwi+1+wd−121+sin22πwdwhilewi=1+xi−1/4,∀i=1,…,d30[−10, 10]d0F14x=∑i=1d−1100xi2−xi+12+xi−1230[−10, 10]d0F15=sin23πx1+x1−121+sin23πx2+x2−121+sin22πx22[−10, 10]0F16x=2x12−1.05x14+x16/6+x1x2+x222[−5, 5]0F17x=1.5−x1+x1x22+2.25−x1+x1x222+2.625−x1+x1x2322[−4.5, 4.5]0F18x=0.002+∑i=1251/i+x1−a1i6+x2−a2i6−1,wherea=−32−1601632−32…01632−32−32−32−32−32−16…3232322[−65.536.65.536]0.998Table 2
The complexity and parameters of each algorithm.
AlgorithmTime complexitySpace complexityIteration and populationParameter settingASFSSAO (P × M × D)O (N × D)Iteration = 200, population = 100ε = 1e − 50BSOeta = 0.95,c = 2, k = 0.4, step0 = 0.9, step1 = 0.2CSSAε = 1e − 50SSAε = 1e − 50GWO—PSOc1 = c2 = 2,w = 0.728The population number of all algorithms is 100; the number of iterations is 200. In PSO, c1 = c2 = 2,w = 0.728. The BSO parameter settings are as follows: eta = 0.95, c = 2, k = 0.4, step0 = 0.9, and step1 = 0.2. The upper and lower limits of all algorithms are given in the test function table. The experimental environment is MATLAB 2018b, the Windows 10 operating system, and the running memory is 8G. In order to enhance the experimental persuasion, exclude the influence of accidental events, and count the minimum (min) value, average (aver) value, and standard (std) deviation of each algorithm, which reflect the optimization ability and stability of each algorithm. The comparison table of optimization effect of each algorithm is shown in Table 3, and the convergence of each algorithm function is shown in Figure 4.Table 3
Table of optimization results of each algorithm.
FunctionAlgorithmBestAverStdF1(x)ASFSSA000BSO8.1585126.385114.9876CSSA000SSA05.192E − 2510GWO1.4406E − 1031.56961E − 975.36616E − 97PSO3.8599E − 123.0697E − 112.7076E − 11F2(x)ASFSSA000BSO0.2122191.88362.13278CSSA03.8973E − 1602.1346E − 159SSA02.2022E − 1448.4437E − 144GWO1.6295E − 252.9050E − 234.4358E − 23PSO8.9056E − 082.5055E − 071.4584E − 07F3(X)ASFSSA000BSO0.000494515.145934.9405CSSA04.2858E − 1920SSA07.7137E − 2100GWO2.2250E − 040.0294310.070791PSO22.259249.959618.1286F4(X)ASFSSA000BSO0.015030.0150261.40522CSSA04.1077E − 1412.2499E − 140SSA4.0636E − 141.9036E − 072.9266E − 07GWO2.4178E − 066.4757E − 062.1850E − 06PSO8.1218E − 146.9044E − 137.0838E − 13F5(X)ASFSSA2.5510E − 099.6950E − 063.977E − 05BSO553.70412543.21611657.5282CSSA1.3357E − 082.6062E − 040.0015114SSA4.7653E − 090.000283250.00049636GWO45.856547.38550.89355PSO89.4507234.8606104.6002F6(X)ASFSSA1.2670E − 172.5726E − 154.5874E − 15BSO1.4135E − 192.7997E − 101.4985E − 09CSSA1.2204E − 178.1489E − 151.1839E − 14SSA4.0636E − 141.0936E − 072.9266E − 07GWO2.4178E − 066.4757E − 062.185E − 06PSO8.1218E − 146.9044E − 137.0838E − 13F7(X)ASFSSA000BSO10.967976.889744.1926CSSA02.6949E − 1531.476E − 152SSA06.9176E − 1393.7889E − 138GWO1.1787E − 062.2057E − 052.7228E − 05PSO30.872558.718918.8337F8(X)ASFSSA000BSO1.46969.24895.9505CSSA01.7622E − 2790SSA02.3385E − 2700GWO6.7719E − 065.7427E − 055.9614E − 05PSO0.0175460.180780.14242F9(X)ASFSSA000BSO7.8221E − 462.0384E − 393.2288E − 39CSSA06.07E − 953.3246E − 94SSA08.7599E − 974.798E − 96GWO09.7069E − 2510PSO1.6341E − 296.6714E − 241.2043E − 23F10(X)ASFSSA1.0044E − 059.5155E − 058.3380E − 05BSO0.00388130.0096744570.004701CSSA9.9226E − 060.000260620.00016246SSA5.318E − 050.000295820.00025735GWO0.000403740.00202520.89355PSO0.0102010.0300150.00096086F11(X)ASFSSA−12569.3148−11107.0762796.9218BSO−12569.4418−11820.3055973.8153CSSA−9859.7543−8700.9989615.6127SSA−9374.4498−8208.1416501.1037GWO−9055.703−6452.3541033.4608PSO−8405.1316−6176.2342793.1086F12(X)ASFSSA0.4900471270.9199964.1809BSO0.03331848.28181061.7445CSSA2529.39743661.9962725.5963SSA3471.6704394292.617883529.1990723GWO4866.18356134.3633604.5177PSO5205.78037638.93871024.9673F13(X)ASFSSA7.2046E − 113.1056E − 076.4439E − 07BSO3.50958.4787E + 543.4748E + 55CSSA3.6686E − 111.6611E − 056.0978E − 05SSA1.1633E − 096.0348E − 071.8076E − 06GWO1.0500E + 541.4300E + 575.7000E + 57PSO1.5273E + 601.9700E + 602.1400E + 59F14(X)ASFSSA04.9628E − 052.5146E − 04BSO1.3048E − 234.77072E − 216.0171E − 21CSSA6.2203E − 080.00127510.0037596SSA2.9797E − 080.000341060.00062708GWO1.0500E + 541.4300E + 575.6800E + 57PSO2.0728E + 873.3100E + 875.6800E + 86F15(X)ASFSSA1.3498E − 311.3498E − 310BSO1.3498E − 311.3498E − 310CSSA1.4730E − 312.3043E − 293.9261E − 29SSA1.3498E − 313.9049E − 295.2232E − 29GWO1.0606E − 088.9305E − 077.8567E − 07PSO1.30489E − 234.7707E − 216.0171E − 21F16(X)ASFSSA000BSO1.2475E − 421.8013E − 411.9512E − 41CSSA04.9534E − 2850SSA03.7547E − 2370GWO2.6095E − 1662.1062E − 1311.0027E − 130PSO4.0625E − 256.4627E − 221.8985E − 21F17(X)ASFSSA2.9038E − 252.3672E − 197.0572E − 19BSO00.25400.3592CSSA4.3789E − 213.2277E − 161.5937E − 15SSA2.7959E − 211.2661E − 162.7684E − 16GWO1.2267E − 084.0761E − 074.2024E − 07PSO1.1013E − 228.1661E − 201.7949E − 19F18(X)ASFSSA0.9980.9980BSO0.9981.03110.17843CSSA0.9982.10682.9273SSA0.9982.55943.6421GWO0.9982.80132.8092PSO0.9981.19680.3976Figure 4
Convergence effect diagram of each algorithm. (a)F1. (b) F2. (c) F3. (d) F4. (e) F5. (f) F6. (g) F7. (h) F8. (i) F9. (j) F10. (k) F11. (l) F12. (m) F13. (n) F14. (o) F15. (p) F16. (q) F17. (r) F18.
(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)(o)(p)(q)(r)From Table3, we can see that the ASFSSA has the best performance in function optimization, especially in F1–F4, F7–F9, F16, and F18, which can find the optimal value each time. The results of CSSA come later, and PSO and GWO are the worst, especially when the boundary is complex. The BSO has good optimization characteristics in the F10, F11, and F17 functions, but the effect in other algorithms has great shortcomings, and the effect is the worst. It can be seen that BSO has the limitation of the optimization ability. Among these three functions, the optimization effect of ASFSSA is second only to it. Generally speaking, ASFSSA has a good convergence speed and accuracy on unimodal functions, and it has a strong ability to resist local extremes on multimodal functions. Therefore, the introduction of multiple strategies significantly improves the stability and searching ability of the algorithm.From Figure4, we can see that ASFSSA has a significant improvement in convergence speed and accuracy. Especially, the ASFSSA has very fast convergence speed and very high convergence precision in the functions of F1–F5, F7–F10, F15-F16 and has obvious ability of resisting local attraction in the functions of F5, F10, and F15. ASFSSA has good convergence effect in F6, F13, F14, and F17 functions, but there a few differences with other algorithms. BSO has better performance in the three functions of F11-F12 and F18, and ASFSSA has the second best performance, but BSO has worse performance in the other functions, and some functions have worse performance than PSO. The convergence effect of other algorithms is insufficient. Thus, it can be seen that the introduction of multistrategy makes the algorithm get rid of the insufficient search mode in the optimization process, open up a more flexible and detailed search, and improve the convergence ability of the algorithm.


### 5.1. Wilcoxon Rank Sum Test

It is not comprehensive to simply calculate the indexes of the running results of each algorithm. In order to highlight the superiority of the ASFSSA algorithm, it is necessary to carry out the statistical test. In order to reflect the fairness, the Wilcoxon rank sum test [20] is used to verify whether the results of each run of ASFSSA are significantly different from those of other algorithms at the P=5% significance level. If P<5%, it can be considered that there is a significant difference between the two algorithms; if P>5%, it means that the difference between the two algorithms is not obvious; that is, the optimization performance of the two algorithms is equivalent. Table 4 shows the results for ASFSSA and PSO, GWO, BSO, SSA, and CSSA are at a significance level of P=5%, where N/A indicates that the performance between the two is similar and not comparable.Table 4
Wilcoxon rank sum testP value.
FunctionBSOCSSASSAPSOGWOF1(X)1.2118e − 12N/AN/A1.2118e − 121.2118e − 12F2(X)1.2118e − 128.8658e − 075.3750e − 061.2118e − 121.2118e − 12F3(X)1.2118e − 120.0216N/A1.2118e − 121.2118e − 12F4(X)1.2118e − 126.6096e − 056.6096e − 051.2118e − 121.2118e − 12F5(X)3.0199e − 110.0184N/A3.0199e − 113.0199e − 11F6(X)0.00101.0937e − 101.6132e − 103.0199e − 113.0199e − 11F7(X)1.2118e − 120.00561.4552e − 041.2118e − 121.2118e − 12F8(X)1.2118e − 120.04190.04191.2118e − 121.2118e − 12F9(X)1.2118e − 128.8658e − 073.4526e − 071.2118e − 121.6572e − 11F10(X)3.0199e − 110.03780.02423.0199e − 113.1589e − 10F11(X)1.1023e − 080.00255.5999e − 074.5043e − 111.2057e − 10F12(X)4.8011e − 070.00204.5726e − 093.0199e − 113.0199e − 11F13(X)3.0199e − 11N/AN/A3.0199e − 113.0199e − 11F14(X)3.0199e − 11N/AN/A3.0199e − 113.0199e − 11F15(X)N/A1.1970e − 121.6572e − 111.2118e − 121.2118e − 12F16(X)1.2118e − 12N/AN/A1.2118e − 121.2118e − 12F17(X)N/A2.9468e − 112.9468e − 112.9468e − 112.9468e − 11F18(X)4.4787e − 060.00710.02360.02001.4930e − 11As can be seen from Table3, each algorithm is significantly different from the ASFSSA algorithm, with only a few cases of comparable performance. It can be seen that the introduction of multiple strategies improves the disadvantages of the original algorithm and enhances the optimization ability of the algorithm.


## 5.1. Wilcoxon Rank Sum Test

It is not comprehensive to simply calculate the indexes of the running results of each algorithm. In order to highlight the superiority of the ASFSSA algorithm, it is necessary to carry out the statistical test. In order to reflect the fairness, the Wilcoxon rank sum test [20] is used to verify whether the results of each run of ASFSSA are significantly different from those of other algorithms at the P=5% significance level. If P<5%, it can be considered that there is a significant difference between the two algorithms; if P>5%, it means that the difference between the two algorithms is not obvious; that is, the optimization performance of the two algorithms is equivalent. Table 4 shows the results for ASFSSA and PSO, GWO, BSO, SSA, and CSSA are at a significance level of P=5%, where N/A indicates that the performance between the two is similar and not comparable.Table 4
Wilcoxon rank sum testP value.
FunctionBSOCSSASSAPSOGWOF1(X)1.2118e − 12N/AN/A1.2118e − 121.2118e − 12F2(X)1.2118e − 128.8658e − 075.3750e − 061.2118e − 121.2118e − 12F3(X)1.2118e − 120.0216N/A1.2118e − 121.2118e − 12F4(X)1.2118e − 126.6096e − 056.6096e − 051.2118e − 121.2118e − 12F5(X)3.0199e − 110.0184N/A3.0199e − 113.0199e − 11F6(X)0.00101.0937e − 101.6132e − 103.0199e − 113.0199e − 11F7(X)1.2118e − 120.00561.4552e − 041.2118e − 121.2118e − 12F8(X)1.2118e − 120.04190.04191.2118e − 121.2118e − 12F9(X)1.2118e − 128.8658e − 073.4526e − 071.2118e − 121.6572e − 11F10(X)3.0199e − 110.03780.02423.0199e − 113.1589e − 10F11(X)1.1023e − 080.00255.5999e − 074.5043e − 111.2057e − 10F12(X)4.8011e − 070.00204.5726e − 093.0199e − 113.0199e − 11F13(X)3.0199e − 11N/AN/A3.0199e − 113.0199e − 11F14(X)3.0199e − 11N/AN/A3.0199e − 113.0199e − 11F15(X)N/A1.1970e − 121.6572e − 111.2118e − 121.2118e − 12F16(X)1.2118e − 12N/AN/A1.2118e − 121.2118e − 12F17(X)N/A2.9468e − 112.9468e − 112.9468e − 112.9468e − 11F18(X)4.4787e − 060.00710.02360.02001.4930e − 11As can be seen from Table3, each algorithm is significantly different from the ASFSSA algorithm, with only a few cases of comparable performance. It can be seen that the introduction of multiple strategies improves the disadvantages of the original algorithm and enhances the optimization ability of the algorithm.


## 6. Robot Path Planning Based on ASFSSA

To verify the feasibility and practicability of the improved algorithm, this paper takes a classic case of robot route planning to explore it. Each individual sparrow is a viable path in routing. Assuming there areN possible paths, dimension D is determined by the number of connections from the starting point to the destination point. Using the raster method to model the environment, the raster method is to use 1 ∗ 1 raster to construct the equivalent working environment, and use the raster value to equivalent the obstacles in the location [23, 24]. This effectively equates the working environment of the robot to a plane, similar to the lattice effect, and then determines the feasible and obstacle zones based on the raster values.The raster number defines 0 as the feasible domain and 1 as the obstacle zone, so the robot can plan its path on the raster with a value of 0. DimensionD is the number of columns in the raster map and the cost function of the path length of the i-th sparrow individual, as shown in the following equation:(11)fxi=∑j=1D−1xj+1−xj2+yj+1−yj2.In equation (11), j is the j-th dimension of a sparrow individual.


### 6.1. Experimental Environment Settings

To better verify the practicability and feasibility of the improved algorithm, the improved algorithm is used to route the raster maps of the two models. Compared with CSSA, SSA, and PSO, the number of population is 20 and the number of iterations is 100. Other environmental parameters are consistent with the above.


### 6.2. Simulation Results and Analysis

The optimal route of each algorithm in the two model graphs is shown in Figures5 and 6. In order to eliminate the influence of chance, each algorithm is tested for 10 times, and the shortest, average, and worst route of each algorithm are counted. Three indicators are used to measure the stability and feasibility of each algorithm in this experiment. The optimization statistical table of each algorithm is shown in Table 5, and the average route convergence chart is shown in Figure 7.Figure 5
10∗ 10 shortest path planning diagram. (a) ASFSSA. (b) CSSA. (c) SSA. (d) PSO.
(a)(b)(c)(d)Figure 6
15∗ 15 shortest path planning diagram. (a) ASFSSA. (b) CSSA. (c) SSA. (d) PSO.
(a)(b)(c)(d)Table 5
Statistics table of optimization route by algorithms.
Map sizePerformance indexASFSSACSSASSAPSO10∗ 10Shortest12.727912.727915.556415.5564Average13.859314.425020.647521.2132Worse15.556420.647521.213241.012220∗ 20Shortest19.799022.627422.627425.4559Average20.930423.758824.324426.0215Worst22.627425.455931.112731.1127Figure 7
The average route convergence graph of each algorithm. (a) 10∗ 10. (b) 15 ∗ 15.
(a)(b)As shown in Figures5 and 6, the ASFSSA route is the simplest and clearest, followed by CSSA, while PSO and SSA are obviously trapped in local optimum. From Table 5, we can see that ASFSSA has the best searching ability and stability in both of raster graphs, and CSSA has better stability. However, from Figure 7, we can see that the convergence of SSA and PSO is insufficient, and the optimization results of SSA and PSO are extremely unstable and poor. Therefore, in the two model diagrams, the introduction of multiple strategies makes the algorithm flexible in the search, greatly improves the search ability of the algorithm, and plans a route with the least cost.


## 6.1. Experimental Environment Settings

To better verify the practicability and feasibility of the improved algorithm, the improved algorithm is used to route the raster maps of the two models. Compared with CSSA, SSA, and PSO, the number of population is 20 and the number of iterations is 100. Other environmental parameters are consistent with the above.


## 6.2. Simulation Results and Analysis

The optimal route of each algorithm in the two model graphs is shown in Figures5 and 6. In order to eliminate the influence of chance, each algorithm is tested for 10 times, and the shortest, average, and worst route of each algorithm are counted. Three indicators are used to measure the stability and feasibility of each algorithm in this experiment. The optimization statistical table of each algorithm is shown in Table 5, and the average route convergence chart is shown in Figure 7.Figure 5
10∗ 10 shortest path planning diagram. (a) ASFSSA. (b) CSSA. (c) SSA. (d) PSO.
(a)(b)(c)(d)Figure 6
15∗ 15 shortest path planning diagram. (a) ASFSSA. (b) CSSA. (c) SSA. (d) PSO.
(a)(b)(c)(d)Table 5
Statistics table of optimization route by algorithms.
Map sizePerformance indexASFSSACSSASSAPSO10∗ 10Shortest12.727912.727915.556415.5564Average13.859314.425020.647521.2132Worse15.556420.647521.213241.012220∗ 20Shortest19.799022.627422.627425.4559Average20.930423.758824.324426.0215Worst22.627425.455931.112731.1127Figure 7
The average route convergence graph of each algorithm. (a) 10∗ 10. (b) 15 ∗ 15.
(a)(b)As shown in Figures5 and 6, the ASFSSA route is the simplest and clearest, followed by CSSA, while PSO and SSA are obviously trapped in local optimum. From Table 5, we can see that ASFSSA has the best searching ability and stability in both of raster graphs, and CSSA has better stability. However, from Figure 7, we can see that the convergence of SSA and PSO is insufficient, and the optimization results of SSA and PSO are extremely unstable and poor. Therefore, in the two model diagrams, the introduction of multiple strategies makes the algorithm flexible in the search, greatly improves the search ability of the algorithm, and plans a route with the least cost.


## 7. Conclusion

The sparrow search algorithm has better performance than other algorithms in optimization, but it is still easy to get stuck in local and rely on population initialization. This paper analyzes these defects and proposes an adaptive spiral flying sparrow search algorithm. Firstly, tent mapping based on random variables is used to initialize the population, which makes the distribution of sparrow individuals uniform and helps the individuals to work better. Secondly, the adaptive weights strategy and Levy flight mechanism are used in the discoverer stage, which makes the discoverer flexible and adaptable in the optimization process and reduces the traditional regular strategy. Finally, the variable spiral search strategy is used in the follower stage, which makes the follower search method more detailed and in-depth, and improves the convergence accuracy of the algorithm. The effectiveness of the improved algorithm is verified by 18 test functions and the comparison of other algorithms. Compared with other algorithms, ASFSSA has significant optimization capabilities. At the same time, the feasibility and practicability of the improved algorithm are verified by the robot path planning study. The path planned by the improved algorithm is clear, and the cost function is the smallest. It can be seen that the introduction of multiple strategies has effectively improved the optimization ability of the basic sparrow search algorithm. However, in some functions, the optimization effect of ASFSSA is second only to the BSO algorithm. In the future research phase, how to improve these optimization effect is the research focus, and it needs to be upgraded to more complex applications.



---

*Source: 6505253-2021-08-27.xml*