• 大小: 1KB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2021-07-13
  • 语言: Matlab
  • 标签: 蛙跳算法  

资源简介

蛙跳算法 MATLAB程序 用MATLAB编写的基本蛙跳算法

资源截图

代码片段和文件信息

clc;clear all;
m=50 %种群分组数
n=35; %t每组青蛙包含的个数
Ne=25; %组内迭代数
smax = 100;  %最大步长
MAXGEN=100;  %种群总进化代数
d=25; %优化问题维数
pmax =1024; %d维最大值
pmin = -1024;%d维最小值


%%产生初始青娃
F=m*n;
tic;
for i1=1:F
    p(i1:)=pmax*rands(1d);
end
%%全局迭代寻优
yy=zeros(1MAXGEN);
for ii=1:MAXGEN    
    for i2=1:F
        fitness(i2)=fun(p(i2:));
    end
    %排序,找最好的,并分组
    [fitsortindex]=sort(fitness);
    for i3=1:F
        x(i3:)=p(index(i3):);
    end
    gx=x(1:);%种群内最好的青娃
    yy(ii)=fitsort(1);
    % yy(ii)=fun(x(1:));
  %   local=zeros(nd);
    for i4=1:m 
      local = p(i4:m:end:);
        for j=1:Ne %每组青蛙迭代次数
            pb=local(1:);%组内最优
            pw=local(n:);%组内最差
            s1=rand.*(pb-pw);%采用组内最优更新
            s1(find(s1>smax))=smax;
            temp= pw+s1;
          temp(find(temp>pmax))=pmax;
           temp(find(temp           if fun(temp) > fun(pw)
               s1=rand.*(gx-pw);%采用全局最优更新
                s1(find(s1>smax))=smax;
               temp=pw+s1;
                 temp(find(temp>pmax))=pmax;
          temp(find(temp           end
           if fun(temp)>fun(pw)
            s1=pmax*rands(1d);%随机更新
             s1(find(s1>smax))=smax;
             temp=pw+s1;
             temp(find(temp>pmax))=pmax;
            temp(find(temp            end
             local(n:) = temp;
             for loc=1:n
             fitlocal(loc)=fun(local(loc:));
             end
             [localsortindexlocal]=sort(fitlocal);
             for loc=1:n
               localnew(loc:) = local(indexlocal(loc):);
              end    
             local=localnew;
        end   %结束Ne
             p(i4:m:end:) =local;
    end    %结束m
  %最好的青娃适配值 
end  %结束MAXGEN
toc
 %结果分析
 plot(yy)
 title(‘混合跬跳算法优化‘);
 xlabel(‘总进化代数‘);ylabel(‘函数最优解‘);








 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       2031  2010-01-06 12:57  蛙跳程序\FSFLA.m

     文件        232  2010-01-06 12:57  蛙跳程序\fun.m

     目录          0  2011-01-07 13:40  蛙跳程序

----------- ---------  ---------- -----  ----

                 2263                    3


评论

共有 条评论