1 | function best_control=compare_candidates(start,candidates,H,u,rsss_parameters,yr,sigma)
|
---|
2 | %hledam minimum
|
---|
3 | rinott=3;
|
---|
4 | student=5;
|
---|
5 |
|
---|
6 | %n0 prvnich realizaci
|
---|
7 | realization1=zeros(size(candidates,1),rsss_parameters.n0);
|
---|
8 | for i=1:size(candidates)
|
---|
9 | for j=1:rsss_parameters.n0
|
---|
10 | realization1(i,j)=generate_realization(start,candidates(i),H,u,sigma,yr);
|
---|
11 | end
|
---|
12 | end
|
---|
13 |
|
---|
14 | %pomocne veliciny
|
---|
15 | mean_values=mean(realization1,2);
|
---|
16 | variances=sum((realization1-mean_values*ones(1,rsss_parameters.n0)).^2,2)/(rsss_parameters.n0-1);
|
---|
17 | W=student*sqrt((variances*ones(1,size(candidates,1))+ones(size(candidates,1),1)*variances')/rsss_parameters.n0);
|
---|
18 |
|
---|
19 | %selekce kadnidatu pro druhou fazi RSSS
|
---|
20 | pass=zeros(size(candidates,1),1);
|
---|
21 | for i=1:size(candidates)
|
---|
22 | pom=true;
|
---|
23 | for j=1:size(candidates)
|
---|
24 | % max(realization1);
|
---|
25 | %max(0,W(i,j)-rsss_parameters.delta)
|
---|
26 | if (mean_values(i)>10*min(mean_values))
|
---|
27 | pom=false;
|
---|
28 | end
|
---|
29 | if (pom && -mean_values(i)<-mean_values(j)-max(0,W(i,j)-rsss_parameters.delta)) %hledam minimum
|
---|
30 | pom=false;
|
---|
31 | end
|
---|
32 | end
|
---|
33 | pass(i)=pom;
|
---|
34 | end
|
---|
35 |
|
---|
36 | if sum(pass)>1
|
---|
37 | sum(pass);
|
---|
38 | %druha faze RSSS
|
---|
39 | best_control=0;
|
---|
40 | for i=1:size(candidates)
|
---|
41 | if (pass(i))
|
---|
42 | poc=(-floor(-variances(i)*(rinott/rsss_parameters.delta)^2));
|
---|
43 | poc=min(1000,poc);
|
---|
44 | realization2=zeros(1,poc);
|
---|
45 | for j=1:size(realization2,2)
|
---|
46 | realization2(j)=generate_realization(start,candidates(i),H,u,sigma,yr);
|
---|
47 | end
|
---|
48 | mean_values(i)=mean(realization1(i))+mean(realization2);
|
---|
49 | if (best_control && mean_value(i)>mean_value(best_control))
|
---|
50 | best_control=i;
|
---|
51 | end
|
---|
52 | end
|
---|
53 | end
|
---|
54 | else
|
---|
55 | [pom,best_control]=max(pass);
|
---|
56 | end
|
---|
57 |
|
---|
58 |
|
---|
59 | end |
---|