已閱讀5頁(yè),還剩5頁(yè)未讀, 繼續(xù)免費(fèi)閱讀
版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
【自動(dòng)充值】百度文庫(kù)財(cái)富值充值 雙峰和多峰函數(shù)最大值的遺傳算法求解摘 要 本文利用基本遺傳算法的思路尋找雙峰或多峰函數(shù)的最大值,選擇采用輪盤(pán)選擇方法;交叉采用單點(diǎn)交叉,交叉位置隨機(jī),交叉概率取0.20;變異概率0.005。經(jīng)多次運(yùn)行,求得最大值。停止法則為循環(huán)最大遺傳代數(shù)為止到。的編程環(huán)境為Matlab6.5。關(guān)鍵字 遺傳算法 多峰函數(shù)遺傳算法是一種通用性非常強(qiáng),計(jì)算性能非常好的算法,解決類(lèi)似X.*sin(10*pi*X)+2.0這樣的多峰函數(shù)的最大值采用遺傳算法似乎是最好的算法。所以本問(wèn)題采用遺傳算法來(lái)解決,也是對(duì)遺傳算法編程的一次練習(xí)。函數(shù)Y=X.*sin(10*pi*X)+2.0 在-1 2區(qū)間上的圖像如下:Y=X.*sin(10*pi*X)+2.0 在-1 2區(qū)間上的圖像本程序最大遺傳代數(shù)為200,個(gè)體數(shù)目為50,采用二進(jìn)制編碼,基因長(zhǎng)度為30。運(yùn)算結(jié)果:best_Y =3.8503index =106X =1.8506各代最大值情況見(jiàn)下圖(藍(lán)點(diǎn)為第一代初始值,紅色三角為各代最大值)每一代計(jì)算過(guò)程如下表:Index各代Y最大值各代X值各代Y平均值1.00003.63781.64671.79822.00003.63781.64671.82533.00003.63771.64671.79934.00003.63771.64671.80835.00003.63771.64671.85906.00003.63931.64691.91937.00003.63931.64691.86098.00003.63921.64691.85309.00003.63921.64691.882910.00003.59871.83371.815511.00003.59871.83371.851812.00003.55141.83211.824613.00003.55141.83211.851014.00003.35701.46211.744015.00003.35701.46211.806616.00003.35701.46211.751517.00003.35701.46211.810718.00003.35701.46211.785719.00003.35701.46211.729720.00003.35701.46211.684321.00003.35661.46221.732722.00003.35661.46221.844023.00003.52081.83121.888824.00003.52081.83121.876925.00003.52111.83121.877826.00003.52111.83121.883927.00003.35831.46211.914328.00003.35831.46211.878329.00003.35741.46211.941630.00003.49931.63691.957531.00003.49931.63691.899732.00003.49931.63691.936133.00003.39991.45911.867534.00003.39841.45921.808435.00003.43181.63401.928736.00003.46291.63531.909937.00003.46291.63531.864638.00003.46301.63531.812639.00003.46301.63531.880740.00003.48041.66511.883841.00003.48041.66511.854642.00003.48041.66511.964543.00003.52381.66311.926844.00003.05731.88101.855745.00003.05731.88101.921346.00003.05731.88101.902047.00003.05711.88101.825248.00003.44751.44871.892649.00003.44841.44901.969850.00003.44841.44901.989751.00003.44841.44901.971452.00002.85030.85211.914553.00002.85030.85211.917054.00002.85791.22471.950155.00002.85030.85211.913456.00003.72481.86231.887257.00003.72481.86231.882058.00003.72421.86231.860959.00003.72421.86231.960960.00003.12411.87961.945761.00003.12411.87961.966362.00003.43531.44611.958663.00003.43561.44611.934564.00003.77121.85991.976665.00003.77731.85952.004766.00003.77731.85951.958767.00003.47481.87111.963168.00003.70911.83802.042769.00003.70901.83802.019970.00003.82741.84552.072071.00003.74381.83972.073872.00003.74301.83962.025573.00003.74381.83972.028874.00003.62731.86632.006375.00003.77601.85962.020476.00003.78501.85902.152377.00003.78501.85902.144478.00003.78501.85902.115879.00003.84291.84772.115780.00003.84291.84771.962381.00003.84291.84771.962082.00003.84301.84771.941683.00003.84301.84771.852784.00003.84301.84772.000585.00003.84301.84772.022686.00003.84301.84772.084687.00003.84301.84772.039988.00003.84271.84772.042489.00003.84271.84772.024790.00003.84291.85342.089891.00003.84291.85342.071592.00003.84291.85342.091693.00003.35251.87431.966994.00003.35251.87432.020695.00003.35251.87432.018396.00003.36501.87402.019197.00003.84041.85382.057898.00003.83911.85402.012099.00003.83911.85401.9769100.00003.83911.85402.0035101.00003.85021.85072.0710102.00003.85021.85072.0570103.00003.85021.85072.0683104.00003.85021.85072.0826105.00003.85021.85072.0440106.00003.85031.85062.0487107.00003.85031.85062.0244108.00003.85031.85062.0568109.00003.85031.85062.1176110.00003.85031.85062.0873111.00003.85031.85062.1207112.00003.85031.85062.0535113.00003.85031.85062.0841114.00003.85021.85032.1926115.00003.76371.84082.1121116.00003.76361.84082.0932117.00003.76361.84081.9732118.00003.76371.84081.9570119.00003.76361.84081.9336120.00003.76361.84081.9575121.00003.72801.83891.8549122.00003.72801.83891.9322123.00003.72801.83891.9030124.00003.72801.83891.9238125.00003.72801.83891.9764126.00003.72801.83892.0212127.00003.72821.83891.9752128.00003.72821.83891.9498129.00003.73301.83911.8933130.00003.73301.83911.8934131.00003.59331.83351.8165132.00003.59331.83351.8368133.00003.30531.82541.8050134.00003.24491.25381.7433135.00003.24491.25381.7819136.00002.84990.85251.7336137.00002.84990.85251.7512138.00002.84990.85251.7261139.00002.84990.85251.7688140.00003.25291.62801.8543141.00003.63191.65541.8755142.00003.63191.65541.8593143.00003.61441.65731.8239144.00003.62301.65641.8335145.00003.62301.65641.8621146.00003.62291.65641.8524147.00003.31861.67111.9152148.00003.19851.46961.9109149.00003.70831.86312.0110150.00003.70831.86311.9662151.00003.62671.86631.9461152.00003.62671.86632.0019153.00003.62671.86631.9808154.00003.62671.86631.9828155.00003.62671.86631.9835156.00003.65501.86531.9858157.00003.65501.86532.0047158.00003.65501.86532.0711159.00003.65321.86532.0025160.00003.65321.86532.0074161.00003.84661.84862.0899162.00003.84661.84862.0768163.00003.84661.84862.0675164.00003.84171.85362.0655165.00003.84171.85362.0244166.00003.49291.63661.9715167.00003.60631.65801.9138168.00003.44331.66671.9892169.00003.43811.66691.9848170.00003.43811.66691.9934171.00003.43811.66691.9868172.00003.79241.84262.0324173.00003.43791.66692.0047174.00003.43791.66692.0191175.00003.43791.66691.9246176.00003.43801.66691.9055177.00003.43801.66691.9284178.00003.60891.64352.0184179.00003.60901.64351.9541180.00003.84521.85291.9973181.00003.60931.64351.9780182.00003.60931.64351.9613183.00003.60961.64351.9650184.00003.35411.43901.9575185.00003.42771.45631.9087186.00003.15211.23811.9247187.00003.45031.45041.9454188.00002.89891.47921.9066189.00002.88221.61841.9284190.00003.42281.66751.9520191.00003.43051.66721.9905192.00003.43051.66721.9467193.00003.33651.87471.9122194.00003.16941.23931.8371195.00003.85031.85061.9073196.00003.81471.85681.9294197.00003.85011.85022.0429198.00003.81471.85681.9125199.00003.81521.85671.9703200.00003.81521.85672.0873201.00003.81821.85652.0715評(píng)價(jià):由于此程序?yàn)檠h(huán)完指定代數(shù)后才結(jié)束,并且算不是絕對(duì)收斂的,所以會(huì)出現(xiàn)后面的一些最大值反而比前面的小的情況,而且顯得沒(méi)有規(guī)律。此程序運(yùn)行時(shí)間很短,1秒左右,性能不錯(cuò)??梢暂敵鲆部煽闯龃顺绦蚴諗克俣葘?shí)際上有點(diǎn)快。雙峰函數(shù)不必討論了。本程序文件名為:SGA.m子函數(shù):bs2rv.m 二進(jìn)制轉(zhuǎn)換10進(jìn)制函數(shù)程序源代碼如下:function SGA()%簡(jiǎn)單遺傳算法程序解決多峰函數(shù)的最值問(wèn)題Maxgen=200; %最大遺傳代數(shù)NIND=50; %個(gè)體數(shù)目gen_len=30; %基因長(zhǎng)度FieldD=-1,2;%區(qū)域描述cross_probability=0.20;%交叉概率mutate_probability=0.005;%變異概率fun=variable.*sin(10*pi*variable)+2.0;%目標(biāo)函數(shù)%subplot(2,1,1);fplot(fun,FieldD);%畫(huà)出目標(biāo)函數(shù)曲線(xiàn)hold on%生成初始種群Chrom=round(rand(NIND,gen_len); %生成二維01數(shù)組Chrom_real=bs2rv(Chrom,FieldD) %二進(jìn)制轉(zhuǎn)換成十進(jìn)制數(shù)%計(jì)算目標(biāo)函數(shù)值Obj=Chrom_real.*sin(10*pi*Chrom_real)+2.0%繪制初始值點(diǎn)plot(Chrom_real,Obj,*);%繪制當(dāng)前最大值的點(diǎn)ma(1,3)=1;ma(1,2) index=max(Obj);ma(1,3)=Chrom_real(index);plot(ma(1,3),ma(1,2),);%種群平均值ma(1,4)=mean(Obj);%開(kāi)始遺傳計(jì)算for gen=1:Maxgen %計(jì)算適應(yīng)度 sumObj=sum(Obj);%所有個(gè)體的目標(biāo)函數(shù)值之和 fitness=Obj/sumObj;%每個(gè)個(gè)體的選擇概率 fitness2=fitness(1);%累計(jì)概率 %選擇 numof=length(fitness); %計(jì)算累計(jì)概率fitness2 for j=2:numof fitness2(j)=fitness(j)+fitness2(j-1);%計(jì)算累計(jì)概率 end %輪盤(pán)選擇 tempChrom=Chrom;%儲(chǔ)存一個(gè)原始的個(gè)體值 index=1; for k=1:NIND fo
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年度餐廳招牌設(shè)計(jì)制作合同范本3篇
- 2025年醫(yī)療器械注冊(cè)代理與質(zhì)量管理體系認(rèn)證合同4篇
- 2025年度體育賽事代理公司注銷(xiāo)服務(wù)協(xié)議4篇
- 2025版二手貨車(chē)交易合同范本3篇
- 2025年度城市綜合體地下空間物業(yè)服務(wù)合同4篇
- 武漢托管班2025年度教師招聘與教育咨詢(xún)服務(wù)合同3篇
- 2024版國(guó)際碳排放交易合同
- 2025版農(nóng)產(chǎn)品銷(xiāo)售合同范例(含保鮮物流)2篇
- 二零二五版苗圃技術(shù)員土壤改良與肥料施用合作協(xié)議4篇
- 2025版?zhèn)€人股權(quán)質(zhì)押協(xié)議(股權(quán)融資)3篇
- 小兒甲型流感護(hù)理查房
- 霧化吸入療法合理用藥專(zhuān)家共識(shí)(2024版)解讀
- 拆遷評(píng)估機(jī)構(gòu)選定方案
- 趣味知識(shí)問(wèn)答100道
- 鋼管豎向承載力表
- 2024年新北師大版八年級(jí)上冊(cè)物理全冊(cè)教學(xué)課件(新版教材)
- 人教版數(shù)學(xué)四年級(jí)下冊(cè)核心素養(yǎng)目標(biāo)全冊(cè)教學(xué)設(shè)計(jì)
- JJG 692-2010無(wú)創(chuàng)自動(dòng)測(cè)量血壓計(jì)
- 三年級(jí)下冊(cè)口算天天100題(A4打印版)
- CSSD職業(yè)暴露與防護(hù)
- 移動(dòng)商務(wù)內(nèi)容運(yùn)營(yíng)(吳洪貴)項(xiàng)目三 移動(dòng)商務(wù)運(yùn)營(yíng)內(nèi)容的策劃和生產(chǎn)
評(píng)論
0/150
提交評(píng)論