First, the way to obtain the code
Get the code 1: by subscribing to the paid column of purple Pole Shenguang blog, you can get this code with payment voucher, private letter bloggers.
Access code 2: Open CSDN membership through the homepage of CSDN blog, and the code can be obtained by payment voucher and private letter bloggers.
[optimization algorithm] Spotted hyena optimization algorithm (SHO) [Matlab source code 1463 issues]
Note: For CSDN membership, only one code can be obtained free of charge (valid within three days from the date of opening); Subscribe to the paid column of purple Pole Shenguang blog, you can get 2 copies of the code for free (valid for three days from the subscription date);
2. Introduction to spotted hyena optimization algorithm
Spotted hyenas rely on their social relationships and cooperative behavior to quickly and efficiently hunt prey. The spotted hyena optimization algorithm was simulated by using four basic steps: searching prey, surrounding prey, hunting behavior and attacking prey, and the mathematical modeling of these four steps was established.1 Surround the preySpotted hyenas can know where their prey are and surround them. In order to mathematically model the social hierarchy of spotted hyenas, it is considered that the best encircled object is the target prey or the target close to the optimal, because the search space is not priori. Other individuals will try to update their position and hunt the best encircled object after determining the best encircled object. The mathematical model of this behavior is expressed by the following equation: 2. Hunting BehaviorSpotted hyenas usually hunt in packs, relying on a group of trusted friends and the ability to spot prey. To precisely define spotted hyena behavior, it is assumed that the best searching individual, whichever is optimal, knows the location of prey. Other search individuals form a cluster, a group of trusted friends, to the best search individuals, and save the best hunting plan obtained so far to update their location. The mathematical model of hunting behavior is: 3 Attacking preyAttacking the prey can reduce the value of vector H. In the simulation process, vector E also changes with the change of vector H. The mathematical formula for attacking prey is described as follows: 4 Hunt for preySpotted hyena algorithm is mainly based on the location of spotted hyenas to find prey. They move away from each other, seeking and attacking prey. When the convergence factor is E, spotted hyenas will disperse away from the current prey. This mechanism allows the SHO algorithm to search globally. B contains the random value and provides the random weight of the prey, which helps the SHO algorithm search and avoid local optimization, so that the SHO algorithm meets the termination condition.
Three, some source code
clear all
clc
SearchAgents=30;
Fun_name='F1';
Max_iterations=1000;
[lowerbound,upperbound,dimension,fitness]=fun_info(Fun_name);
[Best_score,Best_pos,SHO_curve]=sho(SearchAgents,Max_iterations,lowerbound,upperbound,dimension,fitness);
figure('Position'[300 300 400 300])
plots=semilogx(SHO_curve,'Color'.'g');
set(plots,'linewidth'.2)
hold on
title('Objective space')
xlabel('Iterations');
ylabel('Best fitness score');
axis tight
grid on
box on
legend('SHO')
display(['The best optimal value of the objective function found by SHO is : ', num2str(Best_score)]);
function func_plot(fun_name)
[lowerbound,upperbound,dimension,fitness]=fun_info(fun_name);
switch fun_name
case 'F1'
x=- 100.:2:100; y=x; % [- 100..100]
case 'F2'
x=- 100.:2:100; y=x; % [- 10.10]
case 'F3'
x=- 100.:2:100; y=x; % [- 100..100]
case 'F4'
x=- 100.:2:100; y=x; % [- 100..100]
case 'F5'
x=- 200.:2:200; y=x; % [- 5.5]
case 'F6'
x=- 100.:2:100; y=x; % [- 100..100]
case 'F7'
x=- 1:0.03:1; y=x %[- 1.1]
case 'F8'
x=- 500.:10:500; y=x; % [- 500..500]
case 'F9'
x=- 5:0.1:5; y=x; % [- 5.5]
case 'F10'
x=- 20:0.5:20; y=x; % [- 500..500]
case 'F11'
x=- 500.:10:500; y=x; % [0.5.0.5]
case 'F12'
x=- 10:0.1:10; y=x; %[-pi,pi]case 'F13'
x=- 5:0.08:5; y=x; % [- 3.1]
case 'F14'
x=- 100.:2:100; y=x; % [- 100..100]
case 'F15'
x=- 5:0.1:5; y=x; % [- 5.5]
case 'F16'
x=- 1:0.01:1; y=x; % [- 5.5]
case 'F17'
x=- 5:0.1:5; y=x; % [- 5.5]
case 'F18'
x=- 5:0.06:5; y=x; % [- 5.5]
case 'F19'
x=- 5:0.1:5; y=x; % [- 5.5]
case 'F20'
x=- 5:0.1:5; y=x; % [- 5.5]
case 'F21'
x=- 5:0.1:5; y=x; % [- 5.5]
case 'F22'
x=- 5:0.1:5; y=x; % [- 5.5]
case 'F23'
x=- 5:0.1:5; y=x; % [- 5.5]
end
L=length(x);
f=[];
for i=1:L
for j=1:L
if strcmp(fun_name,'F15') = =0 && strcmp(fun_name,'F19') = =0 && strcmp(fun_name,'F20') = =0 && strcmp(fun_name,'F21') = =0 && strcmp(fun_name,'F22') = =0 && strcmp(fun_name,'F23') = =0
f(i,j)=fitness([x(i),y(j)]);
end
if strcmp(fun_name,'F15')= =1
f(i,j)=fitness([x(i),y(j),0.0]);
end
if strcmp(fun_name,'F19')= =1
f(i,j)=fitness([x(i),y(j),0]);
end
if strcmp(fun_name,'F20')= =1
f(i,j)=fitness([x(i),y(j),0.0.0.0]);
end
if strcmp(fun_name,'F21')= =1 || strcmp(fun_name,'F22') = =1 ||strcmp(fun_name,'F23') = =1
f(i,j)=fitness([x(i),y(j),0.0]);
end
end
end
surfc(x,y,f,'LineStyle'.'none');
end
Copy the code
4. 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. [3] SHI Yuanbo. [4] Li Tangbing, Hu Jinhong, Zhou Qiukuan, Et al. Optimization of Cloud Computing Task Scheduling Algorithm based on Improved Swarm Spider [J]. Computer Programming Skills and Maintenance, 2021,(04) Infrared image segmentation based on improved spotted hyena optimization algorithm [J]. Infrared Technology. 201,43(10)