function sidps(regulator_parameters, compare_parameters,system,apriori)
compare_parameters.student=tinv((1-compare_parameters.alpha)^(1/(regulator_parameters.num_of_candidates-1)),regulator_parameters.num_of_candidates-1);
compare_parameters.rinott=4;
regulator_parameters.dim=sum(regulator_parameters.H_tilde_on(:));

[H_tilde C]=init_hyperstate(regulator_parameters,apriori);  %vytvori H_tilde a mi, nastavi H0 a mi*

    for j=1:regulator_parameters.n_iter
        j
        regulator_parameters.search_region=regulator_parameters.gama^(j-1)*regulator_parameters.search_region_init;      
        
        %prolez mrizku a iteruj rizeni
        for k=1:regulator_parameters.n_grid^regulator_parameters.dim
            H0=add_H_tilde0(regulator_parameters,H_tilde,k);
            
            u=C(k);
            candidates=generate_candidates(u, regulator_parameters);
            C(k)=choose_best_control(H_tilde,C,H0,k,apriori,regulator_parameters,candidates,compare_parameters,system);
            
        end
                
        vypis=H_tilde;
        save 'H_tilde.txt' vypis -ASCII;
        save 'C.txt' C -ASCII;
        plot(H_tilde,C); hold on
    end

end

