Improved Sparrow Algorithm Based on Game Predatory Mechanism and Suicide Mechanism

In order to overcome the defect that sparrow search algorithm converges very fast but is easy to fall into the trap of local optimization, based on the original mechanism of sparrow algorithm, this paper proposes game predatory mechanism and suicide mechanism, which makes sparrow algorithm more in line with its biological characteristics and enhances the ability of the algorithm to get rid of the attraction of local optimization while retaining the advantages of fast convergence speed. By initializing the population with the good point set strategy, the quality of the initial population is guaranteed and the diversity of the population is enhanced. In view of the current situation that the diversity index evaluation does not consider the invalid search caused by individuals beyond the boundary in the search process, an index to measure the invalid search beyond the boundary in the search process is proposed, and the measurement of diversity index is further improved to make it more accurate. The improved algorithm is tested on six basic functions and CEC2017 test function to verify its effectiveness. Finally, the improved algorithm is applied to the three-dimensional path planning of UAV with threat area. The results show that the improved algorithm has stronger optimization performance, has strong competitiveness compared with other algorithms, and can quickly plan the effective and stable path of UAV, which improves an effective method for the application in this field and other fields.


Introduction
With the progress of modern technology, intelligent algorithms also continue to develop [1][2][3][4][5] and are applied to all kinds of engineering applications and real life. Comparing the swarm intelligence optimization algorithm and traditional optimization algorithm, the former is a heuristic search technology based on biological population characteristics. It has fast convergence speed, strong robustness, and high stability. With its own self-organization and adaptive characteristics, it can effectively solve complex optimization problems. e continuous development of swarm intelligence algorithm not only opens up a new world for solving various complex engineering problems but also stimulates the great research interest of scholars. Various swarm intelligence optimization algorithms appear one after another, and the family of swarm intelligence optimization algorithms has been unprecedentedly developed [6][7][8][9]. New algorithms are constantly proposed, such as naked mole-rat algorithm (NMRA) [10], firefly algorithm (FA) [11], ant lion optimizer (ALO) [12], whale optimization algorithm (WOA) [13], sine cosine algorithm (SCA) [14], crow search algorithm (CSA) [15], Harris hawks optimization (HHO) [16], slime mould algorithm (SMA) [17], hunger games search (HGS) [18], Runge-Kutta method [19], and colony predation algorithm (CPA) [20].
Inspired by sparrows' foraging behavior, predatory behavior, and antipredation behavior, a new swarm intelligence optimization algorithm, sparrow search algorithm (SSA) [21], was proposed by Xue et al. in 2020. Compared with traditional intelligent optimization algorithms, such as bat algorithm (BA) [22], grey wolf optimization (GWO) [23], and whale optimization algorithm (WOA) [13], SSA has the advantages of fast convergence, high stability, and strong robustness [24]. e algorithm has the advantage of fast convergence speed, but the global search ability is poor, the optimization results have great randomness, and it is easy to fall into the trap of local optimization. In view of this defect, many scholars have proposed different improvement strategies to improve the performance of sparrow algorithm and successfully solve many complex engineering problems [25]. In literature [26], the search mechanism of bird swarm algorithm replaces the original search mechanism, enhances the global search ability, and effectively breaks through the local limited search. Literature [27] makes full use of the current dominant individuals through the iterative local search mechanism, making the search method more diversified and the optimization accuracy more detailed. Literature [28] introduced the dimension-by-dimension lens learning mechanism to reduce the interference between dimensions and accelerate the convergence of the population. Inspired by logistic model, literature [29] proposed a new adaptive factor to dynamically control the safety threshold, which balances the ability of global search and local development of the algorithm. e above algorithm has improved the sparrow algorithm and achieved some results, but there are still some shortcomings: (1) e improved initialization method still has some randomness, which cannot guarantee the quality of each initialization population. (2) e mechanism that the follower only pillages food with the discoverer's optimal solution does not accord with the characteristics of biological population and makes insufficient use of other optimal solutions, so it is easy to skip the global optimal solution and miss it. (3) e location update method of followers is to directly jump to the vicinity of the current optimal solution. Although this method leads to the advantage of fast convergence speed, it is also very easy to fall into local optimization. Once it cannot jump out of local optimization, it will reduce the optimization performance.
To solve the above problems, based on the summary of previous work, this paper presents an improved sparrow search algorithm based on game predatory mechanism and suicide mechanism (GPSSA), which helps to improve the shortcomings of SSA algorithm, such as fast convergence speed while being easy to fall into local optimization. is paper presents an improved sparrow search algorithm based on game predatory mechanism and suicide mechanism, which is more in line with the biological habits of sparrow population, ensures more uniform population through a good point set, makes full use of the better individuals in the population through game predatory mechanism and ensures the flexibility of search, and helps the algorithm jump out of local optimum through suicide mechanism. An invalid search index is presented for the true location of individuals beyond the boundary during the search process, which improves the defect of the original index and makes it more accurate and realistic to reflect the population diversity, exploration, and development stages in the search process. e improved GPSSA has the advantages of good initialization population quality, flexible search ability, good population diversity, and fast convergence speed. It is easy to get rid of the characteristics of local optimal attraction. e main contributions are as follows: (1) By adding good point set, the initial population is more uniform, the population is more diverse, and the quality of the initial population is guaranteed. (2) On the basis of the original mechanism, a game predatory mechanism is proposed, which makes the algorithm more in line with biological characteristics and makes the search ability of the algorithm more flexible without reducing the advantages of fast convergence speed of the original algorithm. (3) According to the unique biological characteristics of sparrows that cannot be kept in captivity, a suicide mechanism is proposed, which is to die and live afterwards, eliminate the original individuals and produce new individuals, help the algorithm increase the population diversity, and jump out of the local optimum. (4) On the basis that the original population diversity index does not consider the individuals beyond the boundary in the search process, an index to measure the invalid search of individuals beyond the boundary is proposed, and the original population diversity index is improved to make the results more accurate. (5) Six basic test functions are used for experimental simulation. e step size diagram, diversity index analysis, and development exploration stage index are used to analyze the role and effect of each strategy. e improved algorithm is compared with particle swarm optimization (PSO) [30], differential evolution (DE) [31], grey wolf optimization (GWO) algorithm [23], and sparrow search algorithm (SSA) [21] to verify its applicability. (6) CEC2017 [32,33] is used to verify the effect of GPSSA algorithm in more complex computing environment. On the basis of the above algorithm, newer cuckoo search (CS) algorithm [34] and multistrategy serial cuckoo search (MSSCS) algorithm [35] are added for comparison and analysis to verify its superiority, and Wilcoxon rank-sum analysis, box chart, and radar sorting chart are used to verify the effectiveness of the algorithm. (7) e improved algorithm (GPSSA) is applied to a discrete problem, UAV path planning with threat [36], to help UAV quickly plan the optimal path.
When the sparrow population is foraging, the individual population can be divided into discoverer, follower, and scouter. e discoverer is responsible for finding the food and leading the population to search the direction. e follower follows the discoverer to seize the food. e scouter is alert to the threat of the surrounding environment and sends a danger signal in time to remind the sparrow population to move to a safer area.
When the sparrow population does not find the existence of predators or other external threats, the search and foraging environment is safe. e discoverer can perform a wide range of search operations to guide the population to obtain higher energy. When the scouter discovers the threat of the external environment or the presence of predators, with the release of the scouter's early warning signal, the discoverer timely adjusts the search strategy and quickly approaches the safe area.
erefore, the location update formula for the discoverer to guide the population foraging is set as follows: In the above formula, X i,j represents the current position of the i-th sparrow in the j-th dimension. M is the maximum number of iterations. t represents the current number of iterations. R 2 represents an early warning value belonging to [0,1]. α is a random number belonging to [0,1]. ST is the security threshold belonging to [0. 5,1]. L stands for a 1 × d matrix, and all elements in the matrix are 1. Q is a random number subject to normal distribution.
When the followers follow the discoverers without food, they are very hungry and have low energy, so they need to fly to other places to find food to improve their energy. When the followers follow the discoverer to get food, they only need to find a place near the best position of the sparrow population for foraging. Based on this, the location update formula of the participant is set as follows: In the above formula, X p is the best position currently occupied by the discoverer, and X worst represents the worst position. A is a 1 × d matrix with only 1 or − 1 elements, where A + � A T (AA T ) − 1 .
When i > n/2, it means that the i-th follower with low fitness does not get food, is in a very hungry state, and needs to fly to other places to find food. When i ≤ n/2, followers will compete for food with the discoverer who finds the most food (with the best fitness), so as to improve their energy.
When the scouter is at the edge of sparrow population, it is very vulnerable to predator attack or other external environment threats, so the scouter needs to quickly move closer to the global optimal position to reduce the threat.
When the scouters are in the middle of the population, if they are aware of the danger information, they will timely get close to other sparrows, so as to reduce the risk of being attacked or preyed on. erefore, the scouter position update formula is set as follows: X best represents the global optimal position of the current population. β is responsible for controlling the step size parameter, which is a random number subject to standard normal distribution. K is responsible for controlling the moving direction and step of sparrow, which is a random number belonging to [− 1, 1]. f i is the fitness value of the current i-th sparrow individual. f g and f w , respectively, represent the best and worst fitness values of the current population. ε is a minimal real number.

