📄 sus.m
字号:
% SUS.M (Stochastic Universal Sampling)%% This function performs selection with STOCHASTIC UNIVERSAL SAMPLING.%% Syntax: NewChrIx = sus(FitnV, Nsel)%% Input parameters:% FitnV - Column vector containing the fitness values of the% individuals in the population.% Nsel - number of individuals to be selected%% Output parameters:% NewChrIx - column vector containing the indexes of the selected% individuals relative to the original population, shuffled.% The new population, ready for mating, can be obtained% by calculating OldChrom(NewChrIx,:).% Author: Hartmut Pohlheim (Carlos Fonseca)% History: 12.12.93 file created% 22.02.94 clean up, commentsfunction NewChrIx = sus(FitnV,Nsel);% Identify the population size (Nind) [Nind,ans] = size(FitnV);% Perform stochastic universal sampling cumfit = cumsum(FitnV); trials = cumfit(Nind) / Nsel * (rand + (0:Nsel-1)'); Mf = cumfit(:, ones(1, Nsel)); Mt = trials(:, ones(1, Nind))'; [NewChrIx, ans] = find(Mt < Mf & [ zeros(1, Nsel); Mf(1:Nind-1, :) ] <= Mt);% Shuffle new population [ans, shuf] = sort(rand(Nsel, 1)); NewChrIx = NewChrIx(shuf);% End of function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -