这篇“怎么用matlab代码解决单目标优化问题”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“怎么用matlab代码解决单目标优化问题”文章吧。
部分代码
%_______________________________________________________________________________________%
% 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)]);
运行结果
以上就是关于“怎么用matlab代码解决单目标优化问题”这篇文章的内容,相信大家都有了一定的了解,希望小编分享的内容对大家有帮助,若想了解更多相关的知识内容,请关注编程网行业资讯频道。