📄 truncationselection.m
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% File: truncationSelection.m
%
% Description: Perform truncation selection and return the mating pool
% (index of selected individuals)
%
% @param truncParam is the selection pressure parameter
%
% @return winners is an array with the index of the individuals that won
% the tournaments.
%
% Author: Kumara Sastry
%
% Date: March 2007
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function winners = truncationSelection(truncParam, fitness)
n = length(fitness);
numWinners = floor(n*truncParam);
numCopies = ceil(1/truncParam);
[sortedFitness, index] = sort(fitness,'descend');
potentialWinners = repmat(index(1:numWinners),numCopies,1);
winners = potentialWinners(1:n);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -