1 | |
---|
2 | /*! |
---|
3 | \file |
---|
4 | \brief UI for ARX estimators |
---|
5 | \author Vaclav Smidl. |
---|
6 | |
---|
7 | ----------------------------------- |
---|
8 | BDM++ - C++ library for Bayesian Decision Making under Uncertainty |
---|
9 | |
---|
10 | Using IT++ for numerical operations |
---|
11 | ----------------------------------- |
---|
12 | */ |
---|
13 | |
---|
14 | #ifndef ARX_UI_H |
---|
15 | #define ARX_UI_H |
---|
16 | |
---|
17 | |
---|
18 | #include "arx.h" |
---|
19 | #include "stat/loggers_ui.h" |
---|
20 | |
---|
21 | /*! UI for ARX estimator |
---|
22 | |
---|
23 | The ARX is constructed from a structure with fields: |
---|
24 | \code |
---|
25 | estimator = { |
---|
26 | type = "ARX"; |
---|
27 | y = {type="rv", ...} // description of output variables |
---|
28 | rgr = {type="rv", ...} // description of regressor variables |
---|
29 | constant = true; // boolean switch if the constant term is modelled or not |
---|
30 | |
---|
31 | //optional fields |
---|
32 | dV0 = [1e-3, 1e-5, 1e-5, 1e-5]; |
---|
33 | // default: 1e-3 for y, 1e-5 for rgr |
---|
34 | nu0 = 6; // default: rgrlen + 2 |
---|
35 | frg = 1.0; // forgetting, default frg=1.0 |
---|
36 | }; |
---|
37 | \endcode |
---|
38 | |
---|
39 | The estimator will assign names of the posterior in the form ["theta_i" and "r_i"] |
---|
40 | */ |
---|
41 | class UIARX : public UIbuilder { |
---|
42 | public: |
---|
43 | UIARX() :UIbuilder ( "ARXest" ) {}; |
---|
44 | bdmroot* build ( Setting &S ) const { |
---|
45 | RV *yrv; UIbuild(S["y"],yrv); |
---|
46 | RV *rrv; UIbuild(S["rgr"],rrv); |
---|
47 | int ylen = yrv->_dsize(); |
---|
48 | int rgrlen = rrv->_dsize(); |
---|
49 | |
---|
50 | //init |
---|
51 | mat V0; |
---|
52 | if ( S.exists ( "dV0" ) ) { |
---|
53 | V0=diag ( getvec(S["dV0"]) ); |
---|
54 | } |
---|
55 | else { |
---|
56 | V0=concat ( 1e-3*ones ( ylen ), 1e-5*ones ( rgrlen ) ); |
---|
57 | } |
---|
58 | double nu0; |
---|
59 | if ( S.exists ( "nu0" ) ) { |
---|
60 | nu0=double(S["nu0"]); |
---|
61 | } |
---|
62 | else { |
---|
63 | nu0 = rgrlen+ylen+2; |
---|
64 | } |
---|
65 | double frg; |
---|
66 | if ( S.exists ( "frg" ) ) { |
---|
67 | frg = S["frg"]; |
---|
68 | } |
---|
69 | else { |
---|
70 | frg = 1.0; |
---|
71 | } |
---|
72 | ARX* A=new ARX; |
---|
73 | A->set_parameters(frg); |
---|
74 | A->set_statistics(ylen,V0, nu0); |
---|
75 | A->set_drv(concat(*yrv,*rrv)); |
---|
76 | |
---|
77 | //name results (for logging) |
---|
78 | A->set_rv(RV("{theta r }", vec_2(ylen*rgrlen, ylen*ylen))); |
---|
79 | delete yrv; delete rrv; |
---|
80 | return A; |
---|
81 | }; |
---|
82 | }; |
---|
83 | |
---|
84 | UIREGISTER ( UIARX ); |
---|
85 | |
---|
86 | #endif // DS_UI_H |
---|