function [populace] = repr (populace,kvalita,fcn_h,y)

[~,I] = sort(kvalita); %seradime jedince sestupne podle kvality a zachovame pouze lepsi polovinu jedincu
indexy = I(((size(I,1)+1)/2):end);
nova_pop = populace(indexy,:); 
pocet_jedincu=size(nova_pop,1);
%beta=rand(1);
for i = 1:2:size(populace,1)
    ind_1=randi([1,pocet_jedincu]); %nahodne vybiram dvojice jedincu ind_1 (P1) a ind_2 (P2), kter? se reprodukuj?
    ind_2=randi([1,pocet_jedincu]);
    beta=rand(1);
    while ind_1==ind_2
        ind_2=randi([1,pocet_jedincu]);
    end
    
%     O1 = (nova_pop(ind_1,:).*0.5)+(nova_pop(ind_2,:).*0.5);
%     O2 = (nova_pop(ind_1,:).*1.5)-(nova_pop(ind_2,:).*0.5);
     O1 = (nova_pop(ind_1,:).*beta)+(nova_pop(ind_2,:).*(1-beta));
     O2 = (nova_pop(ind_2,:).*beta)+(nova_pop(ind_1,:).*(1-beta));
     
    kval1= fcn_h(O1(1),O1(2),0:0.01:60);
    kvalita1 = -sum((y-kval1).^2)/(length(y));
    kval2 = fcn_h(O2(1),O2(2),0:0.01:60);
    kvalita2 = -sum((y-kval2).^2)/(length(y));

    
    [~,In] = sort([kvalita1,kvalita2]);
    potomci = [O1;O2];
    
    vysl_pop(i,:) = potomci(In(end),:); 
    vysl_pop(i+1,:) = potomci(In(2),:);
end

populace = vysl_pop;

end