目录
一、智能优化算法改进收敛行为分析运行结果
二、收敛性分析
三、GWO1在F1收敛性运行结果
四、改进灰狼算法GWO1
五、代码获取
一、智能优化算法改进收敛行为分析运行结果
本文以改进的灰狼算法 GWO1 为例,在 CEC2005 测试函数上进行定性分析实验。
F1:
F5:
F12:
二、收敛性分析
为了证明改进的灰狼算法GWO1的收敛性,我们给出了上图所示的收敛行为,在第一列中,显示基准函数的二维形状。第二列显示了搜索代理的最终位置,红点表示最优解的位置。从图中可以看出,搜索代理分布在整个参数空间中,但它们的位置主要在最优解附近。这表明GWO1具有出色的勘探开发性能。此外,第三列表示整个迭代过程中平均适应度值的变化。曲线收敛非常快表明了GWO1收敛速度很快。第四列说明了搜索代理在第一个维度中的轨迹。可以观察到,在早期的迭代过程中存在明显的波动,但是当迭代达到200次时,波动趋于平稳。这表明GWO1在避免局部最优和实现全局最优方面具有良好的性能。最后一列是收敛曲线,对于单峰函数,收敛曲线显得比较平滑,说明可以通过迭代得到最优值。然而,对于具有多个局部最优的多模态函数,需要在搜索过程中不断地逃避局部最优,以达到全局最优。结果表明,收敛曲线呈阶梯状。总体而言,基于这四个评价指标,GWO1明显具有收敛性。
三、GWO1在F1收敛性运行结果
四、改进灰狼算法GWO1
function [Alpha_score,Alpha_pos,Convergence_curve]=GWO1(SearchAgents_no,Max_iter,lb,ub,dim,fobj)% initialize alpha, beta, and delta_pos
Alpha_pos=zeros(1,dim);
Alpha_score=inf; %change this to -inf for maximization problemsBeta_pos=zeros(1,dim);
Beta_score=inf; %change this to -inf for maximization problemsDelta_pos=zeros(1,dim);
Delta_score=inf; %change this to -inf for maximization problems%Initialize the positions of search agents
Positions=initialization(SearchAgents_no,dim,ub,lb);Convergence_curve=zeros(1,Max_iter);l=0;% Loop counter% Main loop
while l<Max_iterfor i=1:size(Positions,1) % Return back the search agents that go beyond the boundaries of the search spaceFlag4ub=Positions(i,:)>ub;Flag4lb=Positions(i,:)<lb;Positions(i,:)=(Positions(i,:).*(~(Flag4ub+Flag4lb)))+ub.*Flag4ub+lb.*Flag4lb; % Calculate objective function for each search agentfitness=fobj(Positions(i,:));% Update Alpha, Beta, and Deltaif fitness<Alpha_score Alpha_score=fitness; % Update alphaAlpha_pos=Positions(i,:);endif fitness>Alpha_score && fitness<Beta_score Beta_score=fitness; % Update betaBeta_pos=Positions(i,:);endif fitness>Alpha_score && fitness>Beta_score && fitness<Delta_score Delta_score=fitness; % Update deltaDelta_pos=Positions(i,:);endenda=sin(((l*pi)/Max_iter)+pi/2)+1; % a decreases linearly fron 2 to 0% Update the Position of search agents including omegasfor i=1:size(Positions,1)for j=1:size(Positions,2) r1=rand(); % r1 is a random number in [0,1]r2=rand(); % r2 is a random number in [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)-part 1X1=Alpha_pos(j)-A1*D_alpha; % Equation (3.6)-part 1r1=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)-part 2X2=Beta_pos(j)-A2*D_beta; % Equation (3.6)-part 2 r1=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)-part 3X3=Delta_pos(j)-A3*D_delta; % Equation (3.5)-part 3 Positions(i,j)=(5*X1+3*X2+2*X3)/10;% Equation (3.7)endend Convergence_curve(l)=Alpha_score;
end%%
function Positions=initialization(SearchAgents_no,dim,ub,lb)Boundary_no= size(ub,2); % numnber of boundaries% If the boundaries of all variables are equal and user enter a signle
% number for both ub and lb
if Boundary_no==1Positions=rand(SearchAgents_no,dim).*(ub-lb)+lb;
end% If each variable has a different lb and ub
if Boundary_no>1for i=1:dimub_i=ub(i);lb_i=lb(i);Positions(:,i)=rand(SearchAgents_no,1).*(ub_i-lb_i)+lb_i;end
end
五、代码获取
需要代码请私信博主