蝴蝶优化算法,CEC2005/2021/2022进行测试,MATLAB代码免费获取,与麻雀,蜣螂,灰狼算法比较...

今天为大家带来一期蝴蝶优化算法。并与麻雀,蜣螂,灰狼算法比较。

51707cde1e4cea7978e12b61d4529a08.png

蝴蝶优化算法( BOA) 是 Arora [1]等人于2019年提出的一种模拟蝴蝶觅食和求偶行为的新型元启发式优化算法。基本 BOA 中参 数少、原理简单、易于实现。

原理详解

蝴蝶优化算法是模拟自然界中蝴蝶觅食( 花蜜) 和求偶行 为而衍生出的一种新型群智能优化算法。从生物学上讲,蝴蝶 有感官感受器用来闻/感觉食物及花朵的香味,这些感受器被称为化学感受器,分散在蝴蝶身体的各个部位,如腿、触须等。

步骤: 

a) 所有的蝴蝶会散发香味,使蝴蝶个体之间相互吸引。

b) 每只蝴蝶都会随机移动或向发出最多香味的蝴蝶移动。 

c) 蝴蝶的刺激强度受目标函数的影响或决定。 

d) 全局搜索和局部搜索使用切换概率 p 来控制,由于物理近似度以及风雨、雷电等各种其他自然因素等,局部搜索和全 局开采的切换概率 p 有重要意义。在BOA 中,每一只蝴蝶有它自己独特的感觉和个体感知能力,同时这也是区别于其他群智能算法的一个重要特征。蝴蝶产生香味的数学公式:

48471efe4fa95d4b09adbb173fc175db.png    (1)

其中: f 是香味的感知强度,即香味能够被其他蝴蝶感知的强 度; c 是蝴蝶的感觉模态; I 是刺激强度; a 是依赖于模态的幂指数,它解释了不同程度香味的吸收。在全局搜索阶段,蝴蝶朝着最优的蝴蝶 ( 解 g* ) 移动,全局位置更新公式:  794f925cae95ad4dc4262a94da80f518.png (2)

其中: xti是第 t 次迭代中第 i 只蝴蝶的解向量 xi ; g* 表示在当 前迭代的所有解中的最优解; 第 i 只蝴蝶发出的香味用fi表示; r 是[0,1]的随机数。局部位置更新公式为:a43df1da1a9ce9d31810129fe8e44ff8.png  (3)

基本蝴蝶算法流程如图所示:

be6b879010df4fc0a528b8b2ab76b475.png

结果展示

CEC2005测试结果:

c0d1a162a4a2f5a20a130a3abd596436.png

4ad458ede91979646157632bf8d58a82.png

aae0d7c2c7c67e2e4ae0495ebe13ab04.png

0d15879e8aa1334be6562dd5f07d1a4e.png

f3e9c74c8abbfde7ba7d3a3841350138.png

CEC2021测试结果:

f3f6e8dfae56b9a26399ca5e04fd5b37.png

5d054e3a8576729c46e2ad72cdf88223.png

CEC2022测试结果:

0b72de2f024e908169fd237ea46b43c4.png

aed1fa9980ac367b3e7117b2c26df28b.png

可以看到蝴蝶算法的寻优能力令人堪忧呀,不过这也说明了该算法的改进空间很大!

代码展示

%Butterfly optimization algorithm
% AroraS,SinghS.Butterflyoptimizationalgorithm:Anovel approach for global optimization [J].
% SoftComputing,2019,23 (3):715-734.
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 iterations
p=0.8;                       % probabibility switch
power_exponent=0.1;
sensory_modality=0.01;


%Initialize the positions of search agents
Sol=initialization(n,dim,Ub,Lb);
for i=1:n
   Fitness(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 Algorithm 
for t=1:N_iter
        for i=1:n% Loop over all butterflies/solutions
           %Calculate fragrance of each butterfly which is correlated with objective function
          Fnew=fobj(S(i,:));
          FP=(sensory_modality*(Fnew^power_exponent));   
          %Global or local search
          if rand<p    
            dis = rand * rand * best_pos - Sol(i,:);        %Eq. (2) in paper
            S(i,:)=Sol(i,:)+dis*FP;
           else
              % Find random butterflies in the neighbourhood
              epsilon=rand;
              JK=randperm(n);
              dis=epsilon*epsilon*Sol(JK(1),:)-Sol(JK(2),:);
              S(i,:)=Sol(i,:)+dis*FP;                         %Eq. (3) in paper
         end
         % Check if the simple limits/bounds are OK
            S(i,:)=simplebounds(S(i,:),Lb,Ub);
            % Evaluate new solutions
            Fnew=fobj(S(i,:));  %Fnew represents new fitness values
            % If fitness improves (better solutions found), update then
            if (Fnew<=Fitness(i))
                Sol(i,:)=S(i,:);
                Fitness(i)=Fnew;
            end
        % Update the current global best_pos
           if Fnew<=fmin
                best_pos=S(i,:);
                fmin=Fnew;
           end
         end


         Convergence_curve(t,1)=fmin;
         %Update sensory_modality
         sensory_modality=sensory_modality_NEW(sensory_modality, N_iter);
end
end
% Boundary constraints
function s=simplebounds(s,Lb,Ub)
 % Apply the lower bound
 ns_tmp=s;
 I=ns_tmp<Lb;
 ns_tmp(I)=Lb;
  % Apply the upper bounds 
 J=ns_tmp>Ub;
  ns_tmp(J)=Ub;
  % Update this new move 
  s=ns_tmp;
end
function y=sensory_modality_NEW(x,Ngen)
y=x+(0.025/(x*Ngen));
end

下一期对蝴蝶算法进行改进!

代码免费获取方式

完整代码获取方式:后台回复关键字,不区分大小写。关键字:

TGDM827

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

今天吃饺子

不想刀我的可以选择爱我

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值