下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
%AntColonyOptimizationfortheClustering%Reference:Anantcolonyapproachforclustering%%Author:DuYi%%Copyright:
/
%%Data:31/03/06clc;clear;%N=number_of_test_sample;N=150;%n=number_of_attribute_of_test_sample;n=4;%K=number_of_cluster;K=3;%R=number_of_ants;R=10;%t_max=MaxIterations;t_max=1000;%X=test_sample_matrix;X=[3.05.03.01.00.25.03.05.03.05.03.07.02.34.01.05.02.03.51.03.02.24.01.03.04.11.02.84.01.33.05.01.76.06.03.03.04.01.23.04.01.25.03.03.01.93.05.81.8
3.05.02.03.02.25.02.03.26.01.83.06.42.03.03.05.01.93.05.22.03.05.11.8];%INITIALIZATION%pheromonetrailsc=10A-2;tau=ones(N,K)*c;%tau=[%0.0147560.0152740.009900;%0.0152740.0099000.014756;%0.0152740.0147560.009900;%0.0099000.0152740.014756;%0.0147560.0152740.009900;%0.0099000.0147560.015274;%0.0099000.0201310.009900;%0.0152740.0147560.009900;%];%probabilitythresholdqq=0.9;%evaporationraterho=0.1;%fitnessfunctionbest_solution_function_value=inf;t=1;while((t<=t_max))%SENDRANTSEACHWITHEMPTYSOLUTIONSTRING,S%solutionstring:everyantconstructionsolutionandfitnessfunctionsolution_string=zeros(R,N+1);%COMPUTERSOLUTIONfori=1:R%solution_string(1,1:N)=randint(1,N,[1,K]);r=rand(1,N);%constructsolutionSiusingpheromonetrailforg=1:Nifr(g)<qtau_max=max(tau(g,:));Cluster_number=find(tau(g,:)==tau_max);solution_string(i,g)=Cluster_number(1);%%%%%%%%%%%%%1--ielsesum_p=sum(tau(g,:));p=tau(g,:)/sum_p;foru=2:Kp(u)=p(u)+p(u-1);endrr=rand;%Cluster_number=K;fors=1:Kif(rr<=p(s))Cluster_number=s;solution_string(i,g)=Cluster_number;%%%%%%%%%%%%%1--ibreak;endendendend%computeweights(weight)ofalltestsamplesandclustercenters(cluster_center)weight=zeros(N,K);forh=1:NCluster_index=solution_string(i,h);%%%%%%%%%%%%%1--iweight(h,Cluster_index)=1;endcluster_center=zeros(K,n);forj=1:Kforv=1:nsum_wx=sum(weight(:,j).*X(:,v));sum_w=sum(weight(:,j));ifsum_w==0cluster_center(j,v)=0continue;elsecluster_center(j,v)=sum_wx/sum_w;endendend%computerclusteringmetricand%assignitasobjectivefunctionvalueFiofsolution,SiF=0;forj=1:Kforii=1:NTemp=0;ifsolution_string(i,ii)==j;%%%%%%%%%%%%%1--iforv=1:nTemp=((abs(X(ii,v)-cluster_center(j,v))).A2)+Temp;endTemp=sqrt(Temp);endF=(Temp)+F;endendsolution_string(i,end)=F;%%%%%%%%%%%%%1--iend%fori=1:R%selectbestLsolutionsoutofRsolutionsusingobjectivefunctionvalues%LOCALSEARCHPROCEDURES===========================%fitnesssortinascendingorder[fitness_ascend,solution_index]=sort(solution_string(:,end),1);solution_ascend=[solution_string(solution_index,1:end-1)fitness_ascend];%plsislocalsearchthresholdprobabilitypls=0.05;%performlocalsearchonLsolutionL=2;%localsearchproceduressolution_temp=zeros(L,N+1);k=1;while(k<=L)solution_temp(k,:)=solution_ascend(k,:);rp=rand(1,N);fori=1:Nifrp(i)<=plscurrent_cluster_number=setdiff([1:K],solution_temp(k,i));change_cluster=randint(1,1,current_cluster_number);solution_temp(k,i)=change_cluster;endend%computerweightsofalltestsamplesandclustercenterssolution_temp_weight=zeros(N,K);forh=1:Nsolution_temp_cluster_index=solution_temp(k,h);%%%%%%%%%%%%%1--ksolution_temp_weight(h,solution_temp_cluster_index)=1;endsolution_temp_cluster_center=zeros(K,n);forj=1:Kforv=1:nsolution_temp_sum_wx=sum(solution_temp_weight(:,j).*X(:,v));solution_temp_sum_w=sum(solution_temp_weight(:,j));ifsolution_temp_sum_w==0solution_temp_cluster_center(j,v)=0;continue;elsesolution_temp_cluster_center(j,v)=solution_temp_sum_wx/solution_temp_sum_w;endendend%computersolutiontempclusteringmetricand%assignitasobjectivefunctionvalueFtofsolution,Stsolution_temp_F=0;forj=1:Kforii=1:Nst_Temp=0;ifsolution_temp(k,ii)==j;%%%%%%%%%%%%%1--kforv=1:nst_Temp=((abs(X(ii,v)-solution_temp_cluster_center(j,v))).A2)+st_Temp;endst_Temp=sqrt(st_Temp);endsolution_temp_F=(st_Temp)+solution_temp_F;endendsolution_temp(k,end)=solution_temp_F;%%%%%%%%%%%%%1--k%ifFt<FlthenFl=FtandSl=Stifsolution_temp(k,end)<=solution_ascend(k,end)%%%%%%%%%%%%%1--ksolution_ascend(k,:)=solution_temp(k,:);%%%%%%%%%%%%%1--kendifsolution_ascend(k,end)<=best_solution_function_valuebest_solution=solution_ascend(k,:);endk=k+1;end%endwhile(localsearch)%UPDATEPHEROMONETRAILMATRIX=======================%UpdatepheromonetrailmatrixusingbestLsolution%fori=1:N%%forj=1:L%tau(i,best_solution(1,i))=(1-rho)*tau(i,best_solution(1,i))+rho/(sum(best_solution(1,end)));%%end%end%%t=t+1;%end%while(main)%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++tau_F=0;forj=1:Ltau_F=tau_F+solution_ascend(j,end);endfori=1:Ntau(i,best_solution(1,i))=(1-rh
溫馨提示
- 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)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 網(wǎng)絡(luò)游戲公司前臺接待總結(jié)
- 2025年全球及中國神經(jīng)外科分流器行業(yè)頭部企業(yè)市場占有率及排名調(diào)研報告
- 2025-2030全球草坪護(hù)理CRM軟件行業(yè)調(diào)研及趨勢分析報告
- 2025年全球及中國導(dǎo)向銷行業(yè)頭部企業(yè)市場占有率及排名調(diào)研報告
- 2025年全球及中國古董搬運(yùn)行業(yè)頭部企業(yè)市場占有率及排名調(diào)研報告
- 2025-2030全球雙膜儲氣罐行業(yè)調(diào)研及趨勢分析報告
- 2025-2030全球環(huán)保EPDM顆粒行業(yè)調(diào)研及趨勢分析報告
- 2025-2030全球壞死性筋膜炎藥品行業(yè)調(diào)研及趨勢分析報告
- 2025-2030全球車輛后備箱釋放電纜行業(yè)調(diào)研及趨勢分析報告
- 2025-2030全球光伏舟托行業(yè)調(diào)研及趨勢分析報告
- 第十一章《功和機(jī)械能》達(dá)標(biāo)測試卷(含答案)2024-2025學(xué)年度人教版物理八年級下冊
- 2025年銷售部年度工作計劃
- 2024年蘇州工業(yè)園區(qū)服務(wù)外包職業(yè)學(xué)院高職單招職業(yè)適應(yīng)性測試歷年參考題庫含答案解析
- ESG表現(xiàn)對企業(yè)財務(wù)績效的影響研究
- DB3713T 340-2024 實(shí)景三維數(shù)據(jù)接口及服務(wù)發(fā)布技術(shù)規(guī)范
- 八年級生物開學(xué)摸底考(長沙專用)(考試版)
- 車間空調(diào)崗位送風(fēng)方案
- 使用錯誤評估報告(可用性工程)模版
- 初一年級班主任上學(xué)期工作總結(jié)
- 2023-2024年同等學(xué)力經(jīng)濟(jì)學(xué)綜合真題及參考答案
- 農(nóng)村集體土地使用權(quán)轉(zhuǎn)讓協(xié)議
評論
0/150
提交評論