【優(yōu)化算法】多目標水母搜索優(yōu)化算法(MOJS)【含Matlab源碼248期】_第1頁
【優(yōu)化算法】多目標水母搜索優(yōu)化算法(MOJS)【含Matlab源碼248期】_第2頁
【優(yōu)化算法】多目標水母搜索優(yōu)化算法(MOJS)【含Matlab源碼248期】_第3頁
【優(yōu)化算法】多目標水母搜索優(yōu)化算法(MOJS)【含Matlab源碼248期】_第4頁
【優(yōu)化算法】多目標水母搜索優(yōu)化算法(MOJS)【含Matlab源碼248期】_第5頁
已閱讀5頁,還剩6頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

【優(yōu)化算法】多?標?母搜索優(yōu)化算法(MOJS)【含Matlab源碼248期】?、獲取代碼?式獲取代碼?式1:完整代碼已上傳我的資源:獲取代碼?式2:通過訂閱紫極神光博客付費專欄,憑?付憑證,私信博主,可獲得此代碼。備注:訂閱紫極神光博客付費專欄,可免費獲得1份代碼(有效期為訂閱?起,三天內(nèi)有效);?、?母搜索優(yōu)化算法簡介這項研究發(fā)展了?個新的元啟發(fā)式算法,它是受?母在海洋中的?為啟發(fā),被稱為???母搜索(JS)優(yōu)化器。?母搜索?為的模擬包括它們跟隨洋流、它們在?母群中的運動(主動運動和被動運動)、在這些運動之間切換的時間控制機制,以及收斂到?母花的狀態(tài)。新算法在基準函數(shù)和優(yōu)化問題上得到了成功的測試。值得注意的是,JS只有兩個控制參數(shù),即群體規(guī)模和迭代數(shù)。因此,JS的使??常簡單,并且可能是解決優(yōu)化問題的?個優(yōu)秀的元啟發(fā)式算法。三、部分源代碼%%MainMOJSoptimizerfunctionARCH=MOJS(params,MultiObj)%ParametersNpNr=params.Np;=params.Nr;MaxIt=params.maxiter;ngrid=params.ngrid;fun=MultiObj.fun;nVar=MultiObj.nVar;var_min=MultiObj.var_min(:);var_max=MultiObj.var_max(:);it=1;%InitializationbyEq.25POS=initialchaos(7,Np,nVar,var_max',var_min');POS_fit=fun(POS);=POS;ELI_POSELI_POS_fit=POS_fit;DOMINATED=checkDomination(POS_fit);ARCH.pos=POS(~DOMINATED,:);ARCH.pos_fit=POS_fit(~DOMINATED,:);ARCH=updateGrid(ARCH,ngrid);display(['Iteration#0-Archivesize:'num2str(size(ARCH.pos,1))]);%%MainMOJSloopstopCondition=false;while~stopCondition%SelectleaderbyEq.16h=selectLeader(ARCH);%CalculatetimecontrolbyEq.15Ct=abs((1-it*((1)/MaxIt))*(2*rand-1));ifCt>=0.5Meanvl=mean(ELI_POS);fori=1:Np%ThenewpositionisdeterminedbyEq.19andEq.20POS(i,:)=ELI_POS(i,:)+Levy(nVar).*(ARCH.pos(h,:)-3*rand([1nVar]).*Meanvl);endelsefori=1:Npifrand<(1-Ct)%JellyfishfollowtypeB%DeterminethedirectionbyEq.24j=i;j=i;whilej==ij=randperm(Np,1);endStep=ELI_POS(i,:)-ELI_POS(j,:);ifdominates(ELI_POS_fit(j,:),ELI_POS_fit(i,:))Step=-Step;end%ThenewpositionisdeterminedbyEq.22POS(i,:)=ARCH.pos(h,:)+rand([1nVar]).*Step;else%JellyfishfollowtypeA%ThenewpositionisdeterminedbyEq.21POS(i,:)=ARCH.pos(h,:)+Levy(nVar).*(ELI_POS(i,:)-ARCH.pos(h,:));endendend%%Updatenewpositionbyopposition-basedjumpingusingEq.26ifrand<(it/MaxIt)[POS]=OPPOS(POS,var_max,var_min);end%%Checkboundariesifrand>=0.5POS=checksimplebounds(POS,var_min',var_max');elsePOS=checkBoundaries(POS,var_max,var_min);end%%EvaluatethepopulationPOS_fit=fun(POS);pos_best=dominates(POS_fit,ELI_POS_fit);best_pos=~dominates(ELI_POS_fit,POS_fit);best_pos(rand(Np,1)>=0.5)=0;if(sum(pos_best)>1)ELI_POS_fit(pos_best,:)=POS_fit(pos_best,:);ELI_POS(pos_best,:)=POS(pos_best,:);endif(sum(best_pos)>1)ELI_POS_fit(best_pos,:)=POS_fit(best_pos,:);ELI_POS(best_pos,:)=POS(best_pos,:);end%%Updatethearchiveifsize(ARCH.pos,1)==1ARCH.pos=POS;ARCH.pos_fit=POS_fit;ARCH=updateArchive(ARCH,ELI_POS,ELI_POS_fit,ngrid);elseARCH=updateArchive(ARCH,ELI_POS,ELI_POS_fit,ngrid);ifsize(ARCH.pos,1)==1ARCH.pos=ELI_POS;ARCH.pos_fit=ELI_POS_fit;endendif(size(ARCH.pos,1)>Nr)%DeletetheworstmembersfromarchivebyEq.18ARCH=deleteFromArchive(ARCH,size(ARCH.pos,1)-Nr,ngrid);enddisplay(['Iteration#'num2str(it)'-Archivesize:'num2str(size(ARCH.pos,1))]);it=it+1;if(it>MaxIt),stopCondition=true;endend%%Plottingparetofrontif(size(ARCH.pos_fit,2)==2)plot(ARCH.pos_fit(:,1),ARCH.pos_fit(:,2),'or');holdon;gridon;xlabel('f1');ylabel('f2');endif(size(ARCH.pos_fit,2)==3)if(size(ARCH.pos_fit,2)==3)plot3(ARCH.pos_fit(:,1),ARCH.pos_fit(:,2),ARCH.pos_fit(:,3),'or');holdon;gridon;xlabel('f1');ylabel('f2');zlabel('f3');endend%%Thisfunctioncalucatestheleaderperformancebyaroulettewheelselection%basedonthequalityofeachhypercubefunctionselected=selectLeader(ARCH)%Roulettewheelprob=cumsum(ARCH.quality(:,2));%Cumulatedprobssel_hyp=ARCH.quality(find(rand(1,1)*max(prob)<=prob,1,'first'),1);%Selectedhypercube%Selecttheindexleaderasarandomselectioninsidethathypercubeidx=1:1:length(ARCH.grid_idx);selected=idx(ARCH.grid_idx==sel_hyp);selected=selected(randi(length(selected)));end%%Thisfunctionreturns1ifxdominatesyand0otherwisefunctiond=dominates(x,y)d=all(x<=y,2)&any(x<y,2);end%%Thisfunctionchecksthedominationinsidethepopulation.functiondomi_vector=checkDomination(fitness)Np=size(fitness,1);ifNp>2domi_vector=zeros(Np,1);all_perm=nchoosek(1:Np,2);%Possiblepermutationsall_perm=[all_perm;[all_perm(:,2)all_perm(:,1)]];d=dominates(fitness(all_perm(:,1),:),fitness(all_perm(:,2),:));dominated_particles=unique(all_perm(d==1,2));domi_vector(dominated_particles)=1;elsedomi_vector=ones(Np,1);endend%%ThisfunctionupdatesthearchivegivenanewpopulationfunctionARCH=updateArchive(ARCH,POS,POS_fit,ngrid)%DominationbetweenjellyfishDOMINATED=checkDomination(POS_fit);ARCH.pos=[ARCH.pos;POS(~DOMINATED,:)];ARCH.pos_fit=[ARCH.pos_fit;POS_fit(~DOMINATED,:)];%DominationbetweennondominatedjellyfishandthelastarchiveDOMINATED=checkDomination(ARCH.pos_fit);ARCH.pos_fit=ARCH.pos_fit(~DOMINATED,:);ARCH.pos=ARCH.pos(~DOMINATED,:);%UpdatingthegridARCHend=updateGrid(ARCH,ngrid);%%Functionthatupdatesthehypercubegrid,thehypercubewherebelongsfunctionARCH=updateGrid(ARCH,ngrid)%Computingthehypercubelimitationndim=size(ARCH.pos_fit,2);ARCH.hypercube_limits=zeros(ngrid+1,ndim);fordim=1:1:ndimARCH.hypercube_limits(:,dim)=linspace(min(ARCH.pos_fit(:,dim)),max(ARCH.pos_fit(:,dim)),ngrid+1)';end%Computingwherebelongseachjellyfishnpar=size(ARCH.pos_fit,1);ARCH.grid_idx=zeros(npar,1);ARCH.grid_subidx=zeros(npar,ndim);forn=1:1:nparforn=1:1:nparidnames=[];ford=1:1:ndimARCH.grid_subidx(n,d)=find(ARCH.pos_fit(n,d)<=ARCH.hypercube_limits(:,d)',1,'first')-1;if(ARCH.grid_subidx(n,d)==0),ARCH.grid_subidx(n,d)=1;endidnames=[idnames','num2str(ARCH.grid_subidx(n,d))];endARCH.grid_idx(n)=eval(['sub2ind(ngrid.*ones(1,ndim)'idnames');']);end%QualitybasedonthenumberofjellyfishineachhypercubeARCH.quality=zeros(ngrid,2);ids=unique(ARCH.grid_idx);fori=1:length(ids)ARCH.quality(i,1)=ids(i);ARCH.quality(i,2)=10/sum(ARCH.grid_idx==ids(i));endend%%ThisfunctiondeletesanexcessofjellyfishinsidethearchiveusingcrowdingdistancesfunctionARCH=deleteFromArchive(ARCH,n_extra,ngrid)%Computethecrowdingdistancescrowding=zeros(size(ARCH.pos,1),1);form=1:1:size(ARCH.pos_fit,2)[m_fit,idx]=sort(ARCH.pos_fit(:,m),'ascend');m_up=[m_fit(2:end);Inf];m_down=[Inf;m_fit(1:end-1)];distance=(m_up-m_down)./(max(m_fit)-min(m_fit));[~,idx]=sort(idx,'ascend');crowding=crowding+distance(idx);endcrowding(isnan(crowding))=Inf;%Thisfunctiondeletestheextrajellyfishwiththesmallestcrowdingdistances[~,del_idx]=sort(crowding,'ascend');del_idx=del_idx(1:n_extra);ARCH.pos(del_idx,:)=[];ARCH.pos_fit(del_i

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論