[263] | 1 | /*! |
---|
[265] | 2 | \file |
---|
[263] | 3 | \brief Test of UI builders for ARX |
---|
| 4 | |
---|
| 5 | See file \ref arx for mathematical background. |
---|
| 6 | |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | |
---|
| 10 | #include <stat/libDS_ui.h> |
---|
[265] | 11 | #include <estim/arx_ui.h> |
---|
[263] | 12 | |
---|
| 13 | using namespace bdm; |
---|
[268] | 14 | int main(int argc, char* argv[]) { |
---|
| 15 | const char *fname; |
---|
| 16 | if (argc>0) { |
---|
| 17 | fname = argv[0]; |
---|
| 18 | } else { |
---|
| 19 | fname = "UIArxDS_test.cfg"; |
---|
| 20 | } |
---|
| 21 | UIFile F ( fname ); |
---|
[263] | 22 | |
---|
[265] | 23 | logger* L; |
---|
| 24 | UIbuild ( F.lookup ( "logger" ),L ); |
---|
[263] | 25 | ArxDS * DS; |
---|
[265] | 26 | UIbuild ( F.lookup ( "system" ),DS ); |
---|
[263] | 27 | int Ndat; |
---|
[265] | 28 | F.lookupValue ( "experiment.ndat",Ndat ); |
---|
[263] | 29 | // SET SIMULATOR |
---|
[265] | 30 | BM* E; |
---|
| 31 | UIbuild ( F.lookup ( "estimator" ),E ); |
---|
[263] | 32 | |
---|
[265] | 33 | DS->log_add ( *L ); |
---|
| 34 | int L_est= L->add ( E->_epdf()._rv(), "est" ); // estimate |
---|
| 35 | int L_lb = L->add ( E->_epdf()._rv(), "lb" ); // lower bound |
---|
| 36 | int L_ub = L->add ( E->_epdf()._rv(), "ub" ); // upper bound |
---|
[263] | 37 | L->init(); |
---|
[265] | 38 | |
---|
| 39 | vec dt=zeros ( DS->_drv().count() ); //data variable |
---|
| 40 | datalink_e2e dl ( E->_drv(),DS->_drv() ); //datalink between a datasource and estimator |
---|
| 41 | |
---|
[263] | 42 | for ( int tK=1;tK<Ndat;tK++ ) { |
---|
[265] | 43 | DS->step(); // simulator step |
---|
| 44 | DS->getdata ( dt ); // read data |
---|
| 45 | E->bayes ( dl.get_val ( dt ) ); // update estimates |
---|
| 46 | |
---|
| 47 | DS->logit ( *L ); |
---|
| 48 | L->logit ( L_est, E->_epdf().mean() ); |
---|
| 49 | L->logit ( L_lb, E->_epdf().mean()-2*sqrt ( E->_epdf().variance() ) ); |
---|
| 50 | L->logit ( L_ub, E->_epdf().mean() +2*sqrt ( E->_epdf().variance() ) ); |
---|
| 51 | |
---|
[263] | 52 | L->step(); |
---|
| 53 | } |
---|
[265] | 54 | |
---|
| 55 | L->finalize(); |
---|
| 56 | |
---|
[263] | 57 | delete L; |
---|
| 58 | delete DS; |
---|
[265] | 59 | delete E; |
---|
[263] | 60 | return 0; |
---|
| 61 | } |
---|