% 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
自不量力的A同学
- 粉丝: 915
- 资源: 2811
最新资源
- 基于PLC的乡村供水系统设计 有组态仿真,CAD电气原理图,IO分配表,组态仿真,程序,演示视频 (1)该恒压供水系统能够正常供水, 保证供水质量;该恒压供水系统具有手动操作方式和自动操作方式,两种
- 西门子1200博图编程电机控制程序块,1200和1500通用的 1.包括正转,反转,变频控制,模拟量,故障,故障复位,控制字来显示电机的6种状态等 2.底层使用SCl编程,直接可以导出库文件.
- 铌酸锂声光效应声表面波激发 氧化锌与Si体系 2D 3D 注:目前未进行声光耦合,只激发声表面波
- 永磁同步电机无感foc位置估算源码 PMSM FOCBLDC 带仿真模型和源代码 无刷直流电机无感foc源码,无感foc算法源码 1 速度估算位置估算的代码所使用变量全部用实际值单位,能非常直观的
- xilinx vivado verilog srio开发,包含维护包、读写和门铃等功能,顶层封装为fifo,操作简单,简单修改即可应用到实际工程中,附含srio使用说明文档和免费license
- 二自由度车辆动力学模型 软件使用:Matlab Simulink 适用场景:采用模块化建模方法,适用于多种工况场景 产品simulink源码包含如下模块: 包含模块: 二自由度车辆动力学模型 包含:
- 基于滞环电流控制的VIENNA整流器
- FX5U程序三菱plc程序案例模板,一个完整的项目 用三菱FX5U,一共控制4个轴,说明了定位控制中的公共参数设定、回原点、JOG手动、决对定位、相对定位、控制等部分,威纶程序报警界面.多个机种选择
- 直流电机双闭环调速系统,以及直流电机双闭环系统建模,采用转速外环电流内环的控制结构,稳态效果良好,动态响应也较好,需要可以直接联系,仿真模型加对应的报告
- 松下FP-XH系列PLC程序,昆仑通态触摸屏程序 松下+昆仑通泰多工位装配机项目,多工位转配机,实际案例,在多工位直线,转盘类应用,会了这个就懂了. 1.国际标准IEC规范化编程模板框架程序 2.伺服
- 基于FPGA的以太网TCP数据回环设计 vivado工程
- 39节点故障数据,不同短路点,不同短路持续时间,不同负荷水平,共计3000次仿真
- 基于51单片机的电子秤 #有计价功能: 1)HX711传感器称重 2)按键可调整单价 3)去皮、清除功能 4)超重报警 5)可保存到小数点后三位 文档包含: 仿真、程序、原理图、PCB、报告
- T型三电平逆变器仿真模型,闭环控制,三电平SVPWM算法,可提供参考文献
- 光伏电池仿真模型,PV
- 二极管钳位,五电平SPWM仿真模型
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