資源簡介
精通matlab及最優化處理一書中第十四章遺傳優化算法的matlab源程序,包含原始的遺傳算法程序和六種改進程序,程序列表為

代碼片段和文件信息
function?[xvfv]=AdapGA(fitnessabNPNGPc1Pc2Pm1Pm2eps)
%自適應遺傳算法
L?=?ceil(log2((b-a)/eps+1));
x?=?zeros(NPL);
for?i=1:NP
????
????x(i:)?=?Initial(L);
????
????fx(i)?=?fitness(Dec(abx(i:)L));
????
end
for?k=1:NG
????
????sumfx?=?sum(fx);
????
????Px?=?fx/sumfx;
????PPx?=?0;
????
????PPx(1)?=?Px(1);
????
????for?i=2:NP
????????
????????PPx(i)?=?PPx(i-1)?+?Px(i);
????????
????end
????for?i=1:NP
????????
????????sita?=?rand();
????????
????????for?n=1:NP
????????????
????????????if?sita?<=?PPx(n)
????????????????
????????????????SelFather?=?n;
????????????????
????????????????break;
????????????????
????????????end
????????????
????????end
????????
????????Selmother?=?round(rand()*(NP-1))+1;
????????
????????posCut?=?round(rand()*(L-2))?+?1;
??????????
????????favg?=?sumfx/NP;
????????
????????fmax?=?max(fx);
????????
????????Fitness_f?=?fx(SelFather);
????????
????????Fitness_m?=?fx(Selmother);
????????
????????Fm?=?max(Fitness_fFitness_m);
????????
????????if?Fm>=favg
????????????
????????????Pc?=?Pc1*(fmax?-?Fm)/(fmax?-?favg);
????????????
????????else
????????????
????????????Pc?=?Pc2;
????????????
????????end
????????
????????r1?=?rand();
????????
????????if?r1<=Pc
????????????
????????????nx(i1:posCut)?=?x(SelFather1:posCut);
????????????
????????????nx(i(posCut+1):L)?=?x(Selmother(posCut+1):L);
????????????
????????????fmu?=?fitness(Dec(abnx(i:)L));
????????????if?fmu>=favg
????????????????Pm?=?Pm1*(fmax?-?fmu)/(fmax?-?favg);
????????????else
????????????????Pm?=?Pm2;
????????????end
????????????
????????????r2?=?rand();
????????????
????????????if?r2?<=?Pm
????????????????
????????????????posMut?=?round(rand()*(L-1)?+?1);
????????????????
????????????????nx(iposMut)?=?~nx(iposMut);
????????????????
????????????end
????????????
????????else
????????????
????????????nx(i:)?=?x(SelFather:);
????????????
????????end
????????
????end
????x?=?nx;
????
????for?i=1:NP
????????
????????fx(i)?=?fitness(Dec(abx(i:)L));
????????
????end
????
end
fv?=?-inf;
for?i=1:NP
????
????fitx?=?fitness(Dec(abx(i:)L));
????
????if?fitx?>?fv
????????
????????fv?=?fitx;
????????
????????xv?=?Dec(abx(i:)L);
????????
????end
????
end
function?result?=?Initial(length)
for?i=1:length??
????
????r?=?rand();
????
????result(i)?=?round(r);???
????
end
function?y?=?Dec(abxL)
base?=?2.^((L-1):-1:0);
y?=?dot(basex);
y?=?a?+?y*(b-a)/(2^L-1);
????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????2579??2008-09-10?21:32??第14章??遺傳優化算法\AdapGA.m
?????文件???????2380??2008-09-10?21:33??第14章??遺傳優化算法\DblGEGA.m
?????文件???????2889??2008-09-13?14:14??第14章??遺傳優化算法\GMGA.m
?????文件???????3344??2008-09-05?21:46??第14章??遺傳優化算法\MMAdapGA.m
?????文件???????2426??2008-09-13?13:08??第14章??遺傳優化算法\myGA.m
?????文件???????2070??2008-09-13?13:42??第14章??遺傳優化算法\NormFitGA.m
?????文件???????2571??2008-09-13?13:27??第14章??遺傳優化算法\SBOGA.m
?????目錄??????????0??2014-09-17?20:30??第14章??遺傳優化算法
-----------?---------??----------?-----??----
????????????????18259????????????????????8
- 上一篇:遺傳算法和粒子群算法結合的matlab源碼
- 下一篇:區域生長代碼matlab
評論
共有 條評論