1 | function [w x]=sidp3(sidp_parameters, compare_parameters,system,apriori)
|
---|
2 | eps=10^-4;
|
---|
3 | mode=0;
|
---|
4 | q=0;
|
---|
5 | col(1)='b';col(2)='r' ;col(3)='c' ;col(4)='m' ;col(5)='y';
|
---|
6 | a=0;
|
---|
7 | compare_parameters.student=quantile(trnd((sidp_parameters.num_of_candidates-1)*ones(1,100000)),(1-compare_parameters.alpha)^(1/(sidp_parameters.num_of_candidates-1)));
|
---|
8 | compare_parameters.rinott=4;
|
---|
9 |
|
---|
10 | apriori.eta0=abs(apriori.y0)/system.sigma;
|
---|
11 | %apriori.eta0=0;
|
---|
12 |
|
---|
13 | apriori.beta0=abs(apriori.b0)/sqrt(apriori.P0);
|
---|
14 | apriori.beta0_range=2*apriori.P0/sqrt(apriori.P0);
|
---|
15 | if apriori.beta0-apriori.beta0_range<eps
|
---|
16 | apriori.beta0=(abs(apriori.b0)+2*apriori.P0)/2/sqrt(apriori.P0);
|
---|
17 | apriori.beta0_range=apriori.beta0-eps;
|
---|
18 | end
|
---|
19 |
|
---|
20 | [H C]=init_hyperstate(sidp_parameters.n_grid,apriori,mode); %vytvori H a mi, nastavi H0 a mi*
|
---|
21 |
|
---|
22 | min_distance_C=0.5*sidp_parameters.search_region_init;
|
---|
23 | min_distance_H=(H(1,end)-H(1,1))/50;
|
---|
24 |
|
---|
25 | %[los1 los2]=mc_study(system,apriori,1000); q=q+1; w(q)=los1(1)/los1(3); x(q)=los2(1)/los2(3);
|
---|
26 |
|
---|
27 |
|
---|
28 | for j=1:sidp_parameters.n_iter
|
---|
29 | j
|
---|
30 | %search_region=sidp_parameters.gama^(j-1)*sidp_parameters.lambda^(i-1)*sidp_parameters.search_region_init;
|
---|
31 | search_region=sidp_parameters.gama^(j-1)*sidp_parameters.search_region_init;
|
---|
32 | %prolez mrizku a iteruj rizeni
|
---|
33 | for k=1:sidp_parameters.n_grid
|
---|
34 | candidates=generate_candidates(C(k), search_region, sidp_parameters.num_of_candidates);
|
---|
35 | C(k)=choose_best_control(H,C,k,apriori,sidp_parameters.horizont,candidates,compare_parameters);
|
---|
36 | end
|
---|
37 |
|
---|
38 | %[los1 los2]=mc_study(system,apriori,1000); q=q+1; w(q)=los1(2)/los1(3); x(q)=los2(2)/los2(3);
|
---|
39 |
|
---|
40 | vypis=H;
|
---|
41 | save 'Beta.txt' vypis -ASCII;
|
---|
42 | save 'C.txt' C -ASCII;
|
---|
43 |
|
---|
44 | %pokud je mrizka prilis hruba, zjemni ji tamkde je treba
|
---|
45 | for k=1:sidp_parameters.n_grid-1
|
---|
46 | if (abs(C(k)-C(k+1))>min_distance_C && sidp_parameters.n_grid<sidp_parameters.n_grid_max && H(k+1)-H(k)>min_distance_H)
|
---|
47 | % [H C]=update(H,C,k); sidp_parameters.n_grid=sidp_parameters.n_grid+1;
|
---|
48 | end
|
---|
49 | end
|
---|
50 |
|
---|
51 | % subplot(2,1,1);
|
---|
52 | % plot(H,C,['',col(j)]); hold on; a=max(a,max(C(:)));
|
---|
53 | end
|
---|
54 |
|
---|
55 | %xlabel('\fontsize{18} \beta'); ylabel('\fontsize{18} \nu^{ (2)}_0'); set(gca,'ylim',[0 a]); set(gca,'xlim',[0 H(end)]); legend('\pi_1','\pi_2','\pi_3','\pi_4');
|
---|
56 | %subplot(2,1,2);
|
---|
57 | %plot(0:sidp_parameters.n_iter,[w' x' ones(size(x,2),1)]); xlabel('\fontsize{18} iterace'); ylabel('\fontsize{18} relativn�tr�'); legend('mean','median');set(gca,'ylim',[0.99 max(w(1),x(1))]); set(gca,'xtick',0:sidp_parameters.n_iter); set( get(gcf, 'Children'), 'FontSize', 18);
|
---|
58 | %[w;x]
|
---|
59 | end
|
---|
60 |
|
---|