Improved Sparrow Algorithm Based on Game Predatory Mechanism and Suicide Mechanism (GPSSA)
3.1. Good Point Set. e good point set was proposed by Chinese mathematicians Hua and Wang [37], and its principle is as follows: let G S be the unit cube in s-dimensional Euclidean space, and if r ∈ G s , the form is If the deviation φ(n) satisfies φ(n) � C(r, ε)n − 1+ε , ε is any positive number, where C(r, ε)n − 1+ε is a constant only related to r and ε. P n (k) is a good point set and r is a good point. r (n) s · k represents the decimal part, n represents the number of points, and r � 2 cos(2πk/p), 1 ≤ k ≤ s , where p is the minimum prime number satisfying (p − 3)/2 ≥ s. Map it to the search space [34] as where ub j and lb j represent the upper and lower bounds of the j-th dimension, respectively. Figure 1(a) shows a randomly generated initial population distribution map when the good point set is in [0, 1], the number of populations is 500, and the dimension is 1. Figure 1(b)shows the frequency distribution histogram of good point set and tent chaotic map [35] under the above conditions. It can be seen that the good point integration is evenly distributed, and the initialization effect is better than that of tent chaotic map. In the initialization process, the good point set has a more uniform population, which can increase the diversity of the population and help to eliminate the attraction of the local optimal solution.

