Show
Ignore:
Timestamp:
08/27/09 15:39:35 (15 years ago)
Author:
smidl
Message:

redesign of ctrl LQ control for arx

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/design/ctrlbase.cpp

    r565 r586  
    33namespace bdm{ 
    44 
    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; 
     5void LQG::set_system(shared_ptr<StateSpace<fsqmat> > S0){ 
     6        S = S0; 
     7        dimx= S->_dimx(); 
     8        dimy= S->_dimy(); 
     9        dimu= S->_dimu(); 
    1710        pr=zeros(dimx+dimu+dimy,  dimu+dimx+dimu+dimy); 
    1811        pr.set_submatrix(dimx, dimu+dimx, eye(dimu+dimy)); 
    1912} 
    2013 
    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  
     14void LQG::set_control_parameters(const mat &Qy0, const mat &Qu0, const vec &y_req0, int horizon0){ 
    2615        Qy=Qy0; 
    2716        Qu=Qu0; 
    2817        y_req=y_req0; 
    2918        horizon = horizon0; 
    30         prepare_qr(); 
     19        validate(); 
     20        initialize(); 
    3121} 
    3222 
    33 void LQG::prepare_qr(){ 
     23void 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 
     29void LQG::initialize(){ 
    3430        // 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()); 
    3733         
    3834        //penalization 
     
    4238 
    4339        qyx=zeros(dimy, dimx+dimy+dimu); 
    44         qyx.set_submatrix(0,0,C); 
     40        qyx.set_submatrix(0,0,S->_C()); 
    4541        qyx.set_submatrix(0,dimx,-eye(dimy)); 
    4642         
    4743        // 
    48         s=1e-5*eye(4);//dimx+dimu+dimy); 
     44        s=1e-5*eye(dimx+dimu+dimy); 
    4945        // parts of QR 
    5046        hqy=Qy*qyx*pr;