77范文网 - 专业文章范例文档资料分享平台

遗传算法Matlab源代码(7)

来源:网络收集 时间:2021-04-06 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

完整可以运行的数值优化遗传算法源代码

%NewPop(y1(i+2),xPoints(1):xPoints(2))=OldPop(y1(i+1),xPoints(1):xPoints(2));

temp=[OldPop(y1(i+1),xPoints(2)+1:n) OldPop(y1(i+1),1:xPoints(2))];

for del1i=xPoints(1):xPoints(2)

temp(find(temp==OldPop(y1(i+2),del1i)))=[];

end

NewPop(y1(i+1),(xPoints(2)+1):n)=temp(1:(n-xPoints(2)));

NewPop(y1(i+1),1:(xPoints(1)-1))=temp((n-xPoints(2)+1):end);

temp=[OldPop(y1(i+2),xPoints(2)+1:n) OldPop(y1(i+2),1:xPoints(2))];

for del2i=xPoints(1):xPoints(2)

temp(find(temp==OldPop(y1(i+1),del2i)))=[];

end

NewPop(y1(i+2),(xPoints(2)+1):n)=temp(1:(n-xPoints(2)));

NewPop(y1(i+2),1:(xPoints(1)-1))=temp((n-xPoints(2)+1):end);

end

end

end

NewPop(y2,:)=OldPop(y2,:);

% -二进制串均匀交叉算子

function [children1,children2]=EqualCrossOver(parent1,parent2)

global n children1 children2

hidecode=round(rand(1,n));%随机生成掩码

crossposition=find(hidecode==1);

holdposition=find(hidecode==0);

children1(crossposition)=parent1(crossposition);%掩码为1,父1为子1提供基因

children1(holdposition)=parent2(holdposition);%掩码为0,父2为子1提供基因

children2(crossposition)=parent2(crossposition);%掩码为1,父2为子2提供基因

children2(holdposition)=parent1(holdposition);%掩码为0,父1为子2提供基因

% -二进制串多点交叉算子

function [Children1,Children2]=MultiPointCross(Parent1,Parent2)%交叉点数由变量数决定

global n Children1 Children2 VarNum

Children1=Parent1;

Children2=Parent2;

Points=sort(unidrnd(n,1,2*VarNum));

for i=1:VarNum

Children1(Points(2*i-1):Points(2*i))=Parent2(Points(2*i-1):Points(2*i));

Children2(Points(2*i-1):Points(2*i))=Parent1(Points(2*i-1):Points(2*i));

end

% -- 变异操作 --

function [NewPop]=Mutation(OldPop,fit,pMutation,VarNum,opts)

global m n NewPop

NewPop=OldPop;

r=rand(1,m);

MutIn=find(r<=pMutation);

L=length(MutIn);

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库遗传算法Matlab源代码(7)在线全文阅读。

遗传算法Matlab源代码(7).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/jiaoyu/1213443.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: