資源簡介
粒子群算法matlab仿真,幫助研究生學姐的畢設寫的
代碼片段和文件信息
function?[fv_GloBestIndv]?=?PSO(nmVMPMtimeIndvNum)%求最小值
%計算各粒子適應度值并尋找GloBestIndv
format?long;
w=1;c1=2;c2=2;
GloBestIndv?=?zeros(timem);
for?i=1:IndvNum
????while(1)
????????[x(i:)v(i:)]?=?Init(nm);
????????for?j=1:m????????????????????????????????%?阻止x?v逸出
????????????while?(x(ij)<1||x(ij)>n)???
????????????????x(ij)=round(rand(11)*(n-1))+1;
????????????end
????????end
????????if?(judge(nmVMPMx(i:)))?break;???????%確定虛擬機能放入物理機中
????????end
????end?????????????????????????????
????
????PerBestIndv(i:)?=?x(i:);
????y(i:)?=?x(i:);
end
GloBestIndv(1:)?=?x(1:);
for?i=2:IndvNum
????if?fitness(nmVMPMx(i:)) ????????GloBestIndv(1:)?=?x(i:);
????end
end
for?t=2:time?
????for?i=1:IndvNum
????????%v(i:)?=?v(i:)+(PerBestIndv(i:)-x(i:))*rand()+(GloBestIndv-x(i:))*rand();
????????v(i:)=w*v(i:)+c1*rand*(PerBestIndv(i:)-x(i:))+c2*rand*(GloBestIndv(t-1:)-x(i:));
??
- 上一篇:圖像中提取圓環的matlab代碼
- 下一篇:粒子群優化的極限學習機matlab源代碼
評論
共有 條評論