- Timestamp:
- 03/05/08 16:01:56 (17 years ago)
- Location:
- tests
- Files:
-
- 4 added
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
tests/CMakeLists.txt
r32 r33 6 6 7 7 ## Save all needed libraries in variable BdmLibs 8 SET(BdmLibs bdm itpp_debug)9 #SET(BdmLibs bdm itpp)8 #SET(BdmLibs bdm itpp_debug) 9 SET(BdmLibs bdm itpp) 10 10 11 11 IF(WIN32) … … 27 27 add_executable (testResample testResample.cpp) 28 28 add_executable (testKF_QR testKF_QR.cpp) 29 add_executable (testKF_QRexh testKF_QRexh.cpp) 30 add_executable (pmsm_unkQ pmsm_unkQ.cpp) 31 add_executable (pmsm_unkQpf pmsm_unkQpf.cpp) 29 32 30 33 # Link the executable to the Hello library. … … 36 39 target_link_libraries (testResample ${BdmLibs}) 37 40 target_link_libraries (testKF_QR ${BdmLibs}) 41 target_link_libraries (testKF_QRexh ${BdmLibs}) 42 target_link_libraries (pmsm_unkQ ${BdmLibs}) 43 target_link_libraries (pmsm_unkQpf ${BdmLibs}) -
tests/testKF.cpp
r32 r33 11 11 12 12 13 // K laman filter13 // Kalman filter 14 14 mat A, B,C,D,R,Q,P0; 15 15 vec mu0; -
tests/testKF_QR.cpp
r32 r33 17 17 it_file fin( "testKF.it" ); 18 18 19 mat Dt, X Rt,eR,eQ;19 mat Dt, XQRt,eR,eQ; 20 20 int Ndat; 21 21 … … 39 39 40 40 Ndat = Dt.cols(); 41 XRt=zeros( 3,Ndat ); 41 XQRt=zeros( 5,Ndat ); 42 mat Xt=zeros( 2,Ndat ); 42 43 43 44 // cout << KF; … … 45 46 RV ru("2","{u}","1","0"); 46 47 RV ry("3","{y}","1","0"); 47 RV r R("4","{R}","1","0");48 RV rQR("4","{Q,R}","3","0"); 48 49 // 49 KFcondR KF(rx,ry,ru,rR); 50 Kalman<fsqmat> KFtr(rx,ry,ru); 51 Kalman<fsqmat> KFtr2(rx,ry,ru); 52 //correct KF 53 KFtr.set_parameters(A,B,C,D,fsqmat(R),fsqmat(Q)); 54 KFtr.set_est(mu0,fsqmat(P0) ); 55 // KF with lower R 56 mat Q2=Q/1.0; 57 mat R2=R/20.0; 58 KFtr2.set_parameters(A,B,C,D,fsqmat(R2),fsqmat(Q2)); 59 KFtr2.set_est(mu0,fsqmat(P0) ); 50 KFcondQR KF(rx,ry,ru,rQR); 60 51 // KF with R unknown 61 52 KF.set_parameters(A,B,C,D,ldmat(R),ldmat(Q)); 62 53 KF.set_est(mu0,ldmat(P0) ); 63 54 // 64 mgamma evolR(rR,rR); 65 evolR.set_parameters(10.0); //sigma = 1/10 mu 55 Kalman<ldmat> KFtr(rx,ry,ru); 56 // KF with R unknown 57 KFtr.set_parameters(A,B,C,D,ldmat(R),ldmat(Q)); 58 KFtr.set_est(mu0,ldmat(P0) ); 59 60 mgamma evolQR(rQR,rQR); 61 evolQR.set_parameters(10.0); //sigma = 1/10 mu 66 62 67 MPF<KFcondR > KF_R(rx,rR,evolR,evolR,10,KF); 68 evolR.condition("0.1"); 69 epdf& pfinit=evolR._epdf(); 70 KF_R.set_est(pfinit); 71 epdf& mpost=KF_R._epdf(); 63 MPF<KFcondQR > KF_QR(rx,rQR,evolQR,evolQR,100,KF); 64 evolQR.condition("1 1 1"); 65 epdf& pfinit=evolQR._epdf(); 66 KF_QR.set_est(pfinit); 67 epdf& mpost=KF_QR._epdf(); 68 epdf& mposttr=KFtr._epdf(); 72 69 73 cout << mpost.mean()<<endl; 74 75 XRt.set_col( 0,mpost.mean()); 76 double ll1=0.0; 77 double ll2=0.0; 70 XQRt.set_col( 0,mpost.mean()); 71 Xt.set_col( 0,mposttr.mean()); 78 72 for ( int t=1;t<Ndat;t++ ) { 79 // KF_R.bayes( Dt.get_col( t ));73 KF_QR.bayes( Dt.get_col( t )); 80 74 KFtr.bayes( Dt.get_col( t )); 81 KFtr2.bayes( Dt.get_col( t ));82 75 83 ll1+=KFtr._ll(); 84 ll2+=KFtr2._ll(); 85 86 XRt.set_col(t,mpost.mean()); 76 XQRt.set_col(t,mpost.mean()); 77 Xt.set_col(t,mposttr.mean()); 87 78 } 88 79 89 cout << ll1 << " " << ll2 <<endl; 90 91 it_file fou( "testKF_R_res.it" ); 92 fou << Name("xqrth") << XRt; 80 it_file fou( "testKF_QR_res.it" ); 81 fou << Name("xqrth") << XQRt; 82 fou << Name("xth") << Xt; 93 83 //Exit program: 94 84 return 0;