11 | | stsp-> set_parameters ( eye ( 2 ), ones ( 2, 1 ), ones ( 1, 2 ), ones ( 1, 1 ), /* Q,R */ eye ( 2 ), eye ( 1 ) ); |
12 | | reg.set_system ( stsp ); // A, B, C |
13 | | reg.set_control_parameters ( eye ( 1 ), eye ( 1 ), vec_1 ( 1.0 ), 6 ); //Qy, Qu, horizon |
| 11 | stsp-> set_parameters(eye(2), ones(2,1), ones(1,2), ones(1,1), /* Q,R */ eye(2), eye(1)); |
| 12 | reg.set_system(stsp); // A, B, C |
| 13 | reg.set_control_parameters(eye(1), eye(1), vec_1(1.0), 6); //Qy, Qu, horizon |
| 14 | reg.validate(); |
22 | | mat A = "1.1, 2.3"; |
23 | | ml.set_parameters ( A, vec_1 ( 1.3 ), eye ( 1 ) ); |
24 | | RV yr = RV ( "y", 1 ); |
25 | | RV ur = RV ( "u", 1 ); |
26 | | ml.set_rv ( yr ); |
27 | | yr.t_plus ( -1 ); |
28 | | ml.set_rvc ( concat ( yr, ur ) ); |
29 | | |
30 | | shared_ptr<StateCanonical > Stsp = new StateCanonical; |
31 | | Stsp->connect_mlnorm ( ml ); |
32 | | |
33 | | /* results from |
| 23 | mat A="1.1, 2.3"; |
| 24 | ml.set_parameters(A, vec_1(1.3), eye(1)); |
| 25 | RV yr=RV("y",1); |
| 26 | RV ur=RV("u",1); |
| 27 | ml.set_rv(yr); |
| 28 | yr.t_plus(-1); |
| 29 | ml.set_rvc(concat(yr, ur)); |
| 30 | |
| 31 | shared_ptr<StateCanonical > Stsp=new StateCanonical; |
| 32 | Stsp->connect_mlnorm(ml); |
| 33 | |
| 34 | /* results from |
36 | | CHECK_CLOSE_EX ( Stsp->_A().get_row ( 0 ), vec ( "1.1" ), 0.0001 ); |
37 | | CHECK_CLOSE_EX ( Stsp->_C().get_row ( 0 ), vec ( "2.53" ), 0.0001 ); |
38 | | CHECK_CLOSE_EX ( Stsp->_D().get_row ( 0 ), vec ( "2.30" ), 0.0001 ); |
| 37 | CHECK_CLOSE_EX(Stsp->_A().get_row(0), vec("1.1"), 0.0001); |
| 38 | CHECK_CLOSE_EX(Stsp->_C().get_row(0), vec("2.53"), 0.0001); |
| 39 | CHECK_CLOSE_EX(Stsp->_D().get_row(0), vec("2.30"), 0.0001); |
41 | | TEST ( to_state_arx_test ) { |
42 | | mlnorm<fsqmat> ml; |
43 | | mat A = "1.1, 2.3"; |
44 | | ml.set_parameters ( A, vec_1 ( 1.3 ), eye ( 1 ) ); |
45 | | RV yr = RV ( "y", 1 ); |
46 | | RV ur = RV ( "u", 1 ); |
47 | | ml.set_rv ( yr ); |
48 | | yr.t_plus ( -1 ); |
49 | | ml.set_rvc ( concat ( yr, ur ) ); |
50 | | |
51 | | shared_ptr<StateFromARX> Stsp = new StateFromARX; |
52 | | Stsp->connect_mlnorm ( ml ); |
53 | | |
54 | | /* results from |
| 42 | TEST(to_state_arx_test) { |
| 43 | mlnorm<chmat> ml; |
| 44 | mat A="1.1, 2.3, 3.4"; |
| 45 | ml.set_parameters(A, vec_1(1.3), eye(1)); |
| 46 | RV yr=RV("y",1); |
| 47 | RV ur=RV("u",1); |
| 48 | ml.set_rv(yr); |
| 49 | ml.set_rvc(concat(yr.copy_t(-1), concat(ur, ur.copy_t(-1)))); |
| 50 | |
| 51 | shared_ptr<StateFromARX> Stsp=new StateFromARX; |
| 52 | RV xrv; RV urv; |
| 53 | Stsp->connect_mlnorm(ml,xrv,urv); |
| 54 | |
| 55 | /* results from |
60 | | TEST ( arx_LQG_test ) { |
61 | | mlnorm<fsqmat> ml; |
62 | | mat A = "1.81, -.8189, .00468, .00438"; |
63 | | ml.set_parameters ( A, vec_1 ( 0.0 ), 0.00001*eye ( 1 ) ); |
64 | | RV yr = RV ( "y", 1 ); |
65 | | RV ur = RV ( "u", 1 ); |
66 | | RV rgr = yr.copy_t ( -1 ); |
67 | | rgr.add ( yr.copy_t ( -2 ) ); |
68 | | rgr.add ( yr.copy_t ( -2 ) ); |
69 | | rgr.add ( ur.copy_t ( -2 ) ); |
70 | | rgr.add ( ur.copy_t ( -1 ) ); |
71 | | |
72 | | ml.set_rv ( yr ); |
73 | | ml.set_rvc ( rgr ); |
| 63 | TEST(arx_LQG_test){ |
| 64 | mlnorm<chmat> ml; |
| 65 | mat A="1.81, -.81, .00468, .00438"; |
| 66 | ml.set_parameters(A, vec_1(0.0), 0.00001*eye(1)); |
| 67 | RV yr=RV("y",1); |
| 68 | RV ur=RV("u",1); |
| 69 | RV rgr = yr.copy_t(-1); |
| 70 | rgr.add(yr.copy_t(-2)); |
| 71 | rgr.add(yr.copy_t(-2)); |
| 72 | rgr.add(ur.copy_t(-1)); |
| 73 | rgr.add(ur); |
| 74 | |
| 75 | ml.set_rv(yr); |
| 76 | ml.set_rvc(rgr); |