【智能优化算法-灰狼算法】基于翻筋斗觅食策略的灰狼优化算法求解单目标优化问题附matlab代码
?作者簡介:熱愛科研的Matlab仿真開發者,修心和技術同步精進,matlab項目合作可私信。
🍎個人主頁:Matlab科研工作室
🍊個人信條:格物致知。
更多Matlab仿真內容點擊👇
智能優化算法 ?神經網絡預測 雷達通信? 無線傳感器
信號處理 圖像處理 路徑規劃 元胞自動機 無人機
? 內容介紹
?灰狼優化算法(grey wolf optimization,GWO)存在收斂的不合理性等缺陷,目前對 GWO 的收斂性改進方式較少,除此之外,在 GWO 迭代至后期,所有灰狼個體都逼近 α 狼、β 狼、δ 狼,導致算法陷入局部最優。為針對以上問題,提出了一種增強型的灰狼優化算法(disturbance and somersault foraging-grey wolf optimization,DSF-GWO),該算法首先引入了一種擾動因子,平衡了算法的開采和勘探能力;其次又引入翻筋斗覓食策略,在后期使其不陷入局部最優的同時也使得前期的群體多樣性略有提升。
? 部分代碼
%___________________________________________________________________%
%? Grey Wold 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 decreases linearly fron 2 to 0
? ? ?a=sin(((l*pi)/Max_iter)+pi/2)+1;
? ? % 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
? 運行結果
? 參考文獻
[1]王正通, 程鳳芹, 尤文,等. 基于翻筋斗覓食策略的灰狼優化算法[J]. 計算機應用研究, 2021, 38(5):4.
?? 關注我領取海量matlab電子書和數學建模資料
??部分理論引用網絡文獻,若有侵權聯系博主刪除
總結
以上是生活随笔為你收集整理的【智能优化算法-灰狼算法】基于翻筋斗觅食策略的灰狼优化算法求解单目标优化问题附matlab代码的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 足球大数据:引人发思的问题
- 下一篇: bert 句向量 的 各向异性问题 及与