基于透鏡成像學(xué)習(xí)策略的灰狼優(yōu)化算法求解單目標優(yōu)化問題附matlab代碼
?作者簡介:熱愛科研的
開發(fā)者,修心和技術(shù)同步精進,matlab項目合作可私信。??個人主頁:Matlab科研工作室
??個人信條:格物致知。
更多Matlab仿真內(nèi)容點擊??
?? ? ?
? ? ? ?
? 內(nèi)容介紹
在灰狼優(yōu)化算法中, C是一個重要的參數(shù),其功能是負責(zé)算法的勘探能力.目前,針對參數(shù)C的研究工作相對較少.另外,在算法進化過程中,群體中其他個體均向α,β和δ所在區(qū)域靠近以加快收斂速度.然而,算法易陷入局部最優(yōu).為解決以上問題,本文提出一種改進的灰狼優(yōu)化算法(Lens imaging learning grey wolf optimizer algorithm, LIL-GWO).該算法首先分析了參數(shù)C的作用,提出一種新的參數(shù)C策略以平衡算法的勘探和開采能力;同時,分析了灰狼優(yōu)化算法后期個體均向決策層區(qū)域聚集,從而導(dǎo)致群體多樣性較差,提出一種基于光學(xué)透鏡成像原理的反向?qū)W習(xí)策略以避免算法陷入局部最優(yōu).對LIL-GWO算法的收斂性進行了證明.選取12個通用的標準測試函數(shù)和30個CEC 2014測試函數(shù)進行實驗,在相同的適應(yīng)度函數(shù)評價次數(shù)條件下, LIL-GWO算法在總體性能上優(yōu)于基本GWO算法,改進GWO算法和其他比較算法.最后,將LIL-GWO算法應(yīng)用于辨識光伏模型的參數(shù),獲得了滿意的結(jié)果.
? 部分代碼
%___________________________________________________________________%
%? Grey Wolf Optimizer (GWO) source codes version 1.0? ? ? ? ? ? ? ?%
%? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?%
%? Developed in MATLAB R2011b(7.13)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?%
%? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?%
%? Author and programmer: Seyedali Mirjalili? ? ? ? ? ? ? ? ? ? ? ? %
%? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?%
%? ? ? ? ?e-Mail: ali.mirjalili@gmail.com? ? ? ? ? ? ? ? ? ? ? ? ? ?%
%? ? ? ? ? ? ? ? ?seyedali.mirjalili@griffithuni.edu.au? ? ? ? ? ? ?%
%? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?%
%? ? ? ?Homepage: http://www.alimirjalili.com? ? ? ? ? ? ? ? ? ? ? ?%
%? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?%
%? ?Main paper: S. Mirjalili, S. M. Mirjalili, A. Lewis? ? ? ? ? ? ?%
%? ? ? ? ? ? ? ?Grey Wolf Optimizer, Advances in Engineering? ? ? ? %
%? ? ? ? ? ? ? ?Software , in press,? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? %
%? ? ? ? ? ? ? ?DOI: 10.1016/j.advengsoft.2013.12.007? ? ? ? ? ? ? ?%
%? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?%
%___________________________________________________________________%
% Grey Wolf Optimizer
function [Alpha_score,Alpha_pos,Convergence_curve]=GWO(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 problems
Beta_pos=zeros(1,dim);
Beta_score=inf; %change this to -inf for maximization problems
Delta_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_iter
? ? for i=1:size(Positions,1)??
? ? ? ??
? ? ? ?% Return back the search agents that go beyond the boundaries of the search space
? ? ? ? Flag4ub=Positions(i,:)>ub;
? ? ? ? Flag4lb=Positions(i,:)<lb;
? ? ? ? Positions(i,:)=(Positions(i,:).*(~(Flag4ub+Flag4lb)))+ub.*Flag4ub+lb.*Flag4lb;? ? ? ? ? ? ? ?
? ? ? ??
? ? ? ? % Calculate objective function for each search agent
? ? ? ? fitness=fobj(Positions(i,:));
? ? ? ??
? ? ? ? % Update Alpha, Beta, and Delta
? ? ? ? if fitness<Alpha_score?
? ? ? ? ? ? Alpha_score=fitness; % Update alpha
? ? ? ? ? ? Alpha_pos=Positions(i,:);
? ? ? ? end
? ? ? ??
? ? ? ? if fitness>Alpha_score && fitness<Beta_score?
? ? ? ? ? ? Beta_score=fitness; % Update beta
? ? ? ? ? ? Beta_pos=Positions(i,:);
? ? ? ? end
? ? ? ??
? ? ? ? if fitness>Alpha_score && fitness>Beta_score && fitness<Delta_score?
? ? ? ? ? ? Delta_score=fitness; % Update delta
? ? ? ? ? ? Delta_pos=Positions(i,:);
? ? ? ? end
? ? end
? ? ? ?
? ? a=2-l*((2)/Max_iter); % a decreases linearly fron 2 to 0
? ??
? ? % Update the Position of search agents including omegas
? ? for 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 1
? ? ? ? ? ? X1=Alpha_pos(j)-A1*D_alpha; % Equation (3.6)-part 1
? ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? r1=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 2
? ? ? ? ? ? X2=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 3
? ? ? ? ? ? X3=Delta_pos(j)-A3*D_delta; % Equation (3.5)-part 3? ? ? ? ? ? ?
? ? ? ? ? ??
? ? ? ? ? ? Positions(i,j)=(X1+X2+X3)/3;% Equation (3.7)
? ? ? ? ? ??
? ? ? ? end
? ? end
? ? l=l+1;? ??
? ? Convergence_curve(l)=Alpha_score;
end
? 運行結(jié)果



? 參考文獻
[1]龍文、伍鐵斌、唐明珠、徐明、蔡紹洪. "基于透鏡成像學(xué)習(xí)策略的灰狼優(yōu)化算法." 自動化學(xué)報 46.10(2020):17.
?? 關(guān)注我領(lǐng)取海量matlab電子書和數(shù)學(xué)建模資料
??部分理論引用網(wǎng)絡(luò)文獻,若有侵權(quán)聯(lián)系博主刪除