【优化求解】基于哈里斯鹰算法HHO求解最优目标matlab源码

132 阅读1分钟

1 简介

2 部分代码

%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clear all
close all
clc

N=30; % Number of search agents

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

T=100; % 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('Position',[269   240   660   290])
%Draw search space
subplot(1,2,1);
func_plot(Function_name);
title('Parameter space')
xlabel('x_1');
ylabel('x_2');
zlabel([Function_name,'( x_1 , x_2 )'])
subplot(1,2,2);
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)]);

img =gcf;  %获取当前画图的句柄
print(img, '-dpng''-r600''./img1.png')         %即可得到对应格式和期望dpi的图像       

3 仿真结果

4 参考文献

[1]贾鹤鸣, 康立飞, 孙康健, 彭晓旭, 李瑶, & 姜子超. (2019). 哈里斯鹰算法优化脉冲耦合神经网络的图像自动分割. 应用科技(4).​

5 MATLAB代码与数据下载地址

见博客主页