% 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: as_heidari@ut.ac.ir, aliasghar68@gmail.com,
% e-Mail (Singapore): aliasgha@comp.nus.edu.sg, t0917038@u.nus.edu
% _____________________________________________________
% Co-author and Advisor: Seyedali Mirjalili
%
% e-Mail: ali.mirjalili@gmail.com
% seyedali.mirjalili@griffithuni.edu.au
%
% 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]=TTHHO(N,T,lb,ub,dim,fobj)
disp('TTHHO 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,:);
best_voltage=Rabbit_Location;
end
end
K=1; % K is a real can be 0, 1, 2,....
E1=2*(1-(t/T)); % factor to show the decreaing energy of rabbit
% Update the location of Harris' hawks
delta=rand()*(sin((pi/2)*(t/T))+cos((pi/2)*(t/T))-1);
for i=1:size(X,1)
r1=rand();r2=rand();
r3 = rand();
L=2*E1*r1-E1;
C1=K*r2*E1+1;
E0=2*rand()-1; %-1<E0<1
Escaping_Energy=E1*(E0); % escaping energy of rabbit
r9=(2*pi)*rand();
r10=2*rand;
r11=rand();
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
if r3<0.5
if r11<0.5
X(i,:)=X_rand-rand()*abs(X_rand-2*rand()*(best_voltage+exp(-L)*(X(i,:)+(E1*sin(r9)*abs(r10*best_voltage-X(i,:)))-C1*best_voltage)));
elseif r11>=0.5
X(i,:)=X_rand-rand()*abs(X_rand-2*rand()*(best_voltage+exp(-L)*(X(i,:)+(E1*cos(r9)*abs(r10*best_voltage-X(i,:)))-C1*best_voltage)));
end
elseif r3>=0.5
if r11<0.5
X(i,:)=X_rand-rand()*abs(X_rand-2*rand()*(best_voltage+exp(-L)*(cos(L*2*pi)+tan(L*2*pi))*abs(X(i,:)+(E1*sin(r9)*abs(r10*best_voltage-X(i,:)))-C1*best_voltage)));
elseif r11 >= 0.5
X(i,:)=X_rand-rand()*abs(X_rand-2*rand()*(best_voltage+exp(-L)*(tan(L*2*pi)+sin(L*2*pi))*abs(X(i,:)+(E1*cos(r9)*abs(r10*best_voltage-X(i,:)))-C1*best_voltage)));
end
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
if r3<0.5
if r11<0.5
X(i,:)=(Rabbit_Location)-Escaping_Energy*abs(Rabbit_Location-(best_voltage+exp(-L)*(X(i,:)+(E1*sin(r9)*abs(r10*best_voltage-X(i,:)))-C1*best_voltage)));
elseif r11>=0.5
X(i,:)=(Rabbit_Location)-Escaping_Energy*abs(Rabbit_Location-(best_voltage+exp(-L)*(X(i,:)+(E1*cos(r9)*abs(r10*best_voltage-X(i,:)))-C1*best_voltage)));
end
elseif r3>=0.5
if r11<0.5
X(i,:)=(Rabbit_Location)-Escaping_Energy*abs(Rabbit_Location-(best_voltage+exp(-L)*(cos(L*2*pi)+tan(L*2*pi))*abs(X(i,:)+(E1*sin(r9)*abs(r10*best_voltage-X(i,:)))-C1*best_voltage)));
elseif r11 >= 0.5
X(i,:)=(Rabbit_Location)-Escaping_Energy*abs(Rabbit_Location-(best_voltage+exp(-L)*(tan(L*2*pi)+sin(L*2*pi))*abs(X(i,:)+(E1*cos(r9)*abs(r10*best_voltage-X(i,:)))-C1*best_voltage)));
end
end
end
if r>=0.5 && abs(Escaping_Energy)>=0.5 % Soft besiege
Jump_strength=2*(1-rand()); % random jump strength of the rabbit
if r3<0.5
if r11<0.5
X(i,:)=(Rabbit_Location-(best_voltage+exp(-L)*(X(i,:)+(E1*sin(r9)*abs(r10*best_voltage-X(i,:)))-C1*best_voltage)))-Escaping_Energy*abs(Jump_strength*Rabbit_Location-(best_voltage+exp(-L)*(X(i,:)+(E1*sin(r9)*abs(r10*best_voltage-X(i,:)))-C1*best_voltage)));
elseif r11>=0.5
X(i,:)=(Rabbit_Location-(best_voltage+exp(-L)*(X(i,:)+(E1*cos(r9)*abs(r10*best_voltage-X(i,:)))-C1*best_voltage)))-Escaping_Energy*abs(Jump_strength*Rabbit_Location-(best_voltage+exp(-L)*(X(i,:)+(E1*cos(r9)*abs(r10*best_voltage-X(i,:)))-C1*best_voltage)));
end
elseif r3>=0.5
if r11<0.5
X(i,:)=(Rabbit_Location-(best_voltage+exp(-L)*(cos(L*2*pi)+tan(L*2*pi))*abs(X(i,:)+(E1*sin(r9)*abs(r10*best_voltage-X(i,:)))-C1*best_voltage)))-Escaping_Energy*abs(Jump_strength*Rabbit_Location-(best_voltage+exp(-L)*(cos(L*2*pi)+tan(L*2*pi))*abs(X(i,:)+(E1*sin(r9)*abs(r10*best_voltage-X(i,:)))-C1*best_voltage)));
elseif r11 >= 0.5
X(i,:)=(Rabbit_Location-(best_voltage+exp(-L)*(tan(L*2*pi)+sin(L*2*pi))*abs(X(i,:)+(E1*cos(r9)*abs(r10*best_voltage-X(i,:)))-C1*best_voltage)))-Escaping_Energy*abs(Jump_streng
![avatar](https://profile-avatar.csdnimg.cn/17abee78a3ef4024ad2bc8263f71c5ed_xixixixixixixi21.jpg!1)
自不量力的A同学
- 粉丝: 1115
- 资源: 2885
最新资源
- 基于FPGA的Verilog实现FOC电流环控制系统设计与实践:集成PI控制器与SVPWM算法,ADC采样与串口通信,清晰代码层次结构,结合Simulink模型与RTL图解,适用于BLDC与PMSM的
- VESC STM32F4磁链观测器及无感正弦FOC控制实现与工程应用:代码、文档与仿真详解,VESC STM32F4磁链观测器与无感正弦FOC控制:实现0速闭环启动技术指南,VESC STM32F4磁
- 基于Vue全家桶的现代化家庭农场管理系统设计源码
- 基于Java开发的his门诊系统设计源码
- 基于海思硬件平台与华为云的智能饮食营养数据分析系统CaloScan设计源码
- 基于微信小程序和JavaScript的半开源soulmate设计源码
- 冲床自动化送料程序:双轴控制,FX1S PLC与昆仑通态触摸屏协同,通用型板材冲压冲裁自动送料系统,冲床自动化送料程序:双轴控制,FX1S PLC与昆仑通态触摸屏协同,适用于广泛板材冲压冲裁自动送料系
- 基于JavaScript的蓝牙在线版本蓝牙秤设计源码
- 贝叶斯优化SVM模型:多特征输入与输出数据的分类预测与迭代优化图解,基于多特征输入的Bayes-SVM数据分类预测模型:迭代优化与混淆矩阵图分析,bayes-SVM贝叶斯优化支持向量机的数据分类预测
- COMSOL 5.6模拟裂隙岩体注浆中渗透率演化:变质量渗流模型研究及不同压力下的封堵模拟,COMSOL 5.6模拟裂隙岩体注浆:压力变化下的渗透率演化及变质量渗流研究,comsol5.6,模拟裂隙岩
- 基于关键点检测技术的飞机仪表盘识别设计源码
- 基于Vue框架的献血系统前端页面设计源码
- 基于Java的MaaS-ABAC-DP多维数据安全共享隐私保护设计方案源码
- 模拟浆液黏度时空变化对裂隙注浆影响的研究-基于COMSOL 5.6的数值模拟分析,模拟裂隙注浆过程中浆液黏度时空变化特征-基于Comsol 5.6模拟研究,comsol5.6,模拟浆液黏度时空变化
- 基于Vue的纯Admin管理后台项目设计源码保姆级教程文档
- 基于GPT技术的Vue框架试验性辅助学习网站设计源码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)