Particle swarm algorithm based on improved Levi's flight and chaotic mapping (10 chaotic mappings can be switched at will), with matlab code

"  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.

ae08a74726aee78c6c04699df257e590.png

e122025606ab81d46b69c3e6f206cf69.png

273d81d9a9c156ad96b721198a56ee47.png

b96ea35c46e15bdf37af7df834f9e2df.png

614a86459af391bec6fd69204946302f.png

2ad3857e5595adbf00b18be6b704c693.png

c44278ee6016d87de75a0964bb86046c.png

d2826d3031640f91b716070705ac6ee7.png

4dae477ad01586bfefda0cbf5a84df41.png

379fec4300c48a0180b2e7d18bc30d9e.png

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.

  1. 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

  2. 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:

aea4104a2ab6bd14b6fd423023d3b4a5.png

where α is the step scaling factor and Levy(β) is the Levy random path.

9f2b5cbd437e51f5ca0477d4e52aea2e.png

The principle of improvement is as follows:

812aa3d3d1c7f8f8aec46f4d548ce237.png

b70d12d21bf2478ed36d31d29805ece5.png

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

Guess you like

Origin blog.csdn.net/woaipythonmeme/article/details/131526562