1 | function best_control=choose_best_control(H,C,index,apriori,horizont,candidates,compare_parameters)
|
---|
2 | num_of_candidates=size(candidates,1);
|
---|
3 | n_0=compare_parameters.n0;
|
---|
4 | realization1=zeros(num_of_candidates,n_0);
|
---|
5 |
|
---|
6 | %generovani eralizaci ztrat
|
---|
7 | for 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
|
---|
12 | end
|
---|
13 | mean_values=mean(realization1,2);
|
---|
14 |
|
---|
15 | %RSSS
|
---|
16 | if (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
|
---|
48 | end
|
---|
49 |
|
---|
50 | %volba kadnidata s nejmensi prumernou ztratou
|
---|
51 | [min_val min_index]=min(mean_values);
|
---|
52 | best_control=candidates(min_index);
|
---|
53 | end |
---|