roulette.m

来自「Real Genetic Algorithm RGA」· M 代码 · 共 19 行

M
19
字号

% -------------------- Roulette Wheel Function ----------------------

function[Selected_gen]=Roulette(N,Selection_rate,Population)

temp2(1)=Selection_rate(1);
for i=2:N
    temp2(i)=temp2(i-1)+Selection_rate(i);
end
for i=1:N
    ran3=rand;
    for j=1:N
        if ran3<=temp2(j)
            Selected_gen(i,:)=Population(j,:);
            break
        end
    end
end
  

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?