【優化演算法】鴿群優化演算法(PIO)【含Matlab原始碼 1077期】
阿新 • • 發佈:2021-07-02
一、簡介
2014 年 段 海 濱 教 授 通 過 歸 納 總 結 , 提 出 鴿 群 算 法(Pigeon-inspired Optimization PIO),PIO 是模擬鴿子歸巢行為而設計出來的群智慧優化演算法。PIO 具有原理簡明的特點、需要調整引數極少、易於被實現。與其他演算法比較有著計算相對簡單,魯棒性相對較強等明顯的優點。
演算法原理
鴿子在距離目的地較遠時,是在地磁場和地標建築的幫助下到達目的地。影響鴿群歸巢的關鍵原因可分為 3 類,第一個原因是太陽,第二個原因是地球的磁場,第三個原因是地貌景觀,而鴿子在飛行的過程中,根據不同的情況會使用不同的巡航工具。首先通過地磁場來對一個大概的方向進行辨別,然後利用地貌景象對目前的方向實施修正,直到到達精確的目的地。所以 PIO 演算法中鴿子歸巢有兩個基本部分組成:指南針運算元和地標運算元。當鴿子距離自己目的地較遠時是利用地磁場來辨別方向,當距離目的地比較近時就利用當地地標來進行導航。在 PIO 中地圖和指標運算元模型的提出就是基於地磁場和太陽,而地標運算元模型的提出是基於地標。
** 指南針運算元**
地標運算元
二、原始碼
%_________________________________________________________________________% % 鴿群優化演算法 % %_________________________________________________________________________% % 使用方法 %__________________________________________ % 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 PIO: [Best_pos,Best_score,curve]=PIO(pop,Max_iter,lb,ub,dim,fobj) %__________________________________________ clear all clc % rng('default'); SearchAgents_no=50; % Number of search agents 種群數量 Function_name='F9'; % 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,PIO_curve]=PIO(SearchAgents_no,Max_iteration,lb,ub,dim,fobj); %開始優化 % This function containts full information and implementations of the benchmark % lb is the lower bound: lb=[lb_1,lb_2,...,lb_d] % up is the uppper bound: ub=[ub_1,ub_2,...,ub_d] % dim is the number of variables (dimension of the problem) function [lb,ub,dim,fobj] = Get_Functions_details(F) switch F case 'F1' fobj = @F1; lb=-100; ub=100; dim=30; case 'F2' fobj = @F2; lb=-10; ub=10; dim=30; case 'F3' fobj = @F3; lb=-100; ub=100; dim=30; case 'F4' fobj = @F4; lb=-100; ub=100; dim=30; case 'F5' fobj = @F5; lb=-30; ub=30; dim=30; case 'F6' fobj = @F6; lb=-100; ub=100; dim=30; case 'F7' fobj = @F7; lb=-1.28; ub=1.28; dim=30; case 'F8' fobj = @F8; lb=-500; ub=500; dim=30; case 'F9' fobj = @F9; lb=-5.12; ub=5.12; dim=30; case 'F10' fobj = @F10; lb=-32; ub=32; dim=30; case 'F11' fobj = @F11; lb=-600; ub=600; dim=30; case 'F12' fobj = @F12; lb=-50; ub=50; dim=30; case 'F13' fobj = @F13; lb=-50; ub=50; dim=30; case 'F14' fobj = @F14; lb=-65.536; ub=65.536; dim=2; case 'F15' fobj = @F15; lb=-5; ub=5; dim=4; case 'F16' fobj = @F16; lb=-5; ub=5; dim=2; case 'F17' fobj = @F17; lb=[-5,0]; ub=[10,15]; dim=2; case 'F18' fobj = @F18; lb=-2; ub=2; dim=2; case 'F19' fobj = @F19; lb=0; ub=1; dim=3; case 'F20' fobj = @F20; lb=0; ub=1; dim=6; case 'F21' fobj = @F21; lb=0; ub=10; dim=4; case 'F22' fobj = @F22; lb=0; ub=10; dim=4; case 'F23' fobj = @F23; lb=0; ub=10; dim=4; end end
三、執行結果
四、備註
版本:2014a