[254] | 1 | /*! |
---|
| 2 | \file |
---|
| 3 | \brief Models for synchronous electric drive using IT++ and BDM |
---|
| 4 | \author Vaclav Smidl. |
---|
| 5 | |
---|
| 6 | ----------------------------------- |
---|
| 7 | BDM++ - C++ library for Bayesian Decision Making under Uncertainty |
---|
| 8 | |
---|
| 9 | Using IT++ for numerical operations |
---|
| 10 | ----------------------------------- |
---|
| 11 | */ |
---|
| 12 | |
---|
[262] | 13 | |
---|
[254] | 14 | #include <estim/ekf_templ.h> |
---|
[283] | 15 | #include <stat/loggers_ui.h> |
---|
| 16 | #include <stat/libDS_ui.h> |
---|
[254] | 17 | |
---|
| 18 | //include dopravni model |
---|
| 19 | #include "model.h" |
---|
| 20 | |
---|
| 21 | using namespace bdm; |
---|
| 22 | |
---|
[283] | 23 | int main( int argc, char* argv[] ) { |
---|
| 24 | /* const char *fname; |
---|
| 25 | if ( argc>1 ) {fname = argv[1]; } |
---|
| 26 | else { fname = "k1.cfg"; } |
---|
| 27 | UIFile F ( fname ); //protected by exceptions, should complain if not found*/ |
---|
| 28 | |
---|
[309] | 29 | ItppFileDS DS("data.it","Data"); // Data Source |
---|
[283] | 30 | int ndat = DS.ndat(); // number of data |
---|
| 31 | memlog L(ndat); // Logger |
---|
| 32 | string resfile="k1_results.it"; // name of output file |
---|
| 33 | vec dQ="0.1 0.1"; |
---|
| 34 | vec dR="0.2 0.2"; // TODO: read from config file <== broken on windows |
---|
| 35 | |
---|
[254] | 36 | //model vyvoje stavu |
---|
| 37 | IMk1 fxu; |
---|
| 38 | fxu.set_parameters (0.5, 0.5); // pokud nejake budou |
---|
| 39 | |
---|
| 40 | //model pozorovani |
---|
| 41 | OMk1 hxu; |
---|
| 42 | //hxu.set_parameters (); // odkomentovat pokud budou |
---|
| 43 | |
---|
| 44 | // ESTIMATOR --- EKF |
---|
| 45 | // Priprava covariancnich matic pro EKF |
---|
[283] | 46 | EKFCh Efix; //Extended KF s fix. variancemi |
---|
| 47 | Efix.set_parameters ( &fxu,&hxu,diag(dQ),diag(dR)); |
---|
| 48 | Efix.set_statistics ( zeros(fxu.dimension()), 100*eye ( fxu.dimension() ) ); // nulova |
---|
[254] | 49 | |
---|
[283] | 50 | // Definovat co se bude logovat |
---|
[318] | 51 | Efix.log_add(L,"E"); |
---|
[254] | 52 | L.init(); // <<==== allocate memory for results |
---|
[283] | 53 | |
---|
| 54 | vec dt; |
---|
| 55 | for ( int t=1;t<ndat;t++ ) { |
---|
| 56 | DS.getdata(dt); // dt is allocated |
---|
| 57 | Efix.bayes(dt); //ESTIMATE |
---|
[254] | 58 | |
---|
| 59 | //LOG results |
---|
[318] | 60 | Efix.logit(L); |
---|
[254] | 61 | |
---|
| 62 | L.step(); |
---|
[283] | 63 | DS.step(); |
---|
[254] | 64 | } |
---|
| 65 | L.finalize(); |
---|
[283] | 66 | L.itsave(resfile.c_str()); |
---|
[254] | 67 | return 0; |
---|
| 68 | } |
---|