雁群优化算法(Wild Geese Algorithm,WGA)是期刊“Array”的2021年智能优化算法
01.引言
雁群优化算法(Wild Geese Algorithm,WGA)用于大规模全局优化,并利用IEEE CEC 2008和CEC 2010高维D¼100、500、1000特别会议的大规模测试函数验证了该算法的效率和性能。WGA的灵感来自大自然中的大雁,并模拟了它们生活的各个方面,如进化、定期合作迁徙和死亡。将WGA在寻找高维优化问题全局最优解方面的有效性与其他文献报道的方法进行了比较。实验结果表明,该算法结构简单,易于实现,但在求解一系列大规模优化问题方面具有良好的性能,与其他大规模优化算法相比具有很强的竞争力。
02.优化算法的流程
03.论文中算法对比图
04.部分代码
function [Best_score,Best_pos,BestCosts]=WGA(nPop,MaxNFE,xmin,xmax,nVar,CostFunction)
nPop_Initial=nPop;
nPop_Final=30;
% MaxIter0=ceil(MaxNFE/((nPop_Initial+nPop_Final)/2)); % Approximate Maximum Iterations
Cr=0.5;
%%%%%%%%%%%
NFE=0;
Gbest.Position=[];
Gbest.Cost=inf;
BestCosts=nan(1,MaxNFE);
nfe=BestCosts;
for i=1:nPopVelocity(i,:)=zeros(1,nVar); %#ok<*SAGROW>Position(i,:)=xmin+(xmax-xmin)*rand(1,nVar);Cost(i)=CostFunction(Position(i,:));PbestPosition(i,:)=Position(i,:);PbestCost(i)=Cost(i);PbestVel(i,:)=Velocity(i,:);if PbestCost(i)<Gbest.CostGbest.Position=PbestPosition(i,:);Gbest.Cost=PbestCost(i);Gbest.Velocity= PbestVel(i,:);end
end
NFE=NFE+nPop;
iter=0;
% while NFE<=MaxNFE
for iter= 1:MaxNFE
% iter=iter+1;[hh, gg]=sort(PbestCost);nPop=(nPop_Initial-1)-((nPop_Initial-nPop_Final)*(NFE/MaxNFE));nPop=round(nPop+1);nPop=max(nPop,nPop_Final);nPop=min(nPop_Initial,nPop);B6=nPop_Initial-nPop_Final;for eee=1:nPopif B6==0i=eee;elsei=gg(eee);end[~, f2]=find(gg==i);%%% Worstif f2==nPopf2=0;endjj1=gg(1,f2+1);%%% BETTER[~, f2]=find(gg==i);tt=1;if f2==1f2=nPop+1;tt=-1;endjj2=gg(1,f2-1);if f2==2f2=nPop+2;endjj3=gg(1,f2-2);jjj=gg(1,1);ff1=gg(1,end);Velocity(i,:)= (rand(1,nVar).*Velocity(i,:)+rand(1,nVar).*(Velocity(jj2,:)-Velocity(jj1,:)))+rand(1,nVar).*(PbestPosition(i,:)-Position(jj1,:))+rand(1,nVar).*(PbestPosition(jj2,:)-Position(i,:))-rand(1,nVar).*(PbestPosition(jj1,:)-Position(jj3,:))+rand(1,nVar).*(PbestPosition(jj3,:)-Position(jj2,:));%%ORIGINALBB=(PbestCost(jj2))/(PbestCost(i));GG=(PbestCost(jjj))/(PbestCost(i));Position(i,:)=PbestPosition(i,:)+rand(1,nVar).*rand(1,nVar).*(( PbestPosition(jj2,:)+Gbest.Position-2*PbestPosition(i,:))+(Velocity(i,:)));f1=(Gbest.Cost)/(PbestCost(i)+Gbest.Cost);f0=(PbestCost(jj2))/(PbestCost(jj2)+PbestCost(i));DE1=((PbestPosition(jj2,:)-PbestPosition(i,:)));for ww=1:nVarif rand<CrPosition(i,ww)=PbestPosition(i,ww)+rand*rand*(DE1(ww));endendPosition(i,:)=min(max(Position(i,:),xmin),xmax);Cost(i)=CostFunction(Position(i,:));if Cost(i)<PbestCost(i)PbestPosition(i,:)=Position(i,:);PbestCost(i)=Cost(i);PbestVel(i,:)=Velocity(i,:);if PbestCost(i)<Gbest.CostGbest.Position=PbestPosition(i,:);Gbest.Cost=PbestCost(i);Gbest.Velocity= PbestVel(i,:);endendendNFE=NFE+nPop;nfe(iter)=NFE;BestCosts(iter)=Gbest.Cost;% disp(['NFE ' num2str(NFE) ': Best Cost = ' num2str(Gbest.Cost)]);
endBest_score = Gbest.Cost;Best_pos = Gbest.Position;
end
04.本代码效果图
获取代码请关注MATLAB科研小白的个人公众号(即文章下方二维码),并回复智能优化算法本公众号致力于解决找代码难,写代码怵。各位有什么急需的代码,欢迎后台留言~不定时更新科研技巧类推文,可以一起探讨科研,写作,文献,代码等诸多学术问题,我们一起进步。