Game Predatory Mechanism.
e followers in sparrow algorithm have a predatory mechanism; that is, the followers Computational Intelligence and Neuroscience directly jump to the vicinity of the optimal location of the discoverer to compete for food. However, the food in the best position of the discoverer is not endless, and it is impossible to meet the food needs of a large number of followers, which is also inconsistent with the laws of nature. erefore, based on the game theory, this paper proposes a game predator mechanism; that is, the predatory mechanism of followers and discoverers is regarded as a game process. When i < N/2, it is stipulated that the food found by each discoverer can only meet the needs of limited participants, and the amount of food found is determined by its fitness value. e top followers will give priority to those who find the most food to grab food. In order to obtain food and avoid hunger, the lower ranked participants will choose the discoverer who finds less food to eat, as shown in Figure 2(a). It is worth noting that, for the mechanism when i > N/2, the followers obtain food and forage alone is retained, as shown in Figure 2 It is found from (2) that when i ≤ N/2, the followers will grab food after the discoverers. erefore, there are R followers who directly jump to the vicinity of the discoverer who finds the most food and grab food, where R � N/2 − PD · N and PD is the proportion of discoverers.
Assuming that the food found by each discoverer is limited, the food in the optimal location of the discoverer cannot meet the food needs of a large number of followers, and the followers participating in the predator mechanism will grab food from different discoverers because of the shortage of food. At this time, it is a game process, and the followers will choose the discoverer who is most favorable to them to grab food. ere are two steps in the game predatory mechanism: one is to count the food quantity of the discoverer, and the other is to make game selection to select the most beneficial discoverer for oneself as follows.

