⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 universalselect.sci

📁 基于SCILAB的The Genetic Algorithm Toolbox for SCILAB (GATS)工具箱
💻 SCI
字号:
function[newPop] = UniversalSelect(oldPop,options)
//roulette is the traditional selection function with the probability of
//surviving equal to the fittness of i / sum of the fittness of all individuals
//
//function[newPop] = roulette(oldPop,options)
//newPop  - the new population selected from the oldPop
//oldPop  - the current population
//options - options 

//Get the parameters of the population
numVars = size(oldPop,2);
numSols = size(oldPop,1);

//Generate the relative probabilites of selection
totalFit = sum(oldPop(:,numVars));
prob=oldPop(:,numVars) / totalFit; 
prob=cumsum(prob);

rNums=(rand(1) * ones(numSols,1) + (0:numSols-1)')/numSols; //Generate random numbers

//Select individuals from the oldPop to the new
fitIn=1;newIn=1;
while newIn<=numSols
  if(rNums(newIn)<prob(fitIn))
    newPop(newIn,:) = oldPop(fitIn,:);
    newIn = newIn+1;
  else
    fitIn = fitIn + 1;
  end
end

⌨️ 快捷键说明

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