% Developed in MATLAB R2013b
% Source codes demo version 1.0
% _____________________________________________________
% Main paper:
% Harris hawks optimization: Algorithm and applications
% Ali Asghar Heidari, Seyedali Mirjalili, Hossam Faris, Ibrahim Aljarah, Majdi Mafarja, Huiling Chen
% Future Generation Computer Systems,
% DOI: https://doi.org/10.1016/j.future.2019.02.028
% https://www.sciencedirect.com/science/article/pii/S0167739X18313530
% _____________________________________________________
% You can run the HHO code online at codeocean.com https://doi.org/10.24433/CO.1455672.v1
% You can find the HHO code at https://github.com/aliasghar68/Harris-hawks-optimization-Algorithm-and-applications-.git
% _____________________________________________________
% 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: [email protected], [email protected],
% e-Mail (Singapore): [email protected], [email protected]
% _____________________________________________________
% Co-author and Advisor: Seyedali Mirjalili
%
% e-Mail: [email protected]
% [email protected]
%
% Homepage: http://www.alimirjalili.com
% _____________________________________________________
% Co-authors: Hossam Faris, Ibrahim Aljarah, Majdi Mafarja, and Hui-Ling Chen
% Homepage: http://www.evo-ml.com/2019/03/02/hho/
% _____________________________________________________
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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;
k = 0;
%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)
% 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
if t>0
[Rabbit_Location_temp,Rabbit_Energy_temp] = NelderMead(fobj,Rabbit_Location);
if Rabbit_Energy_temp<Rabbit_Energy
Rabbit_Location = Rabbit_Location_temp';
Rabbit_Energy = Rabbit_Energy_temp;
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
if T == 500
if t < 300
Escaping_Energy = E1*(E0); % escaping energy of rabbit
else
if mod(t,2)
Escaping_Energy = E1*(E0) + 0.6*(rand()*(1-k/200));
else
Escaping_Energy = E1*(E0) - 0.6*(rand()*(1-k/200));
end
k = k + 1;
end
end
if T == 300
if t < 200
Escaping_Energy = E1*(E0); % escaping energy of rabbit
else
if mod(t,2)
Escaping_Energy = E1*(E0) + 0.6*(rand()*(1-k/100));
else
Escaping_Energy = E1*(E0) - 0.6*(rand()*(1-k/100));
end
k = k + 1;
end
end
if abs(Escaping_Energy)>=1
%% Exploration:
% Harris' hawks perch randomly based on 2 strategy:
q=rand();
if q<0.5
% perch based on other family members
if N/10 == 3
rand_Hawk_index1 = floor(30*rand()+1);
rand_Hawk_index2 = floor(30*rand()+1);
rand_Hawk_index3 = floor(30*rand()+1);
X_rand1 = X(rand_Hawk_index1,:,:);
X_rand2 = X(rand_Hawk_index2,:,:);
X_rand3 = X(rand_Hawk_index3,:,:);
X(i,:) = ((abs(X(i,:)-X_rand1)+abs(X(i,:)-X_rand2)+abs(X(i,:)-X_rand3))./3) - X(i,:);
end
if N/10 == 5
rand_Hawk_index1 = floor(50*rand()+1);
rand_Hawk_index2 = floor(50*rand()+1);
rand_Hawk_index3 = floor(50*rand()+1);
rand_Hawk_index4 = floor(50*rand()+1);
rand_Hawk_index5 = floor(50*rand()+1);
X_rand1 = X(rand_Hawk_index1,:,:);
X_rand2 = X(rand_Hawk_index2,:,:);
X_rand3 = X(rand_Hawk_index3,:,:);
X_rand4 = X(rand_Hawk_index4,:,:);
X_rand5 = X(rand_Hawk_index5,:,:);
X(i,:) = ((abs(X(i,:)-X_rand1)+abs(X(i,:)-X_rand2)+abs(X(i,:)-X_rand3)+abs(X(i,:)-X_rand4)+abs(X(i,:)-X_rand5))./5) - X(i,:);
end
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
HHO_HHO_HHO优化_HHO优化算法_hho算法_改进_
版权申诉
5星 · 超过95%的资源 119 浏览量
2021-09-28
20:31:23
上传
评论 2
收藏 2KB RAR 举报
weixin_42668301
- 粉丝: 46
- 资源: 3993
最新资源
- 基于JavaScript讲解的数据结构和算法
- python计算机视觉python-computer-vision.rar
- VB+ACCESS计算机等级考试管理系统(源代码+系统+答辩PPT).zip
- python密码python-ciphers.rar
- 2c60fbb3dt9ad50ed8864298eea1484b.MP4
- 基于yolov8+dlib实现视觉识别的安全驾驶监测系统部署到jetson NX平台源码+模型.zip
- Qt框架+OpenCV+动态爱心+编程教学+520
- 基于opencv+yolov8实现目标追踪及驻留时长统计源码.zip
- 水稻病害基于Yolov8算法优化目标检测识别与AI辅助决策python源码+模型+使用说明.zip
- 海尔618算价表_七海5.20_16.00xlsx(1)(2).xlsx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