root/applications/dual/SIDP/SIDPS/matlab/choose_best_control.m @ 1345

Revision 1185, 1.8 kB (checked in by zimamiro, 14 years ago)
Line 
1function best_control=choose_best_control(H,C,index,apriori,horizont,candidates,compare_parameters)
2num_of_candidates=size(candidates,1);
3n_0=compare_parameters.n0;
4realization1=zeros(num_of_candidates,n_0);
5
6%generovani eralizaci ztrat
7for i=1:num_of_candidates
8    C(index)=candidates(i);
9    for j=1:n_0
10        realization1(i,j)=generate_realization(apriori,index,H,C,horizont);
11    end
12end
13mean_values=mean(realization1,2);
14
15%RSSS
16if (compare_parameters.RSSS)
17    h=compare_parameters.rinott;
18    t=compare_parameters.student;
19    variances=sum((realization1-mean_values*ones(1,n_0)).^2,2)/(n_0-1);
20    W=t*sqrt((variances*ones(1,num_of_candidates)+ones(num_of_candidates,1)*variances')/n_0);
21
22    pass=ones(num_of_candidates,1); %pass(i)=1 => i-ty kandidat jde do 2 faze
23    for i=1:size(candidates)
24        for j=1:size(candidates)
25            if (mean_values(i)>mean_values(j)+max(0,W(i,j)-compare_parameters.delta)) %hledam minimum
26                pass(i)=false;
27                break;
28            end
29        end
30    end
31   
32    if sum(pass)>1
33        %druha faze RSSS
34        %sum(pass)   
35        for i=1:size(candidates)
36            if (pass(i))
37                n_1=max(1,(-floor(-variances(i)*(h/compare_parameters.delta)^2))-n_0);
38                n_1=min(100,n_1);
39                realization2=zeros(1,n_1);
40                C(index)=candidates(i);
41                for j=1:n_1
42                    realization2(j)=generate_realization(apriori,index,H,C,horizont);
43                end
44                mean_values(i)=mean_values(i)/(1+n_1/n_0)+mean(realization2)/(1+n_0/n_1);
45            end
46        end
47    end
48end
49
50%volba kadnidata s nejmensi prumernou ztratou
51[min_val min_index]=min(mean_values);
52best_control=candidates(min_index);
53end
Note: See TracBrowser for help on using the browser.