1. Sparrow algorithm
Optimization is a popular problem in scientific research and engineering practice. Most intelligent optimization algorithms are inspired by human intelligence, the sociality of biological groups or the laws of natural phenomena, and carry out global optimization in solution space. Sparrow algorithm was first proposed by Xue Jiankai [1] in 2020. It is a new intelligent optimization algorithm based on the foraging and anti-predation behavior of sparrow population.
Sparrow search algorithm specific steps and formula description:
Building sparrow population:
Where, D represents the dimension of the problem to be optimized, and N represents the number of sparrow population. The fitness function of all sparrow populations can be expressed as follows:
Where, Fx represents the fitness function value.
Sparrows in the sparrow algorithm are divided into two categories: finders and entrants. Finders are responsible for finding food for the whole population and providing foraging directions for entrants. Therefore, the foraging search scope of finders is larger than that of entrants. During each iteration, the discoverer iterates according to Formula (3).
T said the current number of iterations, Xij said of the ith the sparrow population in the first j d location information, alfa said random number of 0 and 1, itermax said the largest number of iterations, Q means a obey the normal distribution of random Numbers, L is a 1 * d and all elements of 1 matrix, R2 belong to early warning value of 0 and 1 is the location of the sparrow population, ST belongs to the safe value of 0.5-1 indicating the position of sparrow population.
When R2<ST, it means that the warning value is less than the safe value. At this time, there is no predator in the foraging environment, and the finder can conduct extensive search operations. When R2>ST, it means that some sparrows in the population have found the predator, and give warning to other sparrows in the population. All sparrows need to fly to the safe area for foraging.
In the process of foraging, part of the entrants will monitor the discoverers all the time. When the discoverers find better food, the entrants will compete with them. If they succeed, they will get the discoverers’ food immediately.
Where, XP represents the optimal location discovered by the discoverer, Xworst represents the global worst location, and A represents the 1* D matrix whose elements are randomly assigned to 1 or -1 and meet the following relations:
L is still a 1 times d matrix with all 1’s. When I >n/2, it indicates that the ith entrant has no food and is hungry. At this time, he/she needs to fly to other places for food so as to obtain more energy.
In the sparrow population, the number of sparrows aware of danger accounts for 10% to 20% of the total number. The positions of these sparrows are randomly generated, and the positions of sparrows aware of danger are constantly updated according to Formula (5).
Where, Xbest represents the current global optimal position, is the random number that follows the standard normal distribution and is used as the step size control parameter, beta is a random number ranging from -1 to 1, Fi represents the fitness value of the current individual sparrow, FG represents the global best fitness value, fw represents the global worst fitness value, Does the one like the left ear read “Il Buzeno”? “One not zeno” means a constant that avoids a zero in the denominator. When FI >fg, sparrows are at the edge of the population and vulnerable to predators. When FI = FG, sparrows in the middle of the population are also in danger and need to be close to other sparrows to reduce the risk of being preyed on.
2. Sparrow Search Algorithm Based on Sobol Sequence and Criss-crossing Strategy (SSASC)
To solve the problems of sparrow search algorithm (SSA), such as easy to fall into local optimum and slow convergence speed, this paper proposes a sparrow search algorithm (SSASC) based on Sobol sequence and cross and cross. Firstly, Sobol sequences in the random sampling method are introduced in the initialization stage to enhance the diversity and ergodicity of the population. Secondly, an exponential form of nonlinear inertia weight is proposed to improve the convergence efficiency of the algorithm. Finally, the crosswise strategy is used to improve the algorithm, the crosswise strategy is used to enhance the global search ability, and the crosswise strategy is used to keep the diversity of the population and prevent the algorithm from falling into local optimum. Thirteen benchmark functions were selected for simulation experiments, and Wilcoxon test and Friedman test were used to evaluate the performance of the algorithm. By extending the benchmark function from 10 dimensions to 100 dimensions, SSASC consistently ranked first in mean and standard deviation compared to other meta-heuristic algorithms. Experimental results show that the algorithm has substantial advantages in convergence speed and accuracy.
Three, part of the code
function [FoodFitness,FoodPosition,Convergence_curve]=SSA(N,Max_iter,lb,ub,dim,fobj) if size(ub,1)==1 ub=ones(dim,1)*ub; lb=ones(dim,1)*lb; end Convergence_curve = zeros(1,Max_iter); %Initialize the positions of salps SalpPositions=initialization(N,dim,ub,lb); FoodPosition=zeros(1,dim); FoodFitness=inf; %calculate the fitness of initial salps for i=1:size(SalpPositions,1) SalpFitness(1,i)=fobj(SalpPositions(i,:)); end [sorted_salps_fitness,sorted_indexes]=sort(SalpFitness); for newindex=1:N Sorted_salps(newindex,:)=SalpPositions(sorted_indexes(newindex),:); end FoodPosition=Sorted_salps(1,:); FoodFitness=sorted_salps_fitness(1); %Main loop l=2; % start from the second iteration since the first iteration was dedicated to calculating the fitness of salps while l<Max_iter+1 c1 = 2*exp(-(4*l/Max_iter)^2); % Eq. (3.2) in the paper for I =1:size(SalpPositions,1) SalpPositions= SalpPositions'; if i<=N/2 for j=1:1:dim c2=rand(); c3=rand(); % % % % % % % % % % % % % % Eq. (3.1) in the paper % % % % % % % % % % % % % % if c3 < 0.5 SalpPositions(j,i)=FoodPosition(j)+c1*((ub(j)-lb(j))*c2+lb(j)); else SalpPositions(j,i)=FoodPosition(j)-c1*((ub(j)-lb(j))*c2+lb(j)); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% end elseif i>N/2 && i<N+1 point1=SalpPositions(:,i-1); point2=SalpPositions(:,i); SalpPositions(:,i)=(point2+point1)/2; % % Eq. (3.4) in the paper end SalpPositions= SalpPositions'; end for i=1:size(SalpPositions,1) Tp=SalpPositions(i,:)>ub'; Tm=SalpPositions(i,:)<lb'; SalpPositions(i,:)=(SalpPositions(i,:).*(~(Tp+Tm)))+ub'.*Tp+lb'.*Tm; SalpFitness(1,i)=fobj(SalpPositions(i,:)); if SalpFitness(1,i)<FoodFitness FoodPosition=SalpPositions(i,:); FoodFitness=SalpFitness(1,i); end end Convergence_curve(l)=FoodFitness; l = l + 1; endCopy the code
4. Simulation results
Five, reference and code private message blogger
[1] Duan Yuxian, LIU Changyun. Sparrow search algorithm based on Sobol sequence and criss-crossing strategy [J]. Computer Applications,{3},{4}{5}:1-9[2021-07-14].