資源簡介
實現了自適應差分進化(SaDE)算法,其中的參數(CR,F)由種群自適應生成,提供了靈活的適宜度函數接口,可供實現復雜的優化問題求解。
代碼片段和文件信息
function?[?besttrmeanttroptindbestvalPopCRtp]?=?SADE(?vminvmaxitermaxNpfitarguin)
%DE?Summary?of?this?function?goes?here
%???Detailed?explanation?goes?here
%%?initialization
[ab]?=?size(vmin);
????if(a>b)
???????vmin?=?vmin‘;
????end
????vmin?=?repmat(vminNp1);
????vmax?=?repmat(vmaxNp1);
????besttr?=?zeros(itermax1);
???meanttr?=?besttr;
???Pop?=?vmin?+(vmax-vmin).*rand(size(vmin));
???V??=?Pop;
????popfit?=?double?(fit(Poparguin));
????[~minInd]??=?min(popfit);
????F?=?zeros(size(Pop1)1);
????M?=?F;
????p??=0.5;
???CRm??=0.5;
????CR??=?0.5??+?0.1?*randn(size(F))?;
????ns1?=0;
????ns2=0;
????nf1?=?0;
????nf2?=0;
????CRs?=[];
????CRt=[];
????weight?=?[];
%?ssss
?%%?iteration
????for?t?=1:itermax
????????????%%?mutate
????????????????for?i??=?1:Np
????????????????????F?=?0.5?+?0.3?.*randn(size(F));
????????????????????F(F?>?1)?=1;
????????????????????F(F<0.1)?=?0.1;
????????????????????if(rand??????????????????????????????%?best/2/bin
??????????????????????????????ind?=?randsample(Np4);
??????????????????????????????V(i:)?=?Pop(minInd:)?+?F(i).*(Pop(ind(1):)?-?Pop(ind(2):))?+?F(i).*(Pop(ind(3):)?-?Pop(ind(4):))?;
??????????????????????????????M(i)??=1;
????????????????????else
????????????????????????????%rand/1/bin
????????????????????????????????????ind?=?randsample(Np3);
????????????????????????????????????V(i:)?=?Pop(ind(1):)?+?F(i).*(Pop(ind(2):)?-?Pop(ind(3):));
????????????????????????????M(i)?=2;
????????????????????end
???????????????????
????????????????end
???????????????%%?crossover
?????????????
??
??????????????
????????????????%%?copy
????????????????R?=?rand(size(Pop));
????????????????T?=?Pop;
????????????????
??
???????????????
????????????
??????????????
?????????????????
????????????????%%?crossover
????????????????R=?rand(size(T));
????????????????CRcurr?=?repmat(CR(:)1size(Pop2));
????????????????T(R? ???????
????????????????T(:end)?=?V(:end);
????????????????????%%?check?boundary
????????????????R=?rand(size(T));
????????????????if(sum(sum(T0)
????????????????T(T?????????????????end
????????????????if?(sum(sum(T>vmax))?>0)
????????????????T(T?>?vmax)??=??vmin(T?>?vmax)?+?R(T?>?vma
評論
共有 條評論