Show
Ignore:
Timestamp:
11/15/09 23:02:02 (15 years ago)
Author:
smidl
Message:

Big commit of LQG stuff

Files:
1 modified

Legend:

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

    r706 r723  
    33namespace bdm{ 
    44 
    5 void LQG::set_system(shared_ptr<StateSpace<fsqmat> > S0){ 
     5void LQG::set_system(shared_ptr<StateSpace<chmat> > S0){ 
    66        S = S0; 
    7         dimx= S->_A().rows(); 
    8         dimy= S->_C().rows(); 
    9         dimu= S->_B().cols(); 
    10         pr=zeros(dimx+dimu+dimy,  dimu+dimx+dimu+dimy); 
    11         pr.set_submatrix(dimx, dimu+dimx, eye(dimu+dimy)); 
    127} 
    138 
     
    1712        y_req=y_req0; 
    1813        horizon = horizon0; 
    19         validate(); 
    20         initialize(); 
    2114} 
    2215 
    2316void LQG::validate() { 
     17        // set properties from S 
     18        dimx= S->_A().rows(); 
     19        dimy= S->_C().rows(); 
     20        dimu= S->_B().cols(); 
     21        pr=zeros(dimx+dimu+dimy,  dimu+dimx+dimu+dimy); 
     22        pr.set_submatrix(dimx, dimu+dimx, eye(dimu+dimy)); 
     23         
     24        //penalization 
    2425        bdm_assert ( Qy.cols() == dimy, "LQG: wrong dimensions of Qy " ); 
    2526        bdm_assert ( Qu.cols() == dimu, "LQG: wrong dimensions of Qu " ); 
    2627        bdm_assert ( y_req.length() == dimy, "LQG: wrong dimensions of y_req " ); 
     28         
     29        qux=zeros(dimu,dimx+2*dimu+dimy);      
     30        qyx=zeros(dimy, dimx+dimy+dimu); 
     31         
     32        // 
     33        initial_belmann(); 
     34        // parts of QR 
     35        post_qr = zeros(pre_qr.rows(), pre_qr.cols()); 
     36         
     37        update_system(); 
    2738} 
    2839 
    29 void LQG::initialize(){ 
    30         // set parameter matrix 
    31         pr.set_submatrix(0,0,S->_B()); 
    32         pr.set_submatrix(0,dimu, S->_A()); 
    33          
    34         //penalization 
    35         qux=zeros(dimu,dimx+2*dimu+dimy);      
    36         qux.set_submatrix(0,0,Qu); 
    37         qux.set_submatrix(0,dimx+dimu+dimy,Qu); 
    38  
    39         qyx=zeros(dimy, dimx+dimy+dimu); 
    40         qyx.set_submatrix(0,0,S->_C()); 
    41         qyx.set_submatrix(0,dimx,-eye(dimy)); 
    42          
    43         // 
    44         s=1e-5*eye(dimx+dimu+dimy); 
    45         // parts of QR 
    46         hqy=Qy*qyx*pr; 
    47          
    48         // pre_qr 
    49         pre_qr = concat_vertical(s*pr, concat_vertical(hqy, qux)); 
    50         post_qr = zeros(pre_qr.rows(), pre_qr.cols()); 
    51 } 
    5240 
    5341}