c/c++语言开发共享基于Matlab实现嗅觉优化算法的示例代码

1.概述嗅觉剂优化是一种新颖的优化算法,旨在模仿气味分子源尾随的药剂的智能行为。该概念分为三个阶段(嗅探,尾随和随机)是独特且易于实现的。此上传包含 sao 在 37 个 cec 基准测试函数上的实现

1.概述

嗅觉剂优化是一种新颖的优化算法,旨在模仿气味分子源尾随的药剂的智能行为。该概念分为三个阶段(嗅探,尾随和随机)是独特且易于实现的。此上传包含 sao 在 37 个 cec 基准测试函数上的实现。

基于Matlab实现嗅觉优化算法的示例代码

2.37 个 cec 基准测试函数代码

function [lb,ub,dim,fobj] = select_function(f)        switch f      case 'f1'          %admijan          fobj = @f1;          lb=[-1 -1];          ub=[2 1];          dim=2;        case 'f2'          %beale          fobj = @f2;          dim=2;          lb=-4.5*ones(1,dim);          ub=4.5*ones(1,dim);          case 'f3'         %bird          fobj = @f3;          dim=2;          lb=-2*pi*ones(1,dim);          ub=2*pi*ones(1,dim);                 case 'f4'         %bohachevsky          fobj = @f4;          dim=2;          lb=-100*ones(1,dim);          ub=100*ones(1,dim);      case 'f5'  %         booth          fobj = @f5;          dim=2;          lb=-10*ones(1,dim);          ub=10*ones(1,dim);      case 'f6'         %branin rcos1          fobj = @f6;          lb=[-5,0];          ub=[10, 15];          dim=2;      case 'f7'          %branin rcos2          fobj = @f7;          dim=2;          lb=-5*ones(1,dim);          ub=15*ones(1,dim);      case 'f8'          %brent           fobj = @f8;          dim=2;          lb=-10*ones(1,dim);          ub=10*ones(1,dim);       case 'f9'          %bukin f2           fobj = @f9;          dim=2;          lb=[-15 -3];          ub=[-5 3];        case 'f10'          %six-hump           fobj = @f10;          dim=2;          lb=-5*ones(1,dim);          ub=5*ones(1,dim);        case 'f11'          %chichinadze          fobj = @f11;          dim=2;          lb=-30*ones(1,dim);          ub=30*ones(1,dim);     case 'f12'          %deckkers-aarts          fobj = @f12;          dim =2;          lb=-20*ones(1,dim);          ub=20*ones(1,dim);      case 'f13'          %easom          dim=2;          fobj=@f13;          lb=-10*ones(1,dim);          ub=10*ones(1,dim);         case 'f14'          %matyas          fobj = @f14;          dim=2;          lb=-10*ones(1,dim);          ub=10*ones(1,dim);          case 'f15'          %mccomick          fobj = @f15;          dim=2;          lb=-10*ones(1,dim);          ub=10*ones(1,dim);               case 'f16'          %michalewicz2          fobj = @f16;          dim=2;          lb=0*ones(1,dim);          ub=pi*ones(1,dim);                case 'f17'          %quadratic          fobj = @f17;                  dim=2;          lb=-10*ones(1,dim);          ub=10*ones(1,dim);               case 'f18'          %schaffer          dim=2;          fobj = @f18;                          lb=-100*ones(1,dim);          ub=100*ones(1,dim);      case 'f19'          %styblinskitang          fobj = @f19;                          dim=2;          lb=-5*ones(1,dim);          ub=5*ones(1,dim);               case 'f20'          %box-betts          fobj = @f20;                                  dim=3;          lb=[0.9 9 0.9];          ub=[1.2 11.2 1.2];       case 'f21'          %colville          fobj = @f21;                                  dim=4;          lb=-1*ones(1,dim);          ub=1*ones(1,dim);                case 'f22'          %csendes          fobj = @f22;                                  dim=4;          lb=-1*ones(1,dim);          ub=1*ones(1,dim);               case 'f23'         %  michalewicz 5          fobj = @f23;                                  dim=5;          lb=0*ones(1,dim);          ub=pi*ones(1,dim);                case 'f24'          %miele cantrell          dim=4;          fobj = @f24;                                  lb=-1*ones(1,dim);          ub=1*ones(1,dim);      case 'f25'          % step          fobj = @f25;                                  dim=5;          lb=-100*ones(1,dim);          ub=100*ones(1,dim);      case 'f26'          %michalewicz          fobj = @f26;                                           dim=10;          lb=0*ones(1,dim);          ub=pi*ones(1,dim);          case 'f27'              %shubert          fobj = @f27;                                          dim=5;          lb=-10*ones(1,dim);          ub=10*ones(1,dim);              case 'f28'          %ackley          dim=30;          fobj = @f28;                                                  lb=-32*ones(1,dim);          ub=32*ones(1,dim);               case 'f29'          %brown          fobj = @f29;                                          dim=30;          lb=-1*ones(1,dim);          ub=4*ones(1,dim);              case 'f30'          %ellipsoid          dim=2;          fobj = @f30;                                                  lb=-5.12*ones(1,dim);          ub=5.12*ones(1,dim);                case 'f31'          % grienwank          fobj = @f31;                                                          dim=30;          lb=-100*ones(1,dim);          ub=100*ones(1,dim);       case 'f32'          %mishra          fobj = @f32;                                                          dim=30;          lb=0*ones(1,dim);          ub=1*ones(1,dim);       case 'f33'          %quartic          dim=30;          fobj = @f33;                                                                  lb=-1.28*ones(1,dim);          ub=1.28*ones(1,dim);      case 'f34'          %rastrigin          fobj = @f34;                                                          dim=30;          lb=-5.12*ones(1,dim);          ub=5.12*ones(1,dim);               case 'f35'          %rosenbrock          fobj = @f35;                                                                       dim=30;          lb=-30*ones(1,dim);          ub=30*ones(1,dim);         case 'f36'       %     salomon          fobj = @f36;                                                               dim=30;          lb=-100*ones(1,dim);          ub=100*ones(1,dim);      case 'f37'          %sphere          fobj = @f37;                                                               dim=30;          lb=-100*ones(1,dim);          ub=100*ones(1,dim);             end  end     function o=f1(x)  % adjiman   o=(cos(x(:,1)).*sin(x(:,2))-x(:,1)./(x(:,2).^2+1));     end  function o=f2(x)    %     beale     o=(1.5-x(:,1)+(x(:,1).*(x(:,2)))).^2+(2.25-x(:,1)+(x(:,1).*(x(:,2)).^2)).^2+...      (2.625-x(:,1)+(x(:,1).*(x(:,2)).^3)).^2;  end  function o=f3(x)      %     bird      o=sin(x(:,2)).*(exp(1-cos(x(:,1))).^2)+cos(x(:,1)).*(exp(1-sin(x(:,2))).^2)...      +(x(:,1)+(x(:,2))).^2;  end     function o=f4(x)      %     bohachevsky      w=0;      [a,dim]=size(x);      for i=1:dim-1          w=w+x(:,i).^2+2.*x(:,i+1).^2-0.3.*cos(3.*pi.*x(:,i+1))-0.4.*cos(4.*pi.*(x(:,i+1)))+0.7;      end      o=w;  end     function o=f5(x)          %booth      o=(x(:,2)-(5.1*x(:,1).^2/(4*pi*2))+(5*x(:,1)/pi)-6).^2+...          10*(1-1/(8*pi)).*cos(x(:,1))+10;  end     function o=f6(x)      %     branin rcos 1      o=(x(:,2)-(5.1*x(:,1).^2/(4*pi*2))+(5*x(:,1)/pi)-6).^2+...          10*(1-1/(8*pi)).*cos(x(:,1))+10;  end     function o=f7(x)  %     branin rcos 2       a=1; b=5.1/(4*pi^2); c=5/pi; d=6; e=10; g=1/(8*pi);      f1=a*(x(:,2)-b*x(:,1).^2+c*x(:,1)-d).^2;      f2=e*(1-g)*cos(x(:,1)).*cos(x(:,2));      f3=log(x(:,1).^2+x(:,2)+1);      o=-1/(f1+f2+f3+e);  end  function o=f8(x)  %brent      o=(x(:,1)+10).^2+(x(:,1)+10).^2+exp(-x(:,1).^2-x(:,2).^2);  end  function o=f9(x)    %bukin f2  o=(abs(x(:,1)-0.01.*x(:,2).^2))+0.01.*abs(x(:,2)+10);  end  function o=f10(x)  %camel six hump      o=(4-2.1*x(:,1).^2+(x(:,1).^4)/3).*x(:,1).^2+x(:,1).*x(:,2)+...          (4*x(:,2).^2-4).*x(:,2).^2;    end  function o=f11(x)          %chichinadze      o=x(:,1).^2-12*x(:,1)+11+10*cos(pi*x(:,1)/2)+8*sin(5*pi*x(:,1)/2)-...          ((1/5)^0.5)*exp(-0.5*(x(:,2)-0.5).^2);  end     function o=f12(x)  %     deckkers-aarts      o=10^5*x(:,1).^2+x(:,2).^2-(x(:,1).^2+x(:,2).^2).^2+...          10^(-5)*(x(:,1).^2+x(:,2).^2).^4;    end  function o = f13(x)  % easom  o=-cos(x(:,1)).*cos(x(:,2)).*exp(-(x(:,1)-pi).^2-(x(:,2)-pi).^2);           end  function o=f14(x)      %     evaluate matyas      o=0.26*(x(:,1).^2+x(:,2).^2)-0.48*x(:,1).*x(:,2);  end  function o=f15(x)    %     mccormick  o=mccormick(x);%  end  function o=f16(x)      %  michalewicz2      [~,d]=size(x);      w=0;      for i=1:d          w=sin(x(:,1)).*sin(i*x(:,i).^2/pi).^2*d;      end      o=-w;  end    function o=f17(x)     %   quadratic      o=-3803.84-138.08*x(:,1)-232.92*x(:,2)+128.08*x(:,1).^2+203.64*x(:,2).^2+182.25*x(:,1).*x(:,2);    end  function o=f18(x)          %     evaluate schaffer          [~,d]=size(x);          w=0;          for i=1:d-1              w=w+((x(i).^2+x(i+1).^2).^.5).*(sin(50.*(x(i).^2+x(i+1).^2).^0.1)).^2;          end          o=w;  end      function o=f19(x)      %  styblinki's tang      [~,d]=size(x);        w=0;        for i=1:d            w=w+(x(:,i).^4-16.*x(:,i).^2+5.*x(:,i));        end        o=w.*0.5;      end      function o=f20(x)          % box-betts          [~,d]=size(x);      w=0;      for i=1:d          g=exp(-0.1.*(i+1)).*x(:,1)-exp(-0.1.*(i+1)).*x(:,2)-((exp(-0.1.*(i+1)))-exp(-(i+1)).*x(:,3));          w=w+g.^2;      end      o=w;      end          function o=f21(x)      %     colville      o=100*(x(:,1)-x(:,2).^2).^2+(1-x(:,1)).^2+90*(x(:,4)-x(:,3).^2).^2+...      (1-x(:,3)).^2+10.1*((x(:,2)-1).^2+(x(:,4)-1).^2)+...      19.8*(x(:,2)-1).*(x(:,4)-1);      end          function o=f22(x)          %     csendes          [~,d]=size(x);      aa=0;      for i=1:d          aa=aa+x(:,i).^6.*(2+sin(1/x(:,i)));      end      o=aa;      end          function o=f23(x)              % michalewicz 5              [~,d]=size(x);      w=0;      for i=1:d          w=sin(x(:,1)).*sin(i*x(:,i).^2/pi).^2*d;      end      o=-w;      end          function o=f24(x)   %miele cantrell      o=(exp(-x(:,1))-x(:,2)).^4+100*(x(:,2)-x(:,3)).^6+...          (tan(x(:,3)-x(:,4))).^4+x(:,1).^8;      end      function o=f25(x)          %     evaluate step          [~,d]=size(x);      w=0;      for i=1:d          w=w+(floor(x(:,i)+0.5)).^2;      end      o=w;      end            function o=f26(x)          %     evaluate michalewicz 10          [~,d]=size(x);          w=0;      for i=1:d          w=sin(x(:,1)).*sin(i*x(:,i).^2/pi).^2*d;      end      o=-w;      end      function o=f27(x)  %     shubert          [~,d]=size(x);          s1=0;          s2=0;          for i = 1:d               s1 = s1+i*cos((i+1)*x(1)+i);               s2 = s2+i*cos((i+1)*x(2)+i);          end          o = s1*s2;         end      % f28--ackley  function o = f28(x)  dim=size(x,2);  o=-20*exp(-.2*sqrt(sum(x.^2)/dim))-exp(sum(cos(2*pi.*x))/dim)+20+exp(1);  end          function o=f29(x)      [~,d]=size(x);      %     brown      a=0;      for i=1:d-1          a=(x(:,i).^2).^(x(:,i+1)+1)+(x(:,i+1).^2).^(x(:,i).^2+1);      end      o=a;      end          function o=f30(x)              %     ellipsoid       [~,d]=size(x);          w=0;          for i=1:d              w=w+i.*x(:,1).^2;          end          o=w;      end          %grienwank      function o=f31(x)      o=griewank(x);      end      function o=f32(x)          %      mishra          [~,d]=size(x);      a=0;      for i=1:d-1          a=a+x(:,i);      end      aa=d-a;      b=0;      for j=1:d-1          b=b+x(:,j);      end      w=abs((1+d-b).^aa);      o=w;         end      % --quartic  function o = f33(x)  dim=size(x,2);  o=sum([1:dim].*(x.^4))+rand;  end      %rastrigin      function o=f34(x)      o=rastrigin(x);       end  % rosenbrock  function o = f35(x)  dim=size(x,2);  o=sum(100*(x(2:dim)-(x(1:dim-1).^2)).^2+(x(1:dim-1)-1).^2);  end      function o=f36(x)  %     salomon      x2 = x.^2;      sumx2 = sum(x2, 2);      sqrtsx2 = sqrt(sumx2);      o = 1 - cos(2 .* pi .* sqrtsx2) + (0.1 * sqrtsx2);      end  function o = f37(x)  %sphere  o=sum(x.^2);  end              function o=ufun(x,a,k,m)  o=k.*((x-a).^m).*(x>a)+k.*((-x-a).^m).*(x<(-a));  end

3.f1 matlab代码仿真

基于Matlab实现嗅觉优化算法的示例代码

基于Matlab实现嗅觉优化算法的示例代码

到此这篇关于基于matlab实现嗅觉优化算法的示例代码的文章就介绍到这了,更多相关matlab嗅觉优化算法内容请搜索<计算机技术网(www.ctvol.com)!!>以前的文章或继续浏览下面的相关文章希望大家以后多多支持<计算机技术网(www.ctvol.com)!!>!

需要了解更多c/c++开发分享基于Matlab实现嗅觉优化算法的示例代码,都可以关注C/C++技术分享栏目—计算机技术网(www.ctvol.com)!

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/c-cdevelopment/1247351.html

(0)
上一篇 2022年9月27日
下一篇 2022年9月27日

精彩推荐