Food Quantity Statistics of Discoverer.
Individuals with lower fitness are considered to be better choices. e lower the fitness of the discoverer's location is, the more food   is found, and the number of discoverers is PD · N. D z represents the z-th discoverer. en the quantity G of food found by the z-th discoverer can be expressed as 3.2.2. Game Choice. When J z followers compete for food with the z-th discoverer, the subsequent followers will choose to compete for food with the z + 1-th discoverer because of the game mechanism, and so on. F j represents the j-th follower. J z is determined by the ratio p z of the quantity G z of food found by the z-th discoverer to the total quantity. e specific principle is as follows: At this time, the relationship between each follower in the game predatory mechanism and its predatory discoverer is as follows: erefore, the location update formula of the improved followers is as follows:

Suicide Mechanism. Sparrows mostly live in places
where human beings live. ey are very lively, bold, and approachable, but they are very vigilant. Sparrows are very proud birds. ey live on people, but they do not want to be kept in captivity. If they do not have freedom, they would rather starve to death [38]. erefore, this paper adds a suicide mechanism to the original mechanism of the sparrow search algorithm. t i represents the number of iterations in which the individual's position is not updated. When the individual in the population exceeds the number of dangerous iterations T c and does not update the position, it is considered that the sparrow is in an imprisoned state. At this time, the sparrow will go on hunger strike and commit suicide. At this time, we abandon the sparrow individual and generate a new sparrow individual, which helps the algorithm jump out of the local optimum. is process can be expressed by an old Chinese saying: "die and come back," and its position is updated as follows:

Time Complexity Analysis.
According to the number of populations, iteration times, and dimensions of SSA algorithm, we can easily know that the time complexity of original SSA algorithm is O (P·M·D). Firstly, GPSSA algorithm is improved on the basis of SSA algorithm; GPSSA has the same structure as the original algorithm and does not increase the number of cycles. Secondly, the good point set strategy replaces the original method of randomly initializing the population, but the time complexity does not increase. e game predatory mechanism only changes the way to approach the current optimal solution and further approaches the suboptimal solution to prevent the omission of the suboptimal solution, which also does not increase the time complexity. e suicide mechanism adopts greedy strategy, which increases the complexity of the searcher's algorithm to a certain extent. Only a few individuals in the population increase the complexity of the algorithm but not the order of magnitude of the entire algorithm. To sum up, we can get that the time complexity of GPSSA is still O(P·M·D).

Exploration and Exploitation Stage and Population Diversity
Literature [39] proposes a theoretical system to evaluate the algorithm's exploration and exploitation stage and population diversity by using the differences between individual dimensions of the population. On the basis of the above, literature [40] uses the median that can better reflect the population center instead of the average to calculate the dimensional diversity, and the effect is more accurate. e calculation formula is shown in (12). When the population diverges, it indicates that it is in the exploration stage, and the calculation formula is shown in (12). When the population gathers, it indicates that it is in the exploitation stage, and the calculation formula is shown in the following equation: where median(x j ) represents the median of the j-th dimension of the whole population, x i,j represents the j-th dimension of the i-th individual, Div j represents the diversity of the j-th dimension, Div represents the diversity of Computational Intelligence and Neuroscience the whole population, and Div max represents the maximum population diversity in the iterative process. In the search process, X pl and X pt represent the percentages of exploration and exploitation stages, respectively.

