遗传算法matlab实现源程序(共12页).doc
《遗传算法matlab实现源程序(共12页).doc》由会员分享,可在线阅读,更多相关《遗传算法matlab实现源程序(共12页).doc(11页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、精选优质文档-倾情为你奉上clc;clear;%各份订单基本数据phen=1 2 3 4 5 6 7 8 9 10 11 12 13 1441,52,-23,-46,-143,-74,-56,101,73,74,95,86,-35,3265,23,-76,104,34,38,4,-23,55,-49,39,89,-86,527716,9887,12188,8819,4002,6119,3284,4607,5600,4587,9821,13024,6547,2684500,400,1000,120,0,235,654,241,0,361,120,254,300,1501,4,2,2,4,4,3,
2、3,3,1,4,5,1,32.7,1.8,4,2.5,1.6,1,3.6,5,4.2,1.9,6.4,2.8,1.4,8;hromlength=14;popsize=30;maxgen=500; pc=0.8;pm=0.04;for kem=1:popsizepopulation(kem,:)=randperm(hromlength);endpopulation;%评价目标函数值for uim=1:popsize vector=population(uim,:); obj(uim)=hanshu(hromlength,vector,phen);end%obj%min(obj)clear uim
3、;objmin=min(obj);for sequ=1:popsize if obj(sequ)=objmin opti=population(sequ,:); endendclear sequ;fmax=22000;%=for gen=1:maxgen%选择操作%将求最小值的函数转化为适应度函数for indivi=1:popsize obj1(indivi)=1/obj(indivi);endclear indivi;%适应度函数累加总合total=0;for indivi=1:popsize total=total+obj1(indivi);endclear indivi;%每条染色体被
4、选中的几率for indivi=1:popsize fitness1(indivi)=obj1(indivi)/total;endclear indivi;%各条染色体被选中的范围for indivi=1:popsize fitness(indivi)=0; for j=1:indivi fitness(indivi)=fitness(indivi)+fitness1(j); endendclear j;fitness;%选择适应度高的个体for ranseti=1:popsize ran=rand; while (ran1|ran0) ran=rand; end ran; if ranfit
5、ness(fet-1)&(ran=fitness(fet) newpopulation(ranseti,:)=population(fet,:); end end endendclear ran;newpopulation;%交叉for int=1:2:popsize-1 popmoth=newpopulation(int,:); popfath=newpopulation(int+1,:); popcross(int,:)=popmoth; popcross(int+1,:)=popfath; randnum=rand; if(randnum cpoint1=round(rand*hroml
6、ength); cpoint2=round(rand*hromlength); while (cpoint2=cpoint1) cpoint2=round(rand*hromlength); end if cpoint1cpoint2 tem=cpoint1; cpoint1=cpoint2; cpoint2=tem; end cpoint1; cpoint2; for term=cpoint1+1:cpoint2 for ss=1:hromlength if popcross(int,ss)=popfath(term) tem1=popcross(int,ss); popcross(int,
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 遗传 算法 matlab 实现 源程序 12
限制150内