Changeset 508 for library/bdm/design/ctrlbase.cpp
- Timestamp:
- 08/12/09 16:47:33 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/design/ctrlbase.cpp
r491 r508 1 #include <ctrlbase.h>1 #include "ctrlbase.h" 2 2 3 LQG::set_system_parameters(const mat &A0, const mat &B0, const mat &C0){ 3 namespace bdm{ 4 5 void LQG::set_system_parameters(const mat &A0, const mat &B0, const mat &C0){ 4 6 dimx = A0.rows(); 5 7 dimy = C0.rows(); … … 13 15 B=B0; 14 16 C=C0; 15 16 // set temporary stuff; 17 pr = concat_vertical( 18 concat_horizontal(B,A, zeros(dimx, dimu+dimy)), 19 concat_horizontal(zeros(dimu+dimy,dimu+dimx), eye(dimu+dimy))); 17 pr=zeros(dimx+dimu+dimy, dimu+dimx+dimu+dimy); 18 pr.set_submatrix(dimx, dimu+dimx, eye(dimu+dimy)); 19 } 20 21 void LQG::set_control_parameters(const mat &Qy0, const mat &Qu0, const vec y_req0, int horizon0){ 22 it_assert_debug ( Qy0.cols() == dimy, "LQG: wrong dimensions of Qy " ); 23 it_assert_debug ( Qu0.cols() == dimu, "LQG: wrong dimensions of Qu " ); 24 it_assert_debug ( y_req0.length() == dimy, "LQG: wrong dimensions of y_req " ); 25 26 Qy=Qy0; 27 Qu=Qu0; 28 y_req=y_req0; 29 horizon = horizon0; 30 prepare_qr(); 31 } 32 33 void LQG::prepare_qr(){ 34 // set parameter matrix 35 pr.set_submatrix(0,0,B); 36 pr.set_submatrix(0,dimu, A); 20 37 21 38 //penalization … … 24 41 qux.set_submatrix(0,dimx+dimu+dimy,Qu); 25 42 26 qyx=concat_horizontal(C,-eye(dimy),zeros(dimy,dimu)); 43 qyx=zeros(dimy, dimx+dimy+dimu); 44 qyx.set_submatrix(0,0,C); 45 qyx.set_submatrix(0,dimx,-eye(dimy)); 27 46 28 47 // 29 s=1e-5*eye( dimx+dimu+dimy);48 s=1e-5*eye(4);//dimx+dimu+dimy); 30 49 // parts of QR 31 50 hqy=Qy*qyx*pr; 32 51 33 52 // pre_qr 34 pre_qr = concat_vertical(s*pr, hqy, qux);35 53 pre_qr = concat_vertical(s*pr, concat_vertical(hqy, qux)); 54 post_qr = zeros(pre_qr.rows(), pre_qr.cols()); 36 55 } 56 57 }