elitistreplacement.m
来自「This matlab code on reed solomon and BCH」· M 代码 · 共 41 行
M
41 行
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% File: ElitistReplacement.m
%
% Description: Perform Lambda+Mu elitist replacement. Combine parent and
% offspring population and choose the best n individuals
%
% @param population is the parent population
%
% @param fitness is the fitness of parent individuals
%
% @param newPopulation is the offspring population
%
% @param newFitness is the fitness of offspring individuals
%
% @return bestPopulation is the top n individuals from the combined
% population of parent and offspring individuals.
%
% @return bestFitness is the fitness of the top n individuals from the
% combined population of parent and offspring individuals.
%
% Author: Kumara Sastry
%
% Date: March 2007
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [bestPopulation, bestFitness] = elitistReplacement(population, fitness, newPopulation, newFitness)
% Determine the population size;
n = size(population,1);
% Combine the parent and offspring population and their fitness values
combinedPopulation = [population; newPopulation];
combinedFitness = [fitness; newFitness];
% Sort the combined fitness vector
[sortedFitness, index] = sort(combinedFitness, 'descend');
% Select the top n individuals and their fitness.
bestPopulation = combinedPopulation(index(1:n),:);
bestFitness = combinedFitness(index(1:n));
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?