第一期开源文章:
所分享的的内容 全部提供硬核开源代码!!!欢迎大家与我交流
1
蝴蝶优化算法简介
蝴 蝶 优 化 算 法 (butterfly optimization algorithm,BOA)模拟自然界中的蝴蝶采食花蜜以及求偶的行为,由印度学者Arora S, Singh S与2018年提出。BOA 算法调节参数少,原理简单,易于实现,与常见的群智能优化算法一样容易陷入局部最优,后期迭代收敛速度较慢的特点。改进思路可看文末给出的参考文献。

2
BOA算法原理
真实的蝴蝶觅食和寻偶行为有很多不确定的因素,无法在算法中体现出来,因此蝴蝶优化算法建立在两个理想化的条件下。假设每只蝴蝶都能产生不同程度的香味(适应度值)并且能嗅到来自不同方向的香味。
蝴蝶的香味浓度f的大小取决于以 下三个因 素:分 别 是感 知 形 态c、 刺激强度I、幂 指 数a用方程表示如下:

全局搜索阶段(可加入levy飞行、动态收敛因子等方法进行改进),蝴蝶朝向最优蝴蝶位置移动:

局部搜索阶段(需要改进的地方),蝴蝶将随机移动,蝴蝶位置更新公式如下:

算法的伪代码:

3
BOA算法源代码
% BOA.m%—————————————————感谢关注了不起的群智能%function [fmin,best_pos,Convergence_curve]=BOA(n,N_iter,Lb,Ub,dim,fobj)% n is the population size% N_iter represnets total number of iterationsp=0.8; % probabibility switchpower_exponent=0.1;sensory_modality=0.01;%Initialize the positions of search agentsSol=initialization(n,dim,Ub,Lb);for i=1:nFitness(i)=fobj(Sol(i,:));end% Find the current best_pos[fmin,I]=min(Fitness);best_pos=Sol(I,:);S=Sol;% Start the iterations -- Butterfly Optimization Algorithmfor t=1:N_iterfor i=1:n% Loop over all butterflies/solutions%Calculate fragrance of each butterfly which is correlated with objective functionFnew=fobj(S(i,:));FP=(sensory_modality*(Fnew^power_exponent));%Global or local searchif rand<pdis = rand * rand * best_pos - Sol(i,:); %Eq. (2) in paperS(i,:)=Sol(i,:)+dis*FP;else% Find random butterflies in the neighbourhoodepsilon=rand;JK=randperm(n);dis=epsilon*epsilon*Sol(JK(1),:)-Sol(JK(2),:);S(i,:)=Sol(i,:)+dis*FP; %Eq. (3) in paperend% Check if the simple limits/bounds are OKS(i,:)=simplebounds(S(i,:),Lb,Ub);% Evaluate new solutionsFnew=fobj(S(i,:)); %Fnew represents new fitness values% If fitness improves (better solutions found), update thenif (Fnew<=Fitness(i))Sol(i,:)=S(i,:);Fitness(i)=Fnew;end% Update the current global best_posif Fnew<=fminbest_pos=S(i,:);fmin=Fnew;endendConvergence_curve(t,1)=fmin;%Update sensory_modalitysensory_modality=sensory_modality_NEW(sensory_modality, N_iter);end% Boundary constraintsfunction s=simplebounds(s,Lb,Ub)% Apply the lower boundns_tmp=s;I=ns_tmp<Lb;ns_tmp(I)=Lb;% Apply the upper boundsJ=ns_tmp>Ub;ns_tmp(J)=Ub;% Update this new moves=ns_tmp;function y=sensory_modality_NEW(x,Ngen)y=x+(0.025/(x*Ngen));
4
BOA仿真实验

5
[1]AroraS,SinghS.Butterflyoptimizationalgorithm:Anovel approachforglobaloptimization [J].SoftComputing,2019,23 (3):715-734.
[2]Hosseinzadeh Mehdi,Masdari Mohammad,Rahmani Amir Masoud,Mohammadi Mokhtar,Aldalwie Adil Hussain Mohammed,Majeed Mohammed Kamal,Taher Karim Sarkhel H.. Correction to: Improved Butterfly Optimization Algorithm for Data Placement and Scheduling in Edge Computing Environments[J]. Journal of Grid Computing,2021,19(3):
[3]刘景森,马义想,李煜.改进蝴蝶算法求解多维复杂函数优化问题[J].电子学报,2021,49(06):1068-1076.
[4]郑洪清,冯文健,周永权.融合正弦余弦算法的蝴蝶优化算法[J].广西科学,2021,28(02):152-159.
[5]郭德龙,周锦程,周永权.基于Levy飞行改进蝴蝶优化算法[J].数学的实践与认识,2021,51(12):130-137.
6
代码获取方式
后台回复 BOA
详细代码+中文注释
下期更新海洋捕食者算法





