root/applications/bdmtoolbox/tutorial/userguide/arx_windsurfer_example.m @ 871

Revision 871, 0.9 kB (checked in by mido, 14 years ago)

adaptation of /applications to new version of LOG_LEVEL
also, a cosmetic change made in enumerations: logub -> logubound, loglb -> loglbound

Line 
1% name random variables
2y = RV({'y'},1);
3u = RV({'u'},1);
4
5% create f(y_t| y_{t-3}, u_{t-1})
6fy.class = 'mlnorm<ldmat>';
7fy.rv    = y;
8fy.rvc   = RVtimes([y,u], [-3, -1]);
9fy.A     = [0.5, -0.9];
10fy.const = 0;
11fy.R     = 1e-2;
12
13DS.class = 'PdfDS';
14DS.pdf = fy;
15
16% create ARX estimator
17A1.class = 'ARX';
18A1.rv = y;
19A1.rgr = RVtimes([y,u],[-3,-1]) ; % correct structure is {y,y}
20A1.log_level ='logbounds,logevidence';
21
22C1.class = 'LQG_ARX';
23C1.ARX = A1;
24C1.Qu = 100*eye(1);
25C1.Qy = 100*eye(1);
26C1.yreq = 1;
27C1.horizon = 10;
28
29C2 = C1;
30C2.windsurfer = 1;
31
32N = 10;
33losses_plain=zeros(1,N);
34losses_wind =zeros(1,N);
35
36for i=1:1000
37    M= controlloop(DS,{C1});
38    losses_plain(i) = (M.DS_y - C1.yreq)'*(M.DS_y - C1.yreq);
39
40    M= controlloop(DS,{C2});
41    losses_wind(i) = (M.DS_y - C1.yreq)'*(M.DS_y - C1.yreq);
42    if losses_wind(i)>100
43      %  keyboard;
44    end
45end
46[mean(losses_plain), mean(losses_wind)]
47[std(losses_plain), std(losses_wind)]
Note: See TracBrowser for help on using the browser.