?? select-1.m
字號:
function s1=select(v0,f,population)
%輪盤賭選擇
matrixsum=sum(f);
roulette=cumsum(f);%求向量累加
choiseP=roulette/matrixsum;%得選擇概率
for i=1:population
tempP=rand(1);
if (tempP<choiseP(1))
selected(i,:)=v0(1,:);
else
for j=2:length(choiseP)
if ((tempP>=choiseP(j-1))&(tempP<=choiseP(j)))
selected(i,:)=v0(j,:);
break;
end
end
end
end
s1=selected;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -