1 簡介
2016年 Mirjalili等 人通過模仿座頭鯨氣泡網(wǎng)狩獵策略提出了鯨魚優(yōu)化算法(WhaleOptimiza-tionAlgorithm富纸,WOA)工秩】闯桑基本原理:
2 部分代碼
%_________________________________________________________________________%
% Whale Optimization Algorithm (WOA) source codes demo 1.0 ? ? ? ? ? ? ? %
% You can simply define your cost in a seperate file and load its handle to fobj?
% The initial parameters that you need are:
%__________________________________________
% fobj = @YourCostFunction
% dim = number of your variables
% Max_iteration = maximum number of generations
% SearchAgents_no = number of search agents
% lb=[lb1,lb2,...,lbn] where lbn is the lower bound of variable n
% ub=[ub1,ub2,...,ubn] where ubn is the upper bound of variable n
% If all the variables have equal lower bound you can just
% define lb and ub as two single number numbers
% To run WOA: [Best_score,Best_pos,WOA_cg_curve]=WOA(SearchAgents_no,Max_iteration,lb,ub,dim,fobj)
%__________________________________________
clear all?
clc
SearchAgents_no=30; % Number of search agents
Function_name='F4'; % Name of the test function that can be from F1 to F23 (Table 1,2,3 in the paper)
Max_iteration=1000; % Maximum numbef of iterations
% Load details of the selected benchmark function
[lb,ub,dim,fobj]=Get_Functions_details(Function_name);
[Best_score,Best_pos,WOA_cg_curve]=WOA(SearchAgents_no,Max_iteration,lb,ub,dim,fobj);
figure('Position',[269 ? 240 ? 660 ? 290])
%Draw search space
subplot(1,2,1);
func_plot(Function_name);
title('Parameter space')
xlabel('x_1');
ylabel('x_2');
zlabel([Function_name,'( x_1 , x_2 )'])
%Draw objective space
subplot(1,2,2);
semilogy(WOA_cg_curve,'Color','r')
title('Objective space')
xlabel('Iteration');
ylabel('Best score obtained so far');
axis tight
grid on
box on
legend('WOA')
display(['The best solution obtained by WOA is : ', num2str(Best_pos)]);
display(['The best optimal value of the objective funciton found by WOA is : ', num2str(Best_score)]);
img =gcf; %獲取當前畫圖的句柄
print(img, '-dpng', '-r600', './運行結(jié)果4.png') ? ? ? ? %即可得到對應(yīng)格式和期望dpi的圖像
3 仿真結(jié)果
4 參考文獻
[1]黃清寶, 李俊興, 宋春寧, 徐辰華, & 林小峰. (2020). 基于余弦控制因子和多項式變異的鯨魚優(yōu)化算法. 控制與決策(3), 10.
博主簡介:擅長智能優(yōu)化算法炕淮、神經(jīng)網(wǎng)絡(luò)預測鉴竭、信號處理柿估、元胞自動機循未、圖像處理、路徑規(guī)劃秫舌、無人機等多種領(lǐng)域的Matlab仿真的妖,相關(guān)matlab代碼問題可私信交流。
部分理論引用網(wǎng)絡(luò)文獻足陨,若有侵權(quán)聯(lián)系博主刪除嫂粟。**完整代碼獲取關(guān)注微信公眾號天天matlab**