教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 高等教育 >

附录2求解RDC的 MATLAB 编程源代码(2)

来源:网络收集 时间:2026-08-01
导读: if opts(2)==1 e1str=['(c1 c1(xZomeLength)]=' evalFN '(c1,[gen evalOps]);']; e2str=['(c2 c2(xZomeLength)]=' evalFN '(c2,[gen evalOps]);']; else e1str=('x=b2f(endPop(j,:),bounds,bits);[x v]='

if opts(2)==1 e1str=['(c1 c1(xZomeLength)]=' evalFN '(c1,[gen evalOps]);']; e2str=['(c2 c2(xZomeLength)]=' evalFN '(c2,[gen evalOps]);']; else e1str=('x=b2f(endPop(j,:),bounds,bits);[x v]=' evalFN… '(x,[gen evalOps]); endPop(j,:)=[f2b(x,bounds,bits) v];']; end end if n<6 termOps=[100]; termFN='maxGenTerm'; end if n<12 if opts(2)==1 mutFNs=['boundaryMutation multiNonUnifMutation nonUnifMutation unifMutation']; mutOps= [4 0 0;6 termOps(1) 3;4 termOps(1) 3;4 0 0]; else mutFNs=['binaryMutation']; mutOps=[0.05]; end end if n<10 if opts(2)==1 xOverFNs=['arithXover heuristicXover simpleXover']; xOverOps=[2 0;2 3;2 0]; else xOverFNs=['simpleXover']; xOverOps=[0.6]; end end if n<9 selectOps=[]; end if n<8 selectFN=['normGeomSelect']; selectOps=[0.08]; end if n<6 Tfault termination information termOps=[100]; termFN='maxGenTerm'; end if n<4n startPop=[];

end if isempty(startPop) startPop=initializega(80,bounds,evalFN,evalOps,opts(1:2)); end if opts(2)==0 bits=calcbits(bounds,opts(1)); end xOverFNs=parse(xOverFNs); mutFNs=parse(mutFNs); xZomeLength=size(startPop,2); numVar=xZomeLength-1; popSize=size(startPop,1); endPop=zeros(popSize,xZomeLength); c1=zeros(1,xZomeLength); c2=zeros(1,xZomeL.ength); numXOvers=size(xOverFNs,1); numMuts=size(mutFNs,1); epsilon=opts(1); oval=max(startPop(:,xZomeLength)); bFoundIn=1; done=0; gen=1; collectTrace=(nargout>3); floatGA=opts(2)==1; display=opts(3); while(~done) [bval,bindx]=max(startPop(:,xZomeLength)); best=startPop(bindx,:); if collectTrace traceInfo(gen,1)=gen; tracelnfo(gen,2)=startPop(bindx,xZomeLength); traceInfo(gen,3)=mean(startPop(:,xZomeLength)); traceInfo(gen,4)=std(startPop(:,xZomeLength)); end if((abs(bval-oval)>epsilon)|(gen==1)) if display fprintf(1,'\\n%d %f\\n',gen,bval); end if floatGA bPop(bFoundIn,:)=[gen startPop(bindx,:)]; else bPop(bFoundIn,:)=[gen b2f(startPop(bindx 1:numVar),bounds,bits)... startPop(bindx,xZomeLength)]; end

bFoundIn=bFoundIn+1; oval=bval; else if display fprintf(1,'%d',gen); end end endPop=feval(selectFN,startPop,[gen selectOps]); if floatGA for i=1:numXOvers, forj=1:xOverOps(i, 1), a=round(rand*(popSize-1)+1); b=round(rand*(popSize-1)+1); xN=deblank(xOverFNs(i,:)); [c1 c2]=feval(xN,endPop(a,:),endPop(b,:),bounds,[gen xOverOps(i,:)]); if c1(1:numVar)==endPop(a,(1:numUar)) c1(xZomeLength)=endPop(a,xZomeLength); elseif c1(1:numVar)==endPop(b,(1:numVar)) c1(xZomeLength)=endPop(b,xZomeLength); else eval(e1str); end if c2(1:numVar)==endPop(a,(1:numVar)) c2(xZomeLength)=endPop(a,xZomeLength); elseif c2(1:numVar)==endPop(b,(1:numVar)) c2(xZomeLength)=endPop(b,xZomeLength); else eval(e2str); end endPop(a,:)=c1; endPop(b,:)=c2; end end for i=1:numMuts, for j=1:mutOps(i,1), a=round(rand*(popSize-1)+1); c1=feval(deblank(mutFNs(i,:)),endPop(a,:),bounds,[gen mutOps(i,:)]); if c1(1:numVar)==endPop(a,(1:numVar)) c1(xZomeLength)=endPop(a,xZomeLength); else eval(e1str); end endPop(a,:)=c1; end

end else for i=1:numXOvers, xN=deblank(xOverFNs(i,:)); cp=find(rand(popSize,1)

…… 此处隐藏:392字,全部文档内容请下载后查看。喜欢就下载吧 ……
附录2求解RDC的 MATLAB 编程源代码(2).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/615407.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)