Home > Mateda2.0 > replacement > elitism.m

# elitism

## PURPOSE

[NewPop,NewFunVal] = elistism(Pop,SelPop,SampledPop,FunVal,SelFunVal,SampledFunVal,replacement_params)

## SYNOPSIS

function [NewPop,NewFunVal] = elistism(Pop,SelPop,SampledPop,FunVal,SelFunVal,SampledFunVal,replacement_params)

## DESCRIPTION

     [NewPop,NewFunVal] =  elistism(Pop,SelPop,SampledPop,FunVal,SelFunVal,SampledFunVal,replacement_params)
     elitism:                  Creates a new population (NewPop) with the k best
                               individuals of Pop and the (PopSize-k) best individuals from SampledPop
     INPUTS
     Pop:                                 Current population
     SelPop:                              Current selected population
     SampledPop:                          Population sampled from the probabilistic model
     CurrentFunVal:                       A matrix of function evaluations, one vector of m objectives for each individual
     replacement__params{1} = k:          Number of elistist solutions
     replacement__params{2} = find_bestids_method:   Name of the procedure for selecting the k best individuals
                                                     from a population (by default is 'fitness_ordering'
     OUTPUTS
     NewPop                        : New Population
     NewFunVal                     : Evaluations of the new population

     Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

## SOURCE CODE

    0001 function [NewPop,NewFunVal] = elistism(Pop,SelPop,SampledPop,FunVal,SelFunVal,SampledFunVal,replacement_params)
    0002 % [NewPop,NewFunVal] =  elistism(Pop,SelPop,SampledPop,FunVal,SelFunVal,SampledFunVal,replacement_params)
    0003 % elitism:                  Creates a new population (NewPop) with the k best
    0004 %                           individuals of Pop and the (PopSize-k) best individuals from SampledPop
    0005 % INPUTS
    0006 % Pop:                                 Current population
    0007 % SelPop:                              Current selected population
    0008 % SampledPop:                          Population sampled from the probabilistic model
    0009 % CurrentFunVal:                       A matrix of function evaluations, one vector of m objectives for each individual
    0010 % replacement__params{1} = k:          Number of elistist solutions
    0011 % replacement__params{2} = find_bestids_method:   Name of the procedure for selecting the k best individuals
    0012 %                                                 from a population (by default is 'fitness_ordering'
    0013 % OUTPUTS
    0014 % NewPop                        : New Population
    0015 % NewFunVal                     : Evaluations of the new population
    0016 %
    0017 % Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)
    0018
    0019
    0020 PopSize = size(Pop,1);
    0021 SelPopSize = size(SelPop,1);
    0022 SampledPopSize = size(SampledPop,1);
    0023
    0024
    0025 k = cell2num(replacement_params{1}(1));
    0026 find_bestinds_method = char(cellstr(replacement_params{1}(2)));
    0027
    0028 [Ind]  = eval([find_bestinds_method,'(Pop,FunVal)']);  %The k  best individuals are taken from Pop
    0029 Ind = Ind(1:k);
    0030 NewPop(1:k,:) = Pop(Ind,:);
    0031 NewFunVal(1:k,:) = FunVal(Ind,:);
    0032
    0033 [Ind]  = eval([find_bestinds_method,'(SampledPop,SampledFunVal)']); %The PopSize - k best individuals are taken from SampledPop
    0034 Ind = Ind(1:PopSize-k);
    0035 NewPop(k+1:PopSize,:) = SampledPop(Ind,:);
    0036 NewFunVal(k+1:PopSize,:) = SampledFunVal(Ind,:);
    0037
    0038
    0039 return
    0040
    0041
    0042