Revision 650, 0.7 kB
(checked in by smidl, 15 years ago)
|
example of control for a trivial ARX model
|
Line | |
---|
1 | % configuracni struktura se bude jmenovat "c" |
---|
2 | c.b =1; |
---|
3 | c.sigma = 0.1; |
---|
4 | c.ndat = 50; |
---|
5 | |
---|
6 | yr = 1; |
---|
7 | |
---|
8 | % nejlepsi mozny regulator - zna b |
---|
9 | C1.class='exact_ctrl'; |
---|
10 | C1.yr = yr; |
---|
11 | C1.b = c.b; |
---|
12 | |
---|
13 | % CE regulator - b se odhaduje |
---|
14 | C2.class='ce_ctrl'; |
---|
15 | C2.yr = yr; |
---|
16 | C2.b0 = -0.; |
---|
17 | C2.P0 = 1; |
---|
18 | |
---|
19 | c.controller = C1; |
---|
20 | M1=iterativemc(c); |
---|
21 | |
---|
22 | loss_exact = sum((M1.y-yr*ones(size(M1.y))).^2) |
---|
23 | loss_theory = c.ndat*c.sigma^2 |
---|
24 | |
---|
25 | c.controller = C2; |
---|
26 | M2=iterativemc(c); |
---|
27 | |
---|
28 | loss_ce = sum((M2.y-yr*ones(size(M2.y))).^2) |
---|
29 | |
---|
30 | % monte carlo study |
---|
31 | n=100; |
---|
32 | losses=zeros(10,1); |
---|
33 | c.controller = C1; |
---|
34 | seeds=32000*rand(1,n); |
---|
35 | for i=1:n |
---|
36 | c.seed = seeds(i); |
---|
37 | Mmc=iterativemc(c); |
---|
38 | losses(i) = sum((Mmc.y-yr*ones(size(Mmc.y))).^2); |
---|
39 | end |
---|
40 | [min(losses) mean(losses) max(losses)] |
---|
41 | |
---|