Invalid Search
Indicator. e above method does not take into account the fact that when an individual exceeds the boundary in the search process, the individual beyond the boundary will be corrected to the boundary in the next iteration. erefore, the position beyond the boundary is invalid, and the diversity of the population is also invalid or inaccurate. erefore, this paper proposes an index Inv to evaluate the invalid search beyond the boundary of the algorithm, which is used to describe the ability of invalid search in the t-th iteration of the algorithm. e specific expression is as follows: where |min(X t i,j − lb, 0)| and |min(ub − X t i,j , 0)| are used to determine the distance values of lb and ub beyond the boundary. If it does not exceed the boundary, the value is 0. max(|min(X t i,j − lb, 0)|, |min(ub − X t i,j , 0)|) is used to calculate the distance beyond the boundary. It is easy to know that one of the two must be 0, because it can only exceed one side of the boundary. e smaller the value, the stronger the ability of the algorithm to search effectively.

Improved Exploration and Exploitation Stage and Population Diversity.
If the above indexes for evaluating the invalid search ability are brought into the original index system, more accurate indexes of population diversity and exploration and exploitation stage can be obtained. For individuals beyond the boundary in the search process, the strategy of modifying to the boundary will be adopted in the next iteration, so the boundary position is the real position of individuals beyond the search boundary. Since the individuals beyond the boundary do not affect the selection of the median, the improved formula is as follows:

