root/applications/pmsm/pmsm_estim.cpp @ 394

Revision 394, 1.5 kB (checked in by mido, 15 years ago)

1) UI_File renamed to UIFile
2) part UI's documentation
3) stat/mixtures.h renamed to stat/emix.h and related changes applied

Line 
1
2/*!
3\file
4\brief Multi-Estimator (developped for PMSM)
5
6
7 */
8
9#include "user_info.h"
10#include "stat/loggers.h"
11#include "estim/kalman.h"
12#include "pmsmDS.h"
13
14
15using namespace bdm;
16int main ( int argc, char* argv[] ) {
17        const char *fname;
18        if ( argc>1 ) {fname = argv[1]; }
19        else { cout << "Missing configuration file.\n Usage: \n $> estimator config_file.cfg"<<endl; abort(); }
20        UIFile F ( fname );
21
22        logger* L = UI::build <logger>( F, "logger" );
23        DS * pDS = UI::build<DS> ( F, "system" );
24        Array<BM*> Es;                  // array of estimators
25        UI::get( Es, F, "estimator" );
26        int nE = Es.length();   //number of estimators
27        int Ndat;                               //number of data records
28        F.lookupValue ( "experiment.ndat",Ndat );
29               
30        pDS->log_add ( *L );
31        string nic="";
32        for (int i=0; i<nE; i++){
33                Es(i)->log_add(*L,nic); // estimate
34        }
35        L->init();
36
37        vec dt=zeros ( pDS->_drv()._dsize() );   //data variable
38        Array<datalink*> Dls(nE); 
39        for (int i=0; i<nE; i++){
40                Dls(i)=new datalink( Es(i)->_drv(),pDS->_drv() ); //datalink between a datasource and estimator
41        }
42       
43        // Main cycle
44        for ( int tK=1;tK<Ndat;tK++ ) {
45                // Data Source
46                pDS->step();                                                    // simulator step
47                pDS->getdata ( dt );                                    // read data
48                pDS->logit ( *L );
49               
50                // Estimators
51                for (int i=0; i<nE; i++){
52                        Es(i)->bayes ( Dls(i)->pushdown ( dt ) );               // update estimates
53
54                        Es(i)->logit (*L);
55                }
56                // Regulators
57                L->step();
58        }
59
60        L->finalize();
61
62        delete L;
63        delete pDS;
64        for (int i=0; i<nE; i++){
65                delete Dls(i);
66                delete Es(i);
67        }
68        return 0;
69}
Note: See TracBrowser for help on using the browser.