发表在中科院二区Future Generation Computer Systems期刊上的论文“Harris hawks optimization: Algorithm and applications"
01.引言
本文提出了一种基于种群的、受自然启发的优化范式,称为Harris Hawks Optimizer (HHO)。HHO的主要灵感来源于自然界中哈里斯鹰的合作行为和追逐方式,即突袭。在这种聪明的策略中,几只鹰从不同的方向合作扑向猎物,试图出其不意。哈里斯鹰可以根据场景的动态性质和猎物的逃脱模式揭示各种追逐模式。这项工作在数学上模拟了这种动态模式和行为,以开发一种优化算法。通过与其他自然启发技术的比较,在29个基准问题和几个实际工程问题上验证了所提出的HHO优化器的有效性。统计结果和比较表明,与已建立的元启发式技术相比,HHO算法提供了非常有前途的和偶尔竞争的结果。
02.代码过程
03.部分代码
% Developed in MATLAB R2013b
% Source codes demo version 1.0.6. Updated 12.5.2021
% _____________________________________________________
% Author, inventor and programmer: Ali Asghar Heidari,
% PhD research intern, Department of Computer Science, School of Computing, National University of Singapore, Singapore
% Exceptionally Talented Ph. DC funded by Iran's National Elites Foundation (INEF), University of Tehran
% 03-03-2019
% Researchgate: https://www.researchgate.net/profile/Ali_Asghar_Heidari
% e-Mail: as_heidari@ut.ac.ir, aliasghar68@gmail.com,
% e-Mail (Singapore): aliasgha@comp.nus.edu.sg, t0917038@u.nus.edu
% _____________________________________________________
% Co-authors: Hossam Faris, Ibrahim Aljarah, Majdi Mafarja, and Hui-Ling Chen
% Homepage: http://www.evo-ml.com/2019/03/02/hho/
% https://aliasgharheidari.com/HHO.html
% _____________________________________________________
% Please refer to the main paper:
% Ali Asghar Heidari, Seyedali Mirjalili, Hossam Faris, Ibrahim Aljarah, Majdi Mafarja, Huiling Chen
% Harris hawks optimization: Algorithm and applications
% Future Generation Computer Systems, DOI: https://doi.org/10.1016/j.future.2019.02.028
% _____________________________________________________
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Harris's hawk optimizer: In this algorithm, Harris' hawks try to catch the rabbit.
% T: maximum iterations, N: populatoin size, CNVG: Convergence curve
% To run HHO: [Rabbit_Energy,Rabbit_Location,CNVG]=HHO(N,T,lb,ub,dim,fobj)
function [Rabbit_Energy,Rabbit_Location,CNVG]=HHO(N,T,lb,ub,dim,fobj)
disp('HHO is now tackling your problem')
tic
% initialize the location and Energy of the rabbit
Rabbit_Location=zeros(1,dim);
Rabbit_Energy=inf;
%Initialize the locations of Harris' hawks
X=initialization(N,dim,ub,lb);
CNVG=zeros(1,T);
t=0; % Loop counter
while t<T
for i=1:size(X,1)
% Check boundries
FU=X(i,:)>ub;FL=X(i,:)<lb;X(i,:)=(X(i,:).*(~(FU+FL)))+ub.*FU+lb.*FL;
% fitness of locations
fitness=fobj(X(i,:));
% Update the location of Rabbit
if fitness<Rabbit_Energy
Rabbit_Energy=fitness;
Rabbit_Location=X(i,:);
end
end
E1=2*(1-(t/T)); % factor to show the decreaing energy of rabbit
% Update the location of Harris' hawks
for i=1:size(X,1)
E0=2*rand()-1; %-1<E0<1
Escaping_Energy=E1*(E0); % escaping energy of rabbit
if abs(Escaping_Energy)>=1
%% Exploration:
% Harris' hawks perch randomly based on 2 strategy:
q=rand();
rand_Hawk_index = floor(N*rand()+1);
X_rand = X(rand_Hawk_index, :);
if q<0.5
% perch based on other family members
X(i,:)=X_rand-rand()*abs(X_rand-2*rand()*X(i,:));
elseif q>=0.5
% perch on a random tall tree (random site inside group's home range)
X(i,:)=(Rabbit_Location(1,:)-mean(X))-rand()*((ub-lb)*rand+lb);
end
elseif abs(Escaping_Energy)<1
%% Exploitation:
% Attacking the rabbit using 4 strategies regarding the behavior of the rabbit
%% phase 1: surprise pounce (seven kills)
% surprise pounce (seven kills): multiple, short rapid dives by different hawks
r=rand(); % probablity of each event
if r>=0.5 && abs(Escaping_Energy)<0.5 % Hard besiege
X(i,:)=(Rabbit_Location)-Escaping_Energy*abs(Rabbit_Location-X(i,:));
end
if r>=0.5 && abs(Escaping_Energy)>=0.5 % Soft besiege
Jump_strength=2*(1-rand()); % random jump strength of the rabbit
X(i,:)=(Rabbit_Location-X(i,:))-Escaping_Energy*abs(Jump_strength*Rabbit_Location-X(i,:));
end
%% phase 2: performing team rapid dives (leapfrog movements)
if r<0.5 && abs(Escaping_Energy)>=0.5, % Soft besiege % rabbit try to escape by many zigzag deceptive motions
Jump_strength=2*(1-rand());
X1=Rabbit_Location-Escaping_Energy*abs(Jump_strength*Rabbit_Location-X(i,:));
if fobj(X1)<fobj(X(i,:)) % improved move?
X(i,:)=X1;
else % hawks perform levy-based short rapid dives around the rabbit
X2=Rabbit_Location-Escaping_Energy*abs(Jump_strength*Rabbit_Location-X(i,:))+rand(1,dim).*Levy(dim);
if (fobj(X2)<fobj(X(i,:))), % improved move?
X(i,:)=X2;
end
end
end
if r<0.5 && abs(Escaping_Energy)<0.5, % Hard besiege % rabbit try to escape by many zigzag deceptive motions
% hawks try to decrease their average location with the rabbit
Jump_strength=2*(1-rand());
X1=Rabbit_Location-Escaping_Energy*abs(Jump_strength*Rabbit_Location-mean(X));
if fobj(X1)<fobj(X(i,:)) % improved move?
X(i,:)=X1;
else % Perform levy-based short rapid dives around the rabbit
X2=Rabbit_Location-Escaping_Energy*abs(Jump_strength*Rabbit_Location-mean(X))+rand(1,dim).*Levy(dim);
if (fobj(X2)<fobj(X(i,:))), % improved move?
X(i,:)=X2;
end
end
end
%%
end
end
t=t+1;
CNVG(t)=Rabbit_Energy;
% Print the progress every 100 iterations
% if mod(t,100)==0
% display(['At iteration ', num2str(t), ' the best fitness is ', num2str(Rabbit_Energy)]);
% end
end
toc
end
% ___________________________________
function o=Levy(d)
beta=1.5;
sigma=(gamma(1+beta)*sin(pi*beta/2)/(gamma((1+beta)/2)*beta*2^((beta-1)/2)))^(1/beta);
u=randn(1,d)*sigma;v=randn(1,d);step=u./abs(v).^(1/beta);
o=step;
end
04.代码效果图
获取代码请关注MATLAB科研小白的个人公众号(即文章下方二维码),并回复:HHO本公众号致力于解决找代码难,写代码怵。各位有什么急需的代码,欢迎后台留言~不定时更新科研技巧类推文,可以一起探讨科研,写作,文献,代码等诸多学术问题,我们一起进步。