Experimental Simulation of Basic Test Function
In this paper, six basic test functions are selected to verify the performance of GPSSA algorithm and compared with other  (7) Output: X best , f g (8) t � 1; (9) Initialize population by formula (5). (10) While (t < M) (11) Sort fitness values and mark the positions of the best and worst sparrows.
Using formula (1) to update the location of the discoverers; (15) End for (16) For i � (PD * N + 1): N (17) e discoverers who were going to prey were selected according to formulas (6)-(9); (18) Using formula (10) to update the location of the followers; (19) End for (20) For l � 1 : SD (21) Using formula (3)   Computational Intelligence and Neuroscience heuristic algorithms, such as PSO, DE, GWO, SSA, and GPSSA. e specific parameter settings are shown in Table 1. F1-F3 are high-dimensional single peak benchmark functions, F4-F5 are high-dimensional multipeak benchmark functions, and F6 is low-dimensional multipeak benchmark function. e test function information is shown in Table 2, and the parameter space is shown in Figure 3. Figure 4 shows the initial population of the above algorithm and the step size update after only one iteration, in which the objective function is F1 and the number of populations is 100. e red cross in the figure is the location of the optimal solution. As can be seen from the figure, the step amplitude of PSO update is small, and the step amplitude of DE and GWO is large. However, the optimal solution found after initializing the population is not fully utilized by DE and GWO, resulting in blind search. Because of the influence of the discoverer-follower mechanism, most of the population individuals converge near the optimal solution, which is also the main reason why the SSA algorithm has the advantage of fast convergence speed. However, it is also easy to fall into the dilemma of local optimization, and it can be seen from the figure that the initial population of GPSSA is more uniform due to the influence of good point set strategy. Due to the game predatory mechanism, some followers will approach the current suboptimal solution to prevent missing the better solution and falling into the local optimum. Figure 5 shows the comparison of the effects of the three strategies proposed in this paper. Set the population number to 30 and the number of iterations to 500, and select F1 as the objective function, where (a) is 30 dimensions and (b) is 100 dimensions. SSA is the original algorithm; SSA1, SSA2, and SSA3 are the improved algorithms with good point set strategy, game predatory mechanism, and suicide mechanism separately added to SSA; and GPSSA is the improved algorithm with three strategies added. As can be seen from the above figure, the addition of these three strategies can improve the performance of SSA algorithm to a certain extent. At 30 dimensions, SSA1 and SSA2 are better; at 100 dimensions, the effect of SSA2 and SSA3 is more obvious when the dimension increases, but SSA1 has no significant change. e effect of GPSSA is better than that of a single strategy, which shows that the good point set strategy, game predatory mechanism, and suicide mechanism all have a good improvement effect on the original algorithm. Table 3 shows the comparison of optimization effects of each algorithm running independently for 30 times, in which the population size is 30, the maximum number of iterations of each algorithm is 500, and the best value of each index is displayed in bold. Finally, the average value is used to sort each algorithm (if the average value is equal, consider the standard deviation). It can be seen from the table that GPSSA shows excellent optimization performance. GPSSA has found the optimal value in F1-F6, indicating that GPSSA has good optimization ability; each index is almost the best in all algorithms, and the comprehensive ranking is also the first, indicating that GPSSA has good optimization accuracy and stability. Except for F5, the results of GPSSA and SSA are the same. In other functions, GPSSA has found a better solution than SSA, indicating that GPSSA algorithm has stronger optimization performance than the original algorithm. Figure 6 shows the convergence diagram of each algorithm in the above function. GPSSA has faster convergence speed and better optimization accuracy than SSA. In F1 and F2, the convergence rate of GPSSA is very stable, almost in a straight line, and there is no cliff decline like SSA, indicating that the game predatory mechanism has stronger and more stable optimization ability than the original SSA predatory mechanism. In F3 and F4, SSA falls into the local optimum, while GPSSA will regenerate new individuals to jump out of the local optimum after stopping updating due to the suicide mechanism. In F5, although both SSA and GPSSA find the optimal solution, the convergence speed of GPSSA is faster. In F6, both SSA and GPSSA find the optimal solution after falling into the local optimum, which shows that the original SSA algorithm also has a certain ability to jump out of the local optimum, but GPSSA has a stronger ability to jump out of the local optimum. Figure 7 shows the invalid search index of each algorithm obtained according to formula (13), which is used to represent the index of invalid search caused by exceeding the boundary in the search process. e change trend of this index is mainly related to the update mechanism of the algorithm location. For example, the population will continue to converge in the search process of PSO, DE, and GWO algorithms, so it will continue to decrease with the number of iterations. Although SSA and GPSSA will also converge and converge faster, due to the antipredation behavior in the algorithm, some population individuals will continue to escape the current position and will not be reduced by the number of iterations, such as F3 and F6. F1, F2, F4, and F5 are not affected by the update step size and boundary size.
Because an individual experiences the phenomenon of exceeding the boundary in the search process and the individual is corrected to the boundary in the next iteration update, the boundary position is the real position of the Computational Intelligence and Neuroscience 7 individual exceeding the boundary in the search process. e improved diversity index removes such effects and the results will be more accurate. Figure 8 shows the population diversity calculated according to the improved formula (14). It can be seen from Figure 8 that the diversity of PSO, DE, and GWO algorithms will decrease with the number of iterations due to the continuous convergence of population individuals, and the decline speed of PSO is the slowest.
Computational Intelligence and Neuroscience SSA and GPSS algorithms decline faster, but because the vigilant mechanism continues to escape from the current position, it will not fall to 0, but it will continue to fluctuate to maintain population diversity and prevent falling into local optimization. Combined with Figure 6, we can find that when SSA and GPSSA no longer converge (when the convergence curve level or no longer decreases), the population diversity will suddenly rise due to the       antipredation behavior, which helps the algorithm jump out of the local optimum. At the same time, due to the suicide mechanism, GPSSA will think that it is in an imprisoned state at this time and then commit suicide to produce new individuals, which will have better population diversity compared to the SSA algorithm. According to equations (15) and (16), Figure 9 shows the exploration-exploitation ratio of each algorithm in six functions, where (a), (b), (c), (d), (e), and (f ) are the development exploration ratio under F1, F2, F3, F4, F5, and F6, respectively. As can be seen from the figure, PSO, DE, and GWO algorithms all change from exploration stage to exploitation stage with the number of iterations, and the exploitation percentage increases and the exploration percentage decreases. SSA and GPSS algorithms enter the development stage after very few iterations because of their fast convergence speed. Combined with Figure 6, we can find that when SSA and GPSSA are no longer convergent, the development percentage continues to decline, the exploration percentage increases, and the development stage changes to the exploration stage to prevent them from falling into local optimization. Due to the addition of three strategies, GPSSA has better search ability and the ability to jump out of local optimization, which leads GPSSA to find the optimal solution earlier, end the exploitation stage, and then enter the exploration stage.

