收敛分析包括搜索历史、平均适应度值、轨迹、和收敛曲线4个指标进行评估。
l=l+1;
Convergence_curve(l)=Alpha_score;
%-------------- 新加--------------------
search_history ((l-1)*SearchAgents_no+1:l*SearchAgents_no,:)=Positions; % search history
ave_fit(l) = mean(fitness); % average fitness
x_1st(l,:)= Positions(1,:); % 1st trajectory
clc;clear;close all;
%% 参数设置
SearchAgents_no=50; % 种群数
Function_name='F1'; % 函数名字 F1 to F23
Max_iteration=500; % 最大迭代次数
%% 加载测试函数信息
[lb,ub,dim,fobj]=Get_Functions_details(Function_name);
%% 优化算法
[Best_score,Best_pos,cg_curve,search_history,ave_fit,x_1st]=GWO2(SearchAgents_no,Max_iteration,lb,ub,dim,fobj);
%% 绘图
figure(1);
% 函数图
subplot(1,5,1);
func_plot(Function_name);
title([Function_name]);xlabel('x_1');ylabel('x_2');
zlabel([Function_name,'( x_1 , x