1 内容介绍
基于海马优化器求解单目标优化问题附matlab代码
2 部分代码
%_______________________________________________________________________________________%
% Sea-Horse optimizer (SHO)
% Developed in MATLAB R2018a
% optimization problems.
% Applied Intelligence
%_______________________________________________________________________________________%
clear all
clc
close all
popsize=30; % Number of search agents
Max_iter=100; % Maximum iteration
F_name='F4'; % Name of the test function that can be from F1 to F23 (Table 2,3,4 in the paper)
[LB,UB,Dim,fobj]=BenchmarkFunctions(F_name);% Load details of the selected benchmark function
tic
[ObjectiveFitness,ObjectivePosition,Convergence_curve,Trajectories,fitness_history, population_history]=SHO(popsize,Max_iter,LB,UB,Dim,fobj);
time=toc;
figure('Position',[454 445 694 297]);
subplot(1,2,1);
func_plot(F_name);
title('Parameter space')
xlabel('x_1');
ylabel('x_2');
zlabel([F_name,'( x_1 , x_2 )'])
subplot(1,2,2);
semilogy(1:Max_iter,Convergence_curve,'color','r','linewidth',2.5);
title('Convergence curve');
xlabel('Iteration');
ylabel('Best score obtained so far')
display(['The running time is:', num2str(time)]);
display(['The best solution obtained by SHO is : ', num2str(ObjectiveFitness)]);
display(['The best optimal sea horse of the objective funciton found by SHO is : ', num2str(ObjectivePosition)]);
3 运行结果