遺傳算法matlab實(shí)現(xiàn)源程序

遺傳算法matlab實(shí)現(xiàn)源程序

ID:21653779

大?。?3.50 KB

頁數(shù):10頁

時(shí)間:2018-10-23

遺傳算法matlab實(shí)現(xiàn)源程序_第1頁
遺傳算法matlab實(shí)現(xiàn)源程序_第2頁
遺傳算法matlab實(shí)現(xiàn)源程序_第3頁
遺傳算法matlab實(shí)現(xiàn)源程序_第4頁
遺傳算法matlab實(shí)現(xiàn)源程序_第5頁
資源描述:

《遺傳算法matlab實(shí)現(xiàn)源程序》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫

1、附頁:一.遺傳算法源程序:clc;clear;population;%評(píng)價(jià)目標(biāo)函數(shù)值foruim=1:popsize???vector=population(uim,:);???obj(uim)=hanshu(hromlength,vector,phen);end%obj%min(obj)clearuim;objmin=min(obj);forsequ=1:popsize???ifobj(sequ)==objmin???????opti=population(sequ,:);???endendclearsequ;fmax=22000;%==forgen=1:maxg

2、en%選擇操作%將求最小值的函數(shù)轉(zhuǎn)化為適應(yīng)度函數(shù)forindivi=1:popsize???obj1(indivi)=1/obj(indivi);endclearindivi;%適應(yīng)度函數(shù)累加總合total=0;forindivi=1:popsize???total=total+obj1(indivi);endclearindivi;%每條染色體被選中的幾率forindivi=1:popsize???fitness1(indivi)=obj1(indivi)/total;endclearindivi;%各條染色體被選中的范圍forindivi=1:popsize??

3、?fitness(indivi)=0;???forj=1:indivi???????fitness(indivi)=fitness(indivi)+fitness1(j);???endendclearj;fitness;%選擇適應(yīng)度高的個(gè)體forranseti=1:popsize???ran=rand;???while(ran>1

4、

5、ran<0)???????ran=rand;???end???ran;???ifran<=fitness(1)???????newpopulation(ranseti,:)=population(1,:);???else???????f

6、orfet=2:popsize???????????if(ran>fitness(fet-1))&&(ran<=fitness(fet))???????????????newpopulation(ranseti,:)=population(fet,:);???????????end???????end???endendclearran;newpopulation;%交叉forint=1:2:popsize-1???popmoth=newpopulation(int,:);????????????????????????popfath=newpopulation(in

7、t+1,:);????????????????????popcross(int,:)=popmoth;???popcross(int+1,:)=popfath;???randnum=rand;???if(randnum

???????cpoint1=round(rand*hromlength);????????????????cpoint2=round(rand*hromlength);??????????????????while(cpoint2==cpoint1)????????????????????????????cpoint2=round(rand*h

8、romlength);???????end???????ifcpoint1>cpoint2????????????????????????????????tem=cpoint1;???????????cpoint1=cpoint2;???????????cpoint2=tem;???????end???????cpoint1;???????cpoint2;???????forterm=cpoint1+1:cpoint2??????????????????????????????forss=1:hromlength???????????????ifpopcross(i

9、nt,ss)==popfath(term)???????????????????tem1=popcross(int,ss);???????????????????popcross(int,ss)=popcross(int,term);???????????????????popcross(int,term)=tem1;???????????????end???????????end???????????cleartem1;???????end???????forterm=cpoint1+1:cpoint2?????????????????????????????

當(dāng)前文檔最多預(yù)覽五頁,下載文檔查看全文

此文檔下載收益歸作者所有

當(dāng)前文檔最多預(yù)覽五頁,下載文檔查看全文
溫馨提示:
1. 部分包含數(shù)學(xué)公式或PPT動(dòng)畫的文件,查看預(yù)覽時(shí)可能會(huì)顯示錯(cuò)亂或異常,文件下載后無此問題,請(qǐng)放心下載。
2. 本文檔由用戶上傳,版權(quán)歸屬用戶,天天文庫負(fù)責(zé)整理代發(fā)布。如果您對(duì)本文檔版權(quán)有爭議請(qǐng)及時(shí)聯(lián)系客服。
3. 下載前請(qǐng)仔細(xì)閱讀文檔內(nèi)容,確認(rèn)文檔內(nèi)容符合您的需求后進(jìn)行下載,若出現(xiàn)內(nèi)容與標(biāo)題不符可向本站投訴處理。
4. 下載文檔時(shí)可能由于網(wǎng)絡(luò)波動(dòng)等原因無法下載或下載錯(cuò)誤,付費(fèi)完成后未能成功下載的用戶請(qǐng)聯(lián)系客服處理。