function Dive_Explor_Exploit(SearchAgents_no,Max_iteration,dim,Function_name,search_history)
% search_history的格式为 [SearchAgents_no*Max_iteration，dim]
%% population diversity
for t=1:Max_iteration
    x = search_history((t-1)*SearchAgents_no+1:t*SearchAgents_no,:);
    cd(t,:)=sum(x)/dim;   
    for i=1:SearchAgents_no
        A(i) = sum((x(i,:)-cd(t,:)).^2);
    end
    Ic(t)=sqrt(sum(A));
end
figure('Name','population diversity')
plot(Ic,'Color', [0.2, 0.6, 0.2], 'LineWidth', 2);
xlabel('Function calls');ylabel('Population Diversity');
title(strcat('F', num2str(Function_name)));
legend('AOO')
grid on
set(gcf,'position',[300  100  375  250]) % 图窗位置及大小
set(gca, 'XTickLabel', arrayfun(@(x) num2str(x), 0:6000:30000, 'UniformOutput', false), 'FontAngle', 'normal');
saveas(gcf, sprintf('PopulationDiversity_F%d.eps', Function_name), 'epsc'); % 保存为 EPS
saveas(gcf, sprintf('PopulationDiversity_F%d.svg', Function_name), 'svg');  % 保存为 SVG
%% Exploration and exploitation analysis
for t=1:Max_iteration
    x = search_history((t-1)*SearchAgents_no+1:t*SearchAgents_no,:);
    for i=1:SearchAgents_no
       B(i,:) =abs(median(x)-x(i,:));
    end
    Div(t) = mean(mean(B));
end    
for t=1:Max_iteration
    Exploration(t) = 100*Div(t)/max(Div);
    Exploitation(t) = 100*abs(Div(t)-max(Div))/max(Div);
end
    
figure('Name','Exploration and exploitation')
plot(Exploration,'Color', [0 0.4470 0.7410], 'LineWidth', 2);
hold on
plot(Exploitation,'Color', [0.8500 0.3250 0.0980], 'LineWidth', 2);
xlabel('Function calls');ylabel('Percentage(%)');
title(strcat('F', num2str(Function_name)));
legend('Exploration','Exploitation')
grid on
set(gcf,'position',[700  100  375  250]) % 图窗位置及大小
set(gca, 'XTickLabel', arrayfun(@(x) num2str(x), 0:6000:30000, 'UniformOutput', false), 'FontAngle', 'normal');
saveas(gcf, sprintf('ExplorationExploitation_F%d.eps', Function_name), 'epsc'); % 保存为 EPS
saveas(gcf, sprintf('ExplorationExploitation_F%d.svg', Function_name), 'svg');  % 保存为 SVG
end