Changeset 586 for library/bdm/design/ctrlbase.cpp
- Timestamp:
- 08/27/09 15:39:35 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/design/ctrlbase.cpp
r565 r586 3 3 namespace bdm{ 4 4 5 void LQG::set_system_parameters(const mat &A0, const mat &B0, const mat &C0){ 6 dimx = A0.rows(); 7 dimy = C0.rows(); 8 dimu = B0.cols(); 9 10 bdm_assert_debug ( A0.cols() == dimx, "LQG: A is not square" ); 11 bdm_assert_debug ( B0.rows() == dimx, "LQG: B is not compatible" ); 12 bdm_assert_debug ( C0.cols() == dimx, "LQG: C is not square" ); 13 14 A=A0; 15 B=B0; 16 C=C0; 5 void LQG::set_system(shared_ptr<StateSpace<fsqmat> > S0){ 6 S = S0; 7 dimx= S->_dimx(); 8 dimy= S->_dimy(); 9 dimu= S->_dimu(); 17 10 pr=zeros(dimx+dimu+dimy, dimu+dimx+dimu+dimy); 18 11 pr.set_submatrix(dimx, dimu+dimx, eye(dimu+dimy)); 19 12 } 20 13 21 void LQG::set_control_parameters(const mat &Qy0, const mat &Qu0, const vec y_req0, int horizon0){ 22 bdm_assert_debug ( Qy0.cols() == dimy, "LQG: wrong dimensions of Qy " ); 23 bdm_assert_debug ( Qu0.cols() == dimu, "LQG: wrong dimensions of Qu " ); 24 bdm_assert_debug ( y_req0.length() == dimy, "LQG: wrong dimensions of y_req " ); 25 14 void LQG::set_control_parameters(const mat &Qy0, const mat &Qu0, const vec &y_req0, int horizon0){ 26 15 Qy=Qy0; 27 16 Qu=Qu0; 28 17 y_req=y_req0; 29 18 horizon = horizon0; 30 prepare_qr(); 19 validate(); 20 initialize(); 31 21 } 32 22 33 void LQG::prepare_qr(){ 23 void LQG::validate() { 24 bdm_assert_debug ( Qy.cols() == dimy, "LQG: wrong dimensions of Qy " ); 25 bdm_assert_debug ( Qu.cols() == dimu, "LQG: wrong dimensions of Qu " ); 26 bdm_assert_debug ( y_req.length() == dimy, "LQG: wrong dimensions of y_req " ); 27 } 28 29 void LQG::initialize(){ 34 30 // set parameter matrix 35 pr.set_submatrix(0,0, B);36 pr.set_submatrix(0,dimu, A);31 pr.set_submatrix(0,0,S->_B()); 32 pr.set_submatrix(0,dimu, S->_A()); 37 33 38 34 //penalization … … 42 38 43 39 qyx=zeros(dimy, dimx+dimy+dimu); 44 qyx.set_submatrix(0,0, C);40 qyx.set_submatrix(0,0,S->_C()); 45 41 qyx.set_submatrix(0,dimx,-eye(dimy)); 46 42 47 43 // 48 s=1e-5*eye( 4);//dimx+dimu+dimy);44 s=1e-5*eye(dimx+dimu+dimy); 49 45 // parts of QR 50 46 hqy=Qy*qyx*pr;