白鯊智能優化算法(White Shark Optimizer,WSO)是期刊“KNOWLEDGE-BASED SYSTEMS”(中科院一區期刊 IF=8.6)的2022年智能優化算法
01.引言
白鯊智能優化算法(White Shark Optimizer,WSO)的核心理念和基礎靈感來自大白鯊的行為,包括它們在導航和覓食時非凡的聽覺和嗅覺。行為的這些方面被數學建模,以適應對WSO的探索和利用之間的充分平衡,并協助搜索代理探索和利用搜索空間的每個潛在區域,以實現優化。WSO的搜索代理會根據目前最佳的解決方案隨機更新自己的位置,最終得到最優的結果。在CEC-2017測試套件的29個測試功能的基礎上,對WSO的性能進行了多個維度的綜合基準測試。進一步將WSO應用于CEC-2011進化算法競賽的基準問題,證明其可靠性和對現實問題的適用性。對計算結果和收斂結果進行了全面分析,以闡明WSO的有效性和穩定性水平。基于生成的解,將WSO在幾種統計方法下的性能得分與9種成熟的元啟發式方法進行比較。Friedman和Holm對結果的測試表明,與其他現有的元啟發式方法相比,WSO在全局最優性、避免局部最小值和解決方案質量方面揭示了合理的解決方案。
02.優化算法的流程
03.論文中算法對比圖
04.部分代碼
function [fmin0,gbest,ccurve]=WSO(whiteSharks,itemax,lb,ub,dim,fobj)%% Convergence curve
ccurve=zeros(1,itemax);
%% Show the convergence curve
% figure (1);
% set(gcf,'color','w');
% hold on
% xlabel('Iteration','interpreter','latex','FontName','Times','fontsize',10)
% ylabel('fitness value','interpreter','latex','FontName','Times','fontsize',10);
% grid;
%% Start the WSO Algorithm
% Generation of initial solutions
WSO_Positions=initialization(whiteSharks,dim,ub,lb);% Initial population
% initial velocity
v=0.0*WSO_Positions;
%% Evaluate the fitness of the initial population
fit=zeros(whiteSharks,1);
for i=1:whiteSharksfit(i,1)=fobj(WSO_Positions(i,:));
end
%% Initalize the parameters of WSO
fitness=fit; % Initial fitness of the random positions of the WSO[fmin0,index]=min(fit);
wbest = WSO_Positions; % Best position initialization
gbest = WSO_Positions(index,:); % initial global position
%% WSO Parametersfmax=0.75; % Maximum frequency of the wavy motionfmin=0.07; % Minimum frequency of the wavy motion tau=4.11; mu=2/abs(2-tau-sqrt(tau^2-4*tau));pmin=0.5;pmax=1.5;a0=6.250; a1=100;a2=0.0005;%% Start the iterative process of WSO
for ite=1:itemaxmv=1/(a0+exp((itemax/2.0-ite)/a1)); s_s=abs((1-exp(-a2*ite/itemax))) ;p1=pmax+(pmax-pmin)*exp(-(4*ite/itemax)^2);p2=pmin+(pmax-pmin)*exp(-(4*ite/itemax)^2);%% Update the speed of the white sharks in water nu=floor((whiteSharks).*rand(1,whiteSharks))+1;for i=1:size(WSO_Positions,1)rmin=1; rmax=3.0;rr=rmin+rand()*(rmax-rmin);wr=abs(((2*rand()) - (1*rand()+rand()))/rr); v(i,:)= mu*v(i,:) + wr *(wbest(nu(i),:)-WSO_Positions(i,:));%% or
% v(i,:)= mu*(v(i,:)+ p1*(gbest-WSO_Positions(i,:))*rand+....
% + p2*(wbest(nu(i),:)-WSO_Positions(i,:))*rand); end%% Update the white shark positionfor i=1:size(WSO_Positions,1)f =fmin+(fmax-fmin)/(fmax+fmin);a=sign(WSO_Positions(i,:)-ub)>0;b=sign(WSO_Positions(i,:)-lb)<0;wo=xor(a,b);% locate the prey based on its sensing (sound, waves)if rand<mvWSO_Positions(i,:)= WSO_Positions(i,:).*(~wo) + (ub.*a+lb.*b); % random allocation else WSO_Positions(i,:) = WSO_Positions(i,:)+ v(i,:)/f; % based on the wavy motionendend %% Update the position of white sharks consides_sng fishing school
for i=1:size(WSO_Positions,1)for j=1:size(WSO_Positions,2)if rand<s_s Dist=abs(rand*(gbest(j)-1*WSO_Positions(i,j)));if(i==1)WSO_Positions(i,j)=gbest(j)+rand*Dist*sign(rand-0.5);else WSO_Pos(i,j)= gbest(j)+rand*Dist*sign(rand-0.5);WSO_Positions(i,j)=(WSO_Pos(i,j)+WSO_Positions(i-1,j))/2*rand;end endend
end
%
%% Update global, best and new positionsfor i=1:whiteSharks % Handling boundary violationsif WSO_Positions(i,:)>=lb & WSO_Positions(i,:)<=ub% % Find the fitnessfit(i)=fobj(WSO_Positions(i,:)); % Evaluate the fitnessif fit(i)<fitness(i)wbest(i,:) = WSO_Positions(i,:); % Update the best positionsfitness(i)=fit(i); % Update the fitnessend%% Finding out the best positionsif (fitness(i)<fmin0)fmin0=fitness(i);gbest = wbest(index,:); % Update the global best positionsend endend
%% Obtain the results
% outmsg = ['Iteration# ', num2str(ite) , ' Fitness= ' , num2str(fmin0)];
% disp(outmsg);ccurve(ite)=fmin0; % Best found value until iteration ite
% if ite>2
% line([ite-1 ite], [ccurve(ite-1) ccurve(ite)],'Color','b');
% title({'Convergence characteristic curve'},'interpreter','latex','FontName','Times','fontsize',12);
% xlabel('Iteration');
% ylabel('Best score obtained so far');
% drawnow
% end end
end
04.本代碼效果圖
獲取代碼請關注MATLAB科研小白的個人公眾號(即文章下方二維碼),并回復智能優化算法本公眾號致力于解決找代碼難,寫代碼怵。各位有什么急需的代碼,歡迎后臺留言~不定時更新科研技巧類推文,可以一起探討科研,寫作,文獻,代碼等諸多學術問題,我們一起進步。