" This article improves the particle swarm optimization algorithm. Firstly, by introducing the chaotic mapping mechanism, the group is initialized to increase the diversity of particle swarm individuals; and then the improved Levi's flight mechanism is introduced in the position update formula of particle swarm individuals. , improve the search accuracy, and help the particle swarm individual jump out of the local optimum. ”
You can choose 1-10 different mappings, 1-10 are tent, Logistic, Cubic, chebyshev, Piecewise, sinusoidal, Sine, ICMIC, Circle, Bernoulli. Choose different numbers to switch at will.
Firstly, the result graph is shown, and the test is performed on the CEC2005 function. The number of individuals in the population is set to 50, and the number of cycles is 3000.
Here, the first 10 functions are selected for display. It can be seen that most functions have greatly improved in terms of convergence speed and optimization accuracy before and after improvement.
Next, let's talk about the principle of improvement.
-
chaos map
The 10 kinds of chaotic mapping mentioned in the previous article are still used, and the mapping method can be switched freely. The mapping method selected in this article is Logistic mapping, and you can also change it yourself. Friends who have not read the previous article can read it. 10 chaotic map optimization gray wolf algorithms, which can be switched with one key, can be used to optimize all swarm intelligence algorithms, and the gray wolf algorithm is used as an example to introduce
-
Improved Levi's flight mechanism
The addition of Levi's flight in this article is not directly adding the Levy coefficient when the particle is updated as in other articles, but a slight improvement. This effect is indeed better than directly adding the Levy coefficient. The principle formula is as follows:
where α is the step scaling factor and Levy(β) is the Levy random path.
The principle of improvement is as follows:
where α=0.01.
The purpose of doing this is to complement the advantages of the particle swarm algorithm and Levi's flight, and can dynamically adjust the proportional coefficient of each optimization.
code show as below:
clear
clc
close all
number='F10'; %选定优化函数,自行替换:F1~F23
% [lb,ub,D,y]:下界、上界、维度、目标函数表达式
[lb,ub,dim,fobj]=CEC2005(number);
N=50; %种群规模
T=1000; %最大迭代次数
%% 调用PSO算法
numm = 11;%% numm 混沌映射类型选择,1-10,tent、Logistic、Cubic、chebyshev、Piecewise、sinusoidal、Sine,ICMIC, Circle,Bernoulli,自由切换
%当numm等于11时,采用原始的随机数rand
% g 最佳位置
% gbest 最佳适应度值
% gb 收敛曲线
[g,gbest,gb]=PSO(numm,N,T,lb,ub,dim,fobj);
fprintf ('Best solution obtained by PSO: %s\n', num2str(g,'%e '));
fprintf ('Best objective function value obtained by PSO: %e \n', gbest);
%% 调用改进的PSO算法
numm = 1;%% numm 混沌映射类型选择,1-10,tent、Logistic、Cubic、chebyshev、Piecewise、sinusoidal、Sine,ICMIC, Circle,Bernoulli,自由切换
%当numm等于11时,采用原始的随机数rand
[chaosLPSOg,chaosLPSOgbest,chaosLPSOgb]=chaosLPSO(numm,N,T,lb,ub,dim,fobj);
fprintf ('Best solution obtained by chaosLPSO: %s\n', num2str(chaosLPSOg,'%e '));
fprintf ('Best objective function value obtained by chaosLPSO: %e \n', chaosLPSOgbest);
%% Figure
figure1 = figure('Color',[1 1 1]);
G1=subplot(1,2,1,'Parent',figure1);
func_plot(number)
title(number)
xlabel('x')
ylabel('y')
zlabel('z')
subplot(1,2,2)
G2=subplot(1,2,2,'Parent',figure1);
CNT=20;
k=round(linspace(1,T,CNT)); %随机选CNT个点
% 注意:如果收敛曲线画出来的点很少,随机点很稀疏,说明点取少了,这时应增加取点的数量,100、200、300等,逐渐增加
% 相反,如果收敛曲线上的随机点非常密集,说明点取多了,此时要减少取点数量
iter=1:1:T;
semilogy(iter(k),gb(k),'b-*','linewidth',1);
hold on
semilogy(iter(k),chaosLPSOgb(k),'g-p','linewidth',1);
grid on;
title('收敛曲线')
xlabel('迭代次数');
ylabel('适应度值');
box on
legend('PSO','chaoLOPSO')
set (gcf,'position', [300,300,800,350])
Pay attention to the variable numm in line 11, you can choose different mappings from 1-10, 1-10 are tent, Logistic, Cubic, chebyshev, Piecewise, sinusoidal, Sine, ICMIC, Circle, Bernoulli. Choose different numbers to switch at will.
Get the complete code method, the card below replies to the keyword: LPSO