CEC2017 Test
In order to further verify the generality of the algorithm, the algorithm is tested on CEC2017 test function [41]. Due to the defects of F2 function, this paper will not test. e number of dimensions is 30, the number of individuals is 100, the number of evaluations is set to 10000 * dim, and the algorithm parameters remain unchanged. After 30 independent runs, the average value and standard deviation of each algorithm are calculated according to the results and finally sorted. e best value for each index is displayed in bold. e specific test results are shown in Table 4.
e results in Table 4 show that the average value of GPSSA algorithm is the best value among all algorithms in F1, F5, F8, F9, f13, F14, F15, F16, F17, F19, F21, F23, F24, F26, F28, and F29 functions, which shows that GPSSA algorithm has good optimization ability and , and GWO (6.00). e SSA algorithm does not perform well in more complex CEC217. Only due to GWO, it shows that the optimization ability of the original algorithm decreases in more complex optimization problems, while the improved GPSSA is more suitable for complex optimization problems due to the improvement of mechanism. Figure 10 shows a radar chart made according to the algorithm ranking. e higher the ranking is, the closer it is to the radar center. It can be seen that more than half of GPSSA functions are closest to the radar center, and the enclosed area is the smallest. According to the 30 times' optimal results, all algorithms conduct Wilcoxon rank-sum   Table 5. When the value is greater than 0.05, it can be considered that there is no significant difference between the two; otherwise, it is considered that there is a significant difference between the two, where "+" and "− " mean greater than and less than 0.05, respectively. Only a few values in the results are greater than 0.05, indicating that GPSSA algorithm is significantly different from other algorithms. Figure 11 shows the selected six groups of box graphs, in which the box graph of GPSSA has a shorter length than other algorithms, indicating that GPSSA algorithm has strong optimization performance and stability. e results show that the optimization performance of GPSSA is better than that of SSA, and the optimization performances of PSO and MSSCS are also better. In the SSA algorithm, when the participants in the population move closer to the discoverer, they jump directly to the current optimal solution instead of moving slowly to the current optimal solution, so the result of SSA is very poor.
is problem leads to a large range of individual update steps of the population in SSA algorithm, which accelerates the convergence of the algorithm, but it is easy to miss the high-quality solution. GPSSA algorithm adopts an improved strategy to make up for this disadvantage, which makes the initial population more uniform, makes full use of other better solutions or generates new solutions, increases the population diversity, makes the search method more flexible, and greatly reduces the loss of population diversity. In general, GPSSA algorithm retains the advantage of fast convergence speed of the original algorithm, has good universality and optimization performance, and has strong competitiveness compared with other algorithms.

UAV Path Planning
UAV path planning problem [42] is an optimization problem where UAV uses terrain as cover to effectively avoid various threats, so as to improve the survivability of aircraft and quickly reach the destination. Aiming at the problem of UAV path planning, several methods such as graph theory search, element decomposition, potential field, and natural heuristic algorithm are proposed in the literature [43][44][45]. However, with the more and more complex tasks undertaken by UAV, the uncertainty of its flight environment, and the higher requirements for track planning, the superiority of swarm intelligence algorithm in solving complex problems makes more and more scholars apply swarm intelligence algorithm to this field. To solve the UAV track planning problem, it is necessary to establish an appropriate fitness function and consider various constraints affecting the track quality. e static global 3D track planning model mainly includes cost function and constraint function.

Flight Path Cost.
In the actual combat mission, the fuel carried by UAV is limited, the track length can reflect the fuel consumption, and L i is the track length of the i-th segment. at is, UAV flight fuel consumption cost can be expressed as track length:   Figure 15: Path planning with threats.

Flight Altitude Change Cost.
In order to avoid radar search and prevent collision with mountains or other obstacles, the UAV must raise or lower the height, but repeated lifting and lowering will also endanger the safety of the UAV. e variance of track altitude change can describe the stability of flight altitude. As the cost of altitude change, it can be expressed as

