协同细菌觅食优化算法(Matlab代码实现)

💥💥💞💞欢迎来到本博客❤️❤️💥💥

🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。

⛳️座右铭:行百里者,半于九十。

📋📋📋本文目录如下:🎁🎁🎁

目录

💥1 概述

📚2 运行结果

🎉3 参考文献

🌈4 Matlab代码及文章阅读


💥1 概述

协同细菌觅食优化算法是一种基于大肠杆菌的社会觅食行为的新型优化算法。本文提出了对原始BFO算法的一种改进,即“协同细菌觅食优化”CBFO,这在解决复杂优化问题时显著改进了原始BFO。这一显著改进是通过对原始BFO应用两种协作方法实现的,即隐式空间分解级别上的串行异构协作和混合空间分解级别的串行异构合作。实验比较了两种CBFO变体与原始BFO、标准PSO和实数编码GA在四个广泛使用的基准函数上的性能。新方法显示出比原始BFO的性能显著提高,并且似乎与PSO和GA相当。

 

📚2 运行结果

c(:,1)=0.05*ones(S,1);   % the run length unit (the size of the step taken in each run or tumble)
% Initial positions
for m=1:S                    % the initital posistions 
    B(1,:,1,1,1)= 10*rand(S,1)';
    B(2,:,1,1,1)= 10*rand(S,1)';
end  
%% Loops
% (2) Elimination-dispersal loop
for l = 1:Ned
    % (3) Reproduction loop
    for k = 1:Nre    
        % (4) Chemotaxis (swim/tumble) loop
        for j=1:Nc
            % (4.1) Chemotatic step
            for i=1:S 
                % (4.2) Fitness function
                J(i,j,k,l) = fitnessBFO(B(:,i,j,k,l));
                % (4.3) Jlast
                Jlast=J(i,j,k,l);
                % (4.4) Tumble
                Delta(:,i) = unifrnd(-1,1,n,1); 
                % (4.5) Move
                B(:,i,j+1,k,l)=B(:,i,j,k,l)+c(i,k)*Delta(:,i)/sqrt(Delta(:,i)'*Delta(:,i));
                % (4.6) New fitness function
                J(i,j+1,k,l)=fitnessBFO(B(:,i,j+1,k,l));
                % (4.7) Swimming
                m=0; % counter for swim length
                while m < Ns 
                    m=m+1;
                     if J(i,j+1,k,l)<Jlast  
                        Jlast=J(i,j+1,k,l);    
                        B(:,i,j+1,k,l)=B(:,i,j+1,k,l)+c(i,k)*Delta(:,i)/sqrt(Delta(:,i)'*Delta(:,i)) ;  
                        J(i,j+1,k,l)=fitnessBFO(B(:,i,j+1,k,l));  
                     else       
                        m=Ns;     
                     end 
                end
                J(i,j,k,l)=Jlast; %???
            end % (4.8) Next bacterium
            x = B(1,:,j,k,l);
            y = B(2,:,j,k,l);
            clf % clears figure 
                run rose_fungraph.m
                plot(x,y,'*','markers',6) % plots figure
                axis([-1.5 1.5 -1 3]), axis square
                xlabel('x'); ylabel('y')
                title('Bacterial Foraging Optimization'); grid on
                legend('Rosenbrock function','Bacteria')
                pause(.01)
                hold on
        end % (5) if j < Nc, chemotaxis
        % (6) Reproduction
        % (6.1) Health
        Jhealth=sum(J(:,:,k,l),2);      % Set the health of each of the S bacteria
        [Jhealth,sortind]=sort(Jhealth);% Sorts bacteria in order of ascending values
        B(:,:,1,k+1,l)=B(:,sortind,Nc+1,k,l); 
        c(:,k+1)=c(sortind,k);          % Keeps the chemotaxis parameters with each bacterium at the next generation
        % (6.2) Split the bacteria
        for i=1:Sr % Sr??
                B(:,i+Sr,1,k+1,l)=B(:,i,1,k+1,l); % The least fit do not reproduce, the most fit ones split into two identical copies  
                c(i+Sr,k+1)=c(i,k+1);                 
        end
    end % (7) Loop to go to the next reproductive step
    % (8) Elimination-dispersal
        for m=1:S 
            if  Ped>rand % % Generate random number 
                B(1,:,1,1,1)= 50*rand(S,1)';
                B(2,:,1,1,1)= .2*rand(S,1)';  
            else 
                B(:,m,1,1,l+1)=B(:,m,1,Nre+1,l); % Bacteria that are not dispersed
            end        
        end 
end
%% Results
           reproduction = J(:,1:Nc,Nre,Ned);
           [jlastreproduction,O] = min(reproduction,[],2);  % min cost function for each bacterial 
           [Y,I] = min(jlastreproduction);
           pbest = B(:,I,O(I,:),k,l); 

🎉3 参考文献

部分理论来源于网络,如有侵权请联系删除。

🌈4 Matlab代码及文章阅读

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值