声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1518|回复: 1

[编程技巧] 遗传算法的交叉算子——近亲抑制策略

[复制链接]
发表于 2011-10-19 19:35 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x

function newchrom=cross0(Chrom,FieldD)
    whole=fix(length(FieldD)/2);number=1;         %set mother and  the other is father which not select
    mather=[1:2:whole*2];
   if rem(length(FieldD),2)==0
         father=[length(FieldD):-2:2];
   else
         father=[length(FieldD)-1:-2:2];
   end
         % 选择母亲和父亲。。具体的换成二进制,再随机选取更好
   
     for Time=1:1:whole
         social(1,Time)=abs(Chrom(mather(Time))-Chrom(father(Time)));
     end     
      mean0=sum(social)/length(social);  %计算整个社会的近亲平均水平 setting as 0.75,最低变异为0.6 高于0.95的设置为0.95  
%越相似的个体,交叉的概率越低
      num=10*(mean0-min(social));
       p=social/num-ones(1,length(social))*min(social)/num+0.6;
      p(p>0.95)=0.95;
      for Time=1:1:length(social)
          if rand()<=p(Time)
              Chrom(mather(Time))=0.4* Chrom(mather(Time))+0.6*Chrom(father(Time));
              Chrom(father(Time))=0.6* Chrom(mather(Time))+0.4*Chrom(father(Time));
          end
      end
      newchrom=Chrom;
end
回复
分享到:

使用道具 举报

发表于 2011-10-23 16:17 | 显示全部楼层
本帖最后由 ChaChing 于 2011-10-23 16:26 编辑

回复 1 # 博大广阔 的帖子

原创 or 转贴 !? 个人专业有限, 看似像分享!? 是吗?
若是, 若能稍作简易说明下相关输入/输出/算法, 甚至举例, 或许更适合学习! 个人浅见
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-30 07:25 , Processed in 0.052115 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表