Smoothing Cost.
In the flight process, the larger the deflection angle is, the more unstable the flight state of the UAV is and the less smooth the flight path is. erefore, the smoothing cost is added to increase the stability and smoothness of UAV track, and the smoothing cost is expressed by the change degree of deflection angle δ. e function is set as follows: 7.4. Integrated reat Constraints. UAV encounters enemy air defense system when it passes through enemy areas, including detection radar, antiaircraft artillery, and ground-to-air missile. e above threats are approximated as a cylindrical area in three-dimensional plane, and the detection or attack range is used as its radius R. e current track segment L i is divided into five segments, M represents the comprehensive threat, k M represents the kth comprehensive threat, R k M represents the radius of the current threat, and d k,i represents the distance from the current threat point to each of the five equal segments. e threat cost of the current synthetic threat point to the track segment is shown in Figure 12, and its threat constraint function is η is a penalty function, and the trajectory planning objective function in this paper is min f cost � ω 1 · f path + ω 2 · f height + ω 3 · f smooth + η · Constraint.  In this paper, the cubic B-spline method is used to ensure better curve smoothness for UAV track smoothing. e spline curve generated during track smoothing is determined by four adjacent control points. By reducing the dependence of track smoothing on each operating point, the smoothed track is more effective, as shown in Figure 13.

Track
Coding. An individual in a population is defined as a path connected by multiple track points, S i � [s x1 , s y1 , s z1 , s x2 , . . . . . . s xn , s yn , s zn ], in which every 3 coordinates constitute a track point in three dimensions, a total of N track points, and a dimension of 3 * n for each individual.

Experimental Simulation.
is paper establishes a three-dimensional mountain terrain using a 100 km × 150 km × 3 km digital elevation map as shown in Figure 14.
is paper runs 20 times, with 10 track nodes , 30 dimensions, maximum number of iterations of 200, and a population of 100. e experimental results are shown in Table 6. Path planning with threats is shown in Figure 15. Top view of path planning contour is shown in Figure 16, and target function convergence is shown in Figure 17.
Combining Figures 15-17, it can be seen that SSA is trapped in a local optimum and cannot jump out. GPSSA algorithm can quickly avoid the constraints of threat area and complete path planning, and the path planning is optimal, with faster convergence speed and better accuracy. From the results in Table 6, the four indicators of GPSSA are all optimal, indicating that they have strong optimization ability and stability. e good algorithm performance of GPSSA is verified, which can quickly and accurately get rid of the constraints of threat areas and complete the unmanned aircraft path planning. is helps the unmanned aircraft path static planning to have shorter time, better path planning, and better stability.

Conclusions
In this paper, game predatory mechanism and suicide mechanism are proposed to improve sparrow search algorithm, which is more in line with the biological habits of sparrow population, ensures more uniform population through a good point set, makes full use of the better individuals in the population through game predatory mechanism and ensures the flexibility of search, and helps the algorithm get rid of the trap of local optimization through suicide mechanism. An invalid search index is presented for the true location of individuals beyond the boundary during the search process, which improves the defect of the original index and makes it more accurate and realistic to reflect the population diversity, exploration, and development stages in the search process. By comparing the basic test functions and CEC2017 with other heuristic algorithms, it is proved that GPSSA has good optimization performance and effectively improves the shortcomings of poor initial population quality, poor utilization of the current better solution, and poor ability to jump out of local optimal. It also strengthens the ability of the original algorithm to get rid of local optimal attraction while retaining the advantages of fast convergence. rough the UAV path planning simulation, the effectiveness and superiority of GPSSA are verified. Using the advantages of rapid convergence and strong optimization performance of GPSSA, it helps to quickly plan the better path. It provides a new method for the research of this kind of field and provides a good case for the research of this algorithm in other fields.
In the future, we will try to integrate with PSO and other heuristic algorithms and combine the advantages of these two algorithms to improve their poor global search ability, further improve the search performance, and better apply them to more practical problems.

Data Availability
e data used to support the findings of this study are available from the corresponding author upon request.

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