root/library/bdm/design/ctrlbase.cpp @ 679

Revision 679, 1.2 kB (checked in by smidl, 15 years ago)

Major changes in BM -- OK is only test suite and tests/tutorial -- the rest is broken!!!

Line 
1#include "ctrlbase.h"
2
3namespace bdm{
4
5void LQG::set_system(shared_ptr<StateSpace<fsqmat> > S0){
6        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));
12}
13
14void LQG::set_control_parameters(const mat &Qy0, const mat &Qu0, const vec &y_req0, int horizon0){
15        Qy=Qy0;
16        Qu=Qu0;
17        y_req=y_req0;
18        horizon = horizon0;
19        validate();
20        initialize();
21}
22
23void LQG::validate() {
24        bdm_assert ( Qy.cols() == dimy, "LQG: wrong dimensions of Qy " );
25        bdm_assert ( Qu.cols() == dimu, "LQG: wrong dimensions of Qu " );
26        bdm_assert ( y_req.length() == dimy, "LQG: wrong dimensions of y_req " );
27}
28
29void 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}
52
53}
Note: See TracBrowser for help on using the browser.