A brief introduction of Harris Eagle algorithm

HHO algorithm uses mathematical formulas to simulate the strategies of real Harris eagle to capture prey under different mechanisms. In HHO, Harris eagle is the candidate solution, and prey approaches the optimal solution iteratively. HHO algorithm includes two stages: global exploration stage and local mining stage.1. Global exploration stageDuring this stage, the Harris eagle is in a waiting state, carefully inspecting and monitoring the search space [LB, UB] to find prey. It searches for prey in random places according to two strategies, and updates its position with probability Q during iteration. The mathematical expression is as follows:Where, Xt+1 and Xt are the positions of the Harris eagle at the t+1 and t iterations respectively, Xrabbit and t are the positions of the prey at the t iteration, q and r1,r2,r3 and r4 are random numbers in the interval (0,1), lb is the lower bound of the search space, ub is the upper bound of the search space. Xrand, t represents the random position of Harris’ eagle in iteration T, Xm,t represents the average position of Harris’ eagle in iteration T, and the formula is as follows: 2 Transition StageThe accurate operation of any swarm intelligence algorithm requires the right balance between exploration and exploitation. HHO realizes the transition from exploration to mining through the energy equation of prey, and its model is as follows:Where, E represents the escape energy of prey, E0 is the initial state of prey energy, and the formula is E0=2*rand-1,rand is a random number between (0,1), T is the maximum iteration number, T is the current iteration number. When | E | 1 or more, the Harris hawk algorithm will perform global exploration; Otherwise, HHO algorithm enters local mining.

3. Local mining stage

During this stage, the Harris-Hawk, based on the detection of the previous stage, carries out a surprise attack on the intended prey while the prey tries to flee from danger. The HHO algorithm proposed four possible strategies to simulate the attack behavior based on the flight behavior of prey and the pursuit strategy of Harris eagle. λ is used to represent the probability of the prey’s successful escape, when λ<0.5, the prey’s successful escape; When λ≥0.5, the prey failed to escape. Use parameter E to simulate a Harris Eagle’s soft or hard siege strategy. When | E | 0.5 or higher, perform soft siege; Otherwise, execute a hard siege. Case1: Soft siege. When | E | 0.5 or higher, lambda acuity 0.5, prey have enough energy and escaped by jumping rounded up, while Harris hawk will gradually consumed energy, and then choose the best position to raid subduction to arrest its prey. The equation for the update position is as follows:Where, Xt is the difference between the position of the prey and the Harris eagle during iteration, J=2(1-R5) represents the random jump during the escape of the prey, and R5 is a random number between 0 and 1.

Case2: hard siege. When the | E | < 0.5, lambda acuity 0.5, exhausted prey, Harris hawk choose raid quickly. The location is updated as follows:Case3: tired speed dive soft siege. When | E | 0.5 or higher, lambda < 0.5, prey has enough energy E escape, Harris hawk before the raid will build a siege. In order to simulate the escape mode and jumping action of prey, levy function LF was integrated into HHO algorithm. The strategy for updating locations is:Where, D is the problem dimension and S is the random row vector of D dimension.

Case4: tired speed dive hard siege. When | E | < 0.5, lambda < 0.5, low energy E prey, Harris hawk before the raid build siege on its prey, position update are as follows:The HHO algorithm uses the prey energy E and the factor λ to adjust the four trapping mechanisms between the Harris eagle and the prey (rabbit) to realize the optimal solution.

Two, some source code


clear all %#ok<CLALL>
close all
clc

N=30; % Number of search agents

Function_name='F1'; % Name of the test function 

T=500; % Maximum number of iterations

% Load details of the selected benchmark function
[lb,ub,dim,fobj]=Get_Functions_details(Function_name);

[Rabbit_Energy,Rabbit_Location,CNVG]=HHO(N,T,lb,ub,dim,fobj);


%Draw objective space
figure,
hold on
semilogy(CNVG,'Color'.'b'.'LineWidth'.4);
title('Convergence curve')
xlabel('Iteration');
ylabel('Best fitness obtained so far');
axis tight
grid off
box on
legend('HHO')

display(['The best location of HHO is: ', num2str(Rabbit_Location)]);
display(['The best fitness of HHO is: ', num2str(Rabbit_Energy)]);

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 Rabbitif 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_rand2 -*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)
            ifR < 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

        
Copy the code

3. Operation results

Matlab version and references

1 matlab version 2014A

[1] Yang Baoyang, YU Jizhou, Yang Shan. Intelligent Optimization Algorithm and Its MATLAB Example (2nd Edition) [M]. Publishing House of Electronics Industry, 2016. [2] ZHANG Yan, WU Shuigen. MATLAB Optimization Algorithm source code [M]. Tsinghua University Press, 2017.