- Timestamp:
- 11/28/09 14:38:48 (15 years ago)
- Location:
- library/bdm
- Files:
-
- 8 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/base/bdmbase.cpp
r738 r744 495 495 void datalink_buffered::set_connection ( const RV &rv, const RV &rv_up ) { 496 496 // create link between up and down 497 datalink_part::set_connection ( rv, rv_up .remove_time()); // only non-delayed version497 datalink_part::set_connection ( rv, rv_up); // only non-delayed version 498 498 499 499 // create rvs of history 500 500 // we can store only what we get in rv_up - everything else is removed 501 ivec valid_ids = rv.findself_ids ( rv_up ); 502 RV rv_hist = rv.subselect ( find ( valid_ids >= 0 ) ); // select only rvs that are in rv_up 501 ivec valid_ids = rv.findself_ids ( rv_up ); // return on which position each id is 502 RV rv_hist = rv.subselect ( find ( valid_ids >= 0 ) ); // select only rvs that are in rv_up, ie ind>0 503 503 RV rv_hist0 = rv_hist.remove_time(); // these RVs will form history at time =0 504 504 // now we need to know what is needed from Up -
library/bdm/base/bdmbase.h
r741 r744 1096 1096 yrv = rv; 1097 1097 } 1098 //! access function 1099 void set_rvc ( const RV &rv ) { 1100 rvc = rv; 1101 } 1098 1102 //! access to rv of the posterior 1099 1103 void set_rv ( const RV &rv ) { -
library/bdm/design/arx_ctrl.h
r737 r744 124 124 lq.validate(); 125 125 126 rv = urvm; // rv is not shifted to t+1!! 126 127 rvc = concat ( xrv, urvm ); 127 128 rvc2ar_y.set_connection ( ar->_yrv(), rvc ); -
library/bdm/design/ctrlbase.cpp
r738 r744 13 13 //penalization 14 14 qux.set_submatrix ( 0, 0, Qu._Ch() ); 15 qux.set_submatrix ( 0, dimx + dimu + dimy, Qu._Ch() );15 qux.set_submatrix ( 0, dimx + dimu + dimy, -Qu._Ch() ); 16 16 17 17 qyx.set_submatrix ( 0, 0, S->_C() ); … … 57 57 58 58 void LQG::ricatti_step() { 59 pre_qr.set_submatrix ( 0, 0, s*pr );60 pre_qr.set_submatrix ( dimx + dimu + dimy, dimu + dimx, -Qy.to_mat() *y_req );59 // pre_qr.set_submatrix ( 0, 0, s*pr ); 60 // pre_qr.set_submatrix ( dimx + dimu + dimy, dimu + dimx, -Qy.to_mat() *y_req ); 61 61 if ( !qr ( pre_qr, post_qr ) ) { 62 62 bdm_warning ( "QR in LQG unstable" ); -
library/bdm/estim/ekf_template.h
r477 r744 22 22 public: 23 23 void condition ( const vec &QR0 ) { 24 Q = diag ( QR0 ( 0, dim x- 1 ) );25 R = diag ( QR0 ( dim x, dimx+ dimy - 1 ) );24 Q = diag ( QR0 ( 0, dimension() - 1 ) ); 25 R = diag ( QR0 ( dimension(), dimension() + dimy - 1 ) ); 26 26 }; 27 27 }; … … 30 30 class EKFCh_dQ : public EKFCh { 31 31 public: 32 void condition ( const vec &Q0 ) { 33 Q.setD ( Q0, 0 ); 32 BM* _copy_() const {return new EKFCh_dQ(*this);} 33 //! new bayes, expects cond = [ut, Qt] 34 void bayes( const vec &yt , const vec &cond) { 35 vec ut=cond.left(dimc-dimension()); 36 vec dQt=cond.right(dimension()); 37 Q.setD ( dQt, 0 ); 34 38 //from EKF 35 preA.set_submatrix ( dimy + dimx, dimy, Q._Ch() ); 39 preA.set_submatrix ( dimy + dimension(), dimy, Q._Ch() ); 40 41 EKFCh::bayes(yt,ut); 36 42 }; 43 void validate() { 44 EKFCh::validate(); 45 dimc += dimension(); 46 } 37 47 }; 38 48 … … 43 53 Q.setCh ( chQ0 ); 44 54 //from EKF 45 preA.set_submatrix ( dimy + dim x, dimy, Q._Ch() );55 preA.set_submatrix ( dimy + dimension(), dimension(), Q._Ch() ); 46 56 }; 47 57 }; -
library/bdm/estim/kalman.cpp
r739 r744 264 264 int active_x = y_block_size; 265 265 for ( int r = 0; r < urv.length(); r++ ) { 266 diagonal_part ( this->A, active_x + urv.size ( r ), active_x, u_block_sizes ( r ) - urv.size ( r ) ); 267 this->B.set_submatrix ( active_x, 0, eye ( urv.size ( r ) ) ); 266 if (u_block_sizes(r)>0){ 267 diagonal_part ( this->A, active_x + urv.size ( r ), active_x, u_block_sizes ( r ) - urv.size ( r ) ); 268 this->B.set_submatrix ( active_x, 0, eye ( urv.size ( r ) ) ); 269 } 268 270 active_x += u_block_sizes ( r ); 269 271 } -
library/bdm/estim/kalman.h
r739 r744 336 336 //! copy constructor duplicated - calls different set_parameters 337 337 BM* _copy_() const { 338 EKFCh* E = new EKFCh; 339 E->set_parameters ( pfxu, phxu, Q, R ); 340 E->set_statistics ( est._mu(), est._R() ); 341 return E; 338 return new EKFCh(*this); 342 339 } 343 340 //! Set nonlinear functions for mean values and covariance matrices. -
library/bdm/estim/particles.h
r739 r744 267 267 MPF () : jest ( pf, BMs ) {}; 268 268 //! set all parameters at once 269 void set_parameters ( shared_ptr<pdf> par0, shared_ptr<pdf> obs0, int n0, RESAMPLING_METHOD rm = SYSTEMATIC ) { 270 pf->set_model ( par0, obs0 ); 269 void set_pf ( shared_ptr<pdf> par0, int n0, RESAMPLING_METHOD rm = SYSTEMATIC ) { 270 if (!pf) pf=new PF; 271 pf->set_model ( par0, par0 ); // <=== nasty!!! 271 272 pf->set_parameters ( n0, rm ); 273 pf->set_rv(par0->_rv()); 272 274 BMs.set_length ( n0 ); 273 275 } … … 298 300 return BMs ( i ); 299 301 } 302 PF& _pf() {return *pf;} 300 303 301 304 /*! configuration structure for basic PF