function candidates=generate_candidates(best_control, search_region, num_of_candidates,mode)
%OK
%vraci sloupec kandidatu na rizeni
switch mode
    case (0)    %nahodne rozlozeni kandidatu
        candidates=best_control*ones(num_of_candidates-1,1)+(2*rand(num_of_candidates-1,1)-ones(num_of_candidates-1,1))*search_region;
        candidates(num_of_candidates)=best_control;
    case (1)    %linearni rozlozeni kandidatu
        if (mod(num_of_candidates,2)==0)
            pom=((-((num_of_candidates-2)/2)):((num_of_candidates-2)/2))/((num_of_candidates-2)/2);
            candidates=best_control*ones(num_of_candidates-1,1)+pom'*search_region;
            candidates(num_of_candidates)=best_control+(2*rand-1)*search_region;
        else
            pom=((-((num_of_candidates-1)/2)):((num_of_candidates-1)/2))/((num_of_candidates-1)/2);
            candidates=best_control*ones(num_of_candidates,1)+pom'*search_region;
        end     
end
end
