1 简介2 部分代码登录后复制 clear all1.登录后复制 clc1.登录后复制 SearchAgents=30;1.登录后复制 Fun_name='F2';1.登录后复制 Max_iterations=1000;1.登录后复制 [lowerbound,upperbound,dimension,fitness]=fun_info(Fun_name);1.登录后复制 [Best_score,Best_pos,TSA_curve]=tsa(SearchAgents,Max_iterations,lowerbound,upperbound,dimension,fitness);1.登录后复制 figure('Position',[500 500 660 290])1.登录后复制 subplot(1,2,1);1.登录后复制 func_plot(Fun_name);1.登录后复制 title('Objective space')1.登录后复制 xlabel('x_1');1.登录后复制 ylabel('x_2');1.登录后复制 zlabel([Fun_name,'( x_1 , x_2 )'])1.登录后复制 subplot(1,2,2);1.登录后复制 plots=semilogx(TSA_curve,'Color','g');1.登录后复制 set(plots,'linewidth',2)1.登录后复制 hold on1.登录后复制 title('Objective space')1.登录后复制 xlabel('Iterations');1.登录后复制 ylabel('Best score');1.登录后复制 axis tight1.登录后复制 grid on1.登录后复制 box on1.登录后复制 legend('TSA')1.登录后复制 img =gcf; %获取当前画图的句柄1.登录后复制 print(img, '-dpng', '-r600', './img2.png') %即可得到对应格式和期望dpi的图像1.登录后复制 display(['The best solution obtained by TSA is : ', num2str(Best_pos)]);1.登录后复制 display(['The best optimal value of the objective funciton found by TSA is : ', num2str(Best_score)]);1.3 仿真结果4 参考文献[1]屈迟文, 彭小宁. 信息共享的记忆被囊群算法[J]. 模式识别与人工智能.