%% GRADE creating of new population

ActualSize=SelectedSize+1;

%% MUTATE
for i = 1:SelectedSize
    p = rand;
    if p < radioactivity
        id = randsample(SelectedSize,1);
        mutation_rate = rand*mutation_rate_limit; 
        x = rand(Dim,1);
        for j = 1:Dim
            x(j) = x(j)*(Domain(j,2)-Domain(j,1))+Domain(j,1);
            CH(ActualSize,j) = CH(id,j)+mutation_rate*( x(j)-CH(id,j) ); 
        end
        ActualSize = ActualSize+1;
    end
end

monsters = ActualSize-1-SelectedSize;

%% CROSS
for i = ActualSize:PoolSize 
    i1 = randsample(SelectedSize,1); 
    i2 = randsample(SelectedSize-1,1)+1; 
    if i1==i2 
        i2 = i2-1;
        if i2 == 0 i2 = 2; end
    end
    cross_rate = rand*cross_limit; 
    if Force(i1)<Force(i2) i3 = i1; 
    else i3 = i2; end
    for j = 1:Dim 
        CH(i,j) = CH(i3,j)+cross_rate*( CH(i2,j)-CH(i1,j) ) ;
    end
end
%% author: Anicka Kucerova, Czech Technical University in Prague
%% version 0.0.2
%% 6 Feb 2009