当前位置: 灰狼 >> 灰狼的形状 >> 灰狼算法基于自适应头狼的灰狼优化算法
灰狼优化算法一种模拟灰狼捕食行为的元启发式优化算法.由于灰狼算法在种群迭代更新中始终靠近最优解,所以易陷入局部最优.提出了一种基于自适应头狼的灰狼优化算法,并在个体迭代更新中选择合适的头狼个数进行个体更新,这使得算法能够平衡开发和勘探能力.通过对20个基准函数优化问题的仿真实验表明,改进后的算法与原始灰狼优化算法相比,其全局搜索能力有显著提高.
1.1灰狼算法介绍2部分代码%GreyWolfOptimizerfunction[Alpha_score,Alpha_pos,Convergence_curve]=GWO(SearchAgents_no,Max_iter,lb,ub,dim,fobj)%initializealpha,beta,anddelta_posAlpha_pos=zeros(1,dim);Alpha_score=inf;%changethisto-infformaximizationproblemsBeta_pos=zeros(1,dim);Beta_score=inf;%changethisto-infformaximizationproblemsDelta_pos=zeros(1,dim);Delta_score=inf;%changethisto-infformaximizationproblems%InitializethepositionsofsearchagentsPositions=initialization(SearchAgents_no,dim,ub,lb);Convergence_curve=zeros(1,Max_iter);l=0;%Loopcounter%MainloopwhilelMax_iterfori=1:size(Positions,1)%ReturnbackthesearchagentsthatgobeyondtheboundariesofthesearchspaceFlag4ub=Positions(i,:)ub;Flag4lb=Positions(i,:)lb;Positions(i,:)=(Positions(i,:).*(~(Flag4ub+Flag4lb)))+ub.*Flag4ub+lb.*Flag4lb;%Calculateobjectivefunctionforeachsearchagentfitness=fobj(Positions(i,:));%UpdateAlpha,Beta,andDeltaiffitnessAlpha_scoreAlpha_score=fitness;%UpdatealphaAlpha_pos=Positions(i,:);endiffitnessAlpha_scorefitnessBeta_scoreBeta_score=fitness;%UpdatebetaBeta_pos=Positions(i,:);endiffitnessAlpha_scorefitnessBeta_scorefitnessDelta_scoreDelta_score=fitness;%UpdatedeltaDelta_pos=Positions(i,:);endend%adecreaseslinearlyfron2to0a=sin(((l*pi)/Max_iter)+pi/2)+1;%UpdatethePositionofsearchagentsincludingomegasfori=1:size(Positions,1)forj=1:size(Positions,2)r1=rand();%r1isarandomnumberin[0,1]r2=rand();%r2isarandomnumberin[0,1]A1=2*a*r1-a;%Equation(3.3)C1=2*r2;%Equation(3.4)D_alpha=abs(C1*Alpha_pos(j)-Positions(i,j));%Equation(3.5)-part1X1=Alpha_pos(j)-A1*D_alpha;%Equation(3.6)-part1r1=rand();r2=rand();A2=2*a*r1-a;%Equation(3.3)C2=2*r2;%Equation(3.4)D_beta=abs(C2*Beta_pos(j)-Positions(i,j));%Equation(3.5)-part2X2=Beta_pos(j)-A2*D_beta;%Equation(3.6)-part2r1=rand();r2=rand();A3=2*a*r1-a;%Equation(3.3)C3=2*r2;%Equation(3.4)D_delta=abs(C3*Delta_pos(j)-Positions(i,j));%Equation(3.5)-part3X3=Delta_pos(j)-A3*D_delta;%Equation(3.5)-part3Positions(i,j)=(X1+X2+X3)/3;%Equation(3.7)endendl=l+1;Convergence_curve(l)=Alpha_score;end3仿真结果4参考文献
[1]郭阳,张涛,胡玉蝶,等.基于自适应头狼的灰狼优化算法[J].成都大学学报:自然科学版,,39(1):5.
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。部分理论引用网络文献,若有侵权联系博主删除。预览时标签不可点收录于合集#个上一篇下一篇