資源簡介
用matlab寫的dpso算法,適合教師做研究,學生寫論文

代碼片段和文件信息
function?current_Path=add_M(current_Pathadd_Edge)
%%?添加邊并調整函數
%%%%?current_Path為合法路徑,Path(city_nums1);
%%%%?add_Edge為待添加邊,edge(21);
%%%%?添加一條邊后,從左到右搜索Path獲取在Path中edge端點的位置jk且j %%%%?將Path中j到(k-1)或者j+1到k路徑點逆序
len=length(current_Path);
keyPosition=zeros(21);
j=1;
for?i=1:len
????if(current_Path(i1)==add_Edge(11)||current_Path(i1)==add_Edge(21))
????????keyPosition(j1)=i;
????????j=j+1;
????end
end
exchange_Len=keyPosition(21)-keyPosition(11);
if(exchange_Len~=1?&&?exchange_Len~=len-1)
????tempM=zeros(exchange_Len1);
????if(rand<0.5)
????????k=1;
????else
????????k=0;
????end
????for?i=1:exchange_Len
????????tempM(exchange_Len+1-i1)=current_Path(keyPosition(11)+k+i-11);
????end
????current_Path(keyPosition(11)+k:keyPosition(21)-1+k1)=tempM;
end
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????854??2013-04-13?20:28??DPSO\add_M.m
?????文件?????????66??2013-04-13?20:28??DPSO\and_M.m
?????文件????????220??2013-04-13?20:28??DPSO\calFitness.m
?????文件????????233??2013-04-13?20:28??DPSO\li
?????文件???????3316??2013-04-13?20:28??DPSO\main.m
?????文件????????325??2013-04-13?20:28??DPSO\pathPlot.m
?????文件????????261??2013-04-13?20:28??DPSO\PM2VM.m
?????文件????????129??2013-04-13?20:28??DPSO\sub_M.m
?????文件????????357??2013-04-13?20:28??DPSO\wGenerate.m
?????目錄??????????0??2013-04-13?20:28??DPSO
-----------?---------??----------?-----??----
?????????????????5761????????????????????10
- 上一篇:matlab輪廓波變換重采樣
- 下一篇:MATLAB程序initialize
評論
共有 條評論