| 1 | /*! |
|---|
| 2 | \file |
|---|
| 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> |
|---|
| 11 | #include <estim/arx_ui.h> |
|---|
| 12 | |
|---|
| 13 | using namespace bdm; |
|---|
| 14 | int main() { |
|---|
| 15 | UIFile F ( "UIArxDS_test.cfg" ); |
|---|
| 16 | |
|---|
| 17 | logger* L; |
|---|
| 18 | UIbuild ( F.lookup ( "logger" ),L ); |
|---|
| 19 | ArxDS * DS; |
|---|
| 20 | UIbuild ( F.lookup ( "system" ),DS ); |
|---|
| 21 | int Ndat; |
|---|
| 22 | F.lookupValue ( "experiment.ndat",Ndat ); |
|---|
| 23 | // SET SIMULATOR |
|---|
| 24 | BM* E; |
|---|
| 25 | UIbuild ( F.lookup ( "estimator" ),E ); |
|---|
| 26 | |
|---|
| 27 | DS->log_add ( *L ); |
|---|
| 28 | int L_est= L->add ( E->_epdf()._rv(), "est" ); // estimate |
|---|
| 29 | int L_lb = L->add ( E->_epdf()._rv(), "lb" ); // lower bound |
|---|
| 30 | int L_ub = L->add ( E->_epdf()._rv(), "ub" ); // upper bound |
|---|
| 31 | L->init(); |
|---|
| 32 | |
|---|
| 33 | vec dt=zeros ( DS->_drv().count() ); //data variable |
|---|
| 34 | datalink_e2e dl ( E->_drv(),DS->_drv() ); //datalink between a datasource and estimator |
|---|
| 35 | |
|---|
| 36 | for ( int tK=1;tK<Ndat;tK++ ) { |
|---|
| 37 | DS->step(); // simulator step |
|---|
| 38 | DS->getdata ( dt ); // read data |
|---|
| 39 | E->bayes ( dl.get_val ( dt ) ); // update estimates |
|---|
| 40 | |
|---|
| 41 | DS->logit ( *L ); |
|---|
| 42 | L->logit ( L_est, E->_epdf().mean() ); |
|---|
| 43 | L->logit ( L_lb, E->_epdf().mean()-2*sqrt ( E->_epdf().variance() ) ); |
|---|
| 44 | L->logit ( L_ub, E->_epdf().mean() +2*sqrt ( E->_epdf().variance() ) ); |
|---|
| 45 | |
|---|
| 46 | L->step(); |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | L->finalize(); |
|---|
| 50 | |
|---|
| 51 | delete L; |
|---|
| 52 | delete DS; |
|---|
| 53 | delete E; |
|---|
| 54 | return 0; |
|---|
| 55 | } |
|---|