Changeset 686

Show
Ignore:
Timestamp:
10/29/09 23:24:04 (14 years ago)
Author:
smidl
Message:

pmsm using new syntax for bayes

Files:
7 modified

Legend:

Unmodified
Added
Removed
  • applications/pmsm/cfg/uni_test.cfg

    r667 r686  
    55}; 
    66 
    7 system0= "system@cfg/sim.cfg"; 
     7system= "system@cfg/sim.cfg"; 
    88 
    9 system= { 
     9system0= { 
    1010        class = "ITppFileDS"; 
    1111        filename = "Barcelona/tec0009ALL.it"; 
     
    3232        prior = {class ="euni"; low = [-1,-1,-1,-1]; high=[1,1,1,1];}; 
    3333        //connect 
    34         drv = {class="RV"; names=("o_ia","o_ib","o_ua","o_ub");}; 
     34        yrv = {class="RV"; names=("o_ia","o_ib");}; 
     35        rvc = {class="RV"; names=("o_ua","o_ub");}; 
    3536        rv = {class="RV"; names=("e_ia","e_ib","e_om","e_th");}; 
    3637        options = "logbounds"; 
  • applications/pmsm/filters.h

    r654 r686  
    141141                validate(); 
    142142        } 
    143         void bayes ( const vec& data ) { 
     143        void bayes ( const vec &yt, const vec &cond ) { 
    144144                const vec &mu = posterior().mean(); 
    145145                const vec &Var =  posterior().variance(); 
     
    163163#pragma parallel for 
    164164                for ( i = 0; i < n; i++ ) { 
    165                         BMs ( i ) -> condition ( pf->posterior()._sample ( i ) ); 
    166                         BMs ( i ) -> bayes ( data ); 
     165                        BMs ( i ) -> bayes ( yt, concat(cond, pf->posterior()._sample ( i )) ); 
    167166                        lls ( i ) += BMs ( i )->_ll(); 
    168167                } 
  • applications/pmsm/pmsmDS.h

    r679 r686  
    3838public: 
    3939    //! Constructor with fixed sampling period 
    40     pmsmDS () 
     40    pmsmDS () : DS() 
    4141    { 
    4242        Dt=125; 
    43         Drv=RV ( "{o_ua o_ub o_ia o_ib t_ua t_ub o_om o_th Mz }" ); 
     43        Yrv=RV ( "{o_ua o_ub o_ia o_ib t_ua t_ub o_om o_th Mz }" ); 
     44                ytsize = Yrv._dsize(); 
     45                Drv = Yrv; 
    4446    } 
    4547    void set_parameters ( double Rs0, double Ls0, double Fmag0, double Bf0, double p0, double kp0, double J0, double Uc0, double DT0, double dt0 ) 
     
    210212        static vec umin(2); 
    211213                vec u(2); 
    212                 vec &mu = est->_mu(); 
     214                vec &mu = est._mu(); 
    213215                //assume we know state exactly: 
    214216        vec true_state=vec(x,4); // read from pmsm 
     
    312314        true_state(4)=x[8]; 
    313315 
    314         vec &mu = est->_mu(); 
     316        vec &mu = est._mu(); 
    315317        mu = true_state; 
    316318        //hack for ut 
  • applications/pmsm/pmsm_estim.cpp

    r676 r686  
    4444        vec dt=zeros ( pDS->_drv()._dsize() );   //data variable 
    4545        Array<datalink*> Dls(nE);  
     46        Array<datalink*> Dlsc(nE);  
    4647        for (int i=0; i<nE; i++){ 
    47                 Dls(i)=new datalink( Es(i)->_drv(),pDS->_drv() ); //datalink between a datasource and estimator 
     48                Dls(i)=new datalink( Es(i)->_yrv(),pDS->_drv() ); //datalink between a datasource and estimator 
     49                Dlsc(i)=new datalink( Es(i)->_rvc(),pDS->_drv() ); //datalink between a datasource and estimator 
    4850        } 
    4951         
     
    5759                // Estimators 
    5860                for (int i=0; i<nE; i++){ 
    59                         Es(i)->bayes ( Dls(i)->pushdown ( dt ) );               // update estimates 
     61                        Es(i)->bayes ( Dls(i)->pushdown ( dt ), Dlsc(i)->pushdown(dt) );                // update estimates 
    6062 
    6163                        Es(i)->log_write (); 
     
    6971        for (int i=0; i<nE; i++){ 
    7072                delete Dls(i); 
     73                delete Dlsc(i); 
    7174        } 
    7275        return 0; 
  • library/bdm/estim/kalman.cpp

    r679 r686  
    244244 
    245245void EKFCh::from_setting ( const Setting &set ) { 
     246        BM::from_setting(set); 
    246247        shared_ptr<diffbifn> IM = UI::build<diffbifn> ( set, "IM", UI::compulsory ); 
    247248        shared_ptr<diffbifn> OM = UI::build<diffbifn> ( set, "OM", UI::compulsory ); 
     
    267268        UI::get ( dR, set, "dR", UI::compulsory ); 
    268269        set_parameters ( IM, OM, diag ( dQ ), diag ( dR ) ); 
    269  
    270         //connect 
    271         shared_ptr<RV> drv = UI::build<RV> ( set, "drv", UI::compulsory ); 
    272         set_yrv ( *drv ); 
    273         shared_ptr<RV> rv = UI::build<RV> ( set, "rv", UI::compulsory ); 
    274         set_rv ( *rv ); 
    275  
    276         string options; 
    277         if ( UI::get ( options, set, "options" ) ) 
    278                 set_options ( options ); 
    279270} 
    280271 
  • library/bdm/estim/kalman.h

    r681 r686  
    246246                        return est._R().to_mat(); 
    247247                } 
    248                 void from_setting (const Setting &set) { 
     248                void from_setting (const Setting &set) {                         
     249                        BM::from_setting(set); 
    249250                        shared_ptr<diffbifn> IM = UI::build<diffbifn> ( set, "IM", UI::compulsory ); 
    250251                        shared_ptr<diffbifn> OM = UI::build<diffbifn> ( set, "OM", UI::compulsory ); 
     
    270271                        UI::get ( dR, set, "dR", UI::compulsory ); 
    271272                        set_parameters ( IM, OM, diag ( dQ ), diag ( dR ) ); 
    272                          
    273                         //connect 
    274                         shared_ptr<RV> drv = UI::build<RV> ( set, "drv", UI::compulsory ); 
    275                         set_yrv ( *drv ); 
    276                         shared_ptr<RV> rv = UI::build<RV> ( set, "rv", UI::compulsory ); 
    277                         set_rv ( *rv ); 
    278                          
     273                                                 
    279274                        string options; 
    280275                        if ( UI::get ( options, set, "options" ) ) 
  • library/bdm/estim/particles.h

    r679 r686  
    131131                u.add(obs_u); // join both u, and check if they do not overlap 
    132132 
    133                 set_yrv(concat(obs->_rv(),u) ); 
     133                set_yrv(obs->_rv() ); 
     134                rvc = u; 
    134135        } 
    135136        //! auxiliary function reading parameter 'resmethod' from configuration file