天天看點

蚱蜢優化算法(Matlab代碼實作)

💥💥💥💞💞💞歡迎來到本部落格❤️❤️❤️💥💥💥

🏆部落客優勢:🌞🌞🌞部落格内容盡量做到思維缜密,邏輯清晰,為了友善讀者。

⛳️座右銘:行百裡者,半于九十。

目錄

​​💥1 概述​​

​​📚2 運作結果​​

​​🎉3 參考文獻​​

​​🌈4 Matlab代碼實作​​

💥1 概述

蚱蜢優化算法(Matlab代碼實作)

本文提出了一種稱為蚱蜢優化算法(GOA)的優化算法,并将其應用于結構優化中的挑戰性問題。所提出的算法在數學上模拟和模拟自然界中蚱蜢群的行為,以解決優化問題。GOA算法首先在包括CEC2005在内的一系列測試問題上進行基準測試,以定性和定量地測試和驗證其性能。然後使用它來找到 52 巴桁架、3 巴桁架和懸臂梁的最佳形狀,以證明其适用性。結果表明,與文獻中已知的和最新的算法相比,所提出的算法能夠提供更好的結果。實際應用的結果也證明了GOA在解決未知搜尋空間的實際問題方面的優點。

📚2 運作結果

蚱蜢優化算法(Matlab代碼實作)

主函數代碼:

clear all 
 clcSearchAgents_no=100; % Number of search agents
Function_name='F1'; % Name of the test function that can be from F1 to F23 (Table 1,2,3 in the paper)
Max_iteration=500; % Maximum numbef of iterations
% Load details of the selected benchmark function
 [lb,ub,dim,fobj]=Get_Functions_details(Function_name);[Target_score,Target_pos,GOA_cg_curve, Trajectories,fitness_history, position_history]=GOA(SearchAgents_no,Max_iteration,lb,ub,dim,fobj);
figure('Position',[454   445   894   297])
 %Draw search space
 subplot(1,5,1);
 func_plot(Function_name);
 title('Parameter space')
 xlabel('x_1');
 ylabel('x_2');
 zlabel([Function_name,'( x_1 , x_2 )'])
 box on
 axis tightsubplot(1,5,2);
 hold on
 for k1 = 1: size(position_history,1)
     for k2 = 1: size(position_history,2)
         plot(position_history(k1,k2,1),position_history(k1,k2,2),'.','markersize',1,'MarkerEdgeColor','k','markerfacecolor','k');
     end
 end
 plot(Target_pos(1),Target_pos(2),'.','markersize',10,'MarkerEdgeColor','r','markerfacecolor','r');
 title('Search history (x1 and x2 only)')
 xlabel('x1')
 ylabel('x2')
 box on
 axis tightsubplot(1,5,3);
 hold on
 plot(Trajectories(1,:));
 title('Trajectory of 1st grasshopper')
 xlabel('Iteration#')
 box on
 axis tightsubplot(1,5,4);
 hold on
 plot(mean(fitness_history));
 title('Average fitness of all grasshoppers')
 xlabel('Iteration#')
 box on
 axis tight%Draw objective space
 subplot(1,5,5);
 semilogy(GOA_cg_curve,'Color','r')
 title('Convergence curve')
 xlabel('Iteration#');
 ylabel('Best score obtained so far');
 box on
 axis tight
 set(gcf, 'position' , [39         479        1727         267]); display(['The best solution obtained by GOA is : ', num2str(Target_pos)]);
 display(['The best optimal value of the objective funciton found by GOA is : ', num2str(Target_score)]);      

🎉3 參考文獻

​​🌈​​4 Matlab代碼實作

繼續閱讀