- Timestamp:
- 07/09/10 12:39:41 (15 years ago)
- Location:
- library
- Files:
-
- 1 added
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/design/ctrlbase.h
r1064 r1130 20 20 //! \note advanced Controllers will probably include estimator as their internal attribute (e.g. dual controllers) 21 21 class Controller : public root { 22 protected:22 public: 23 23 //! identifier of the designed action; 24 24 RV rv; 25 protected: 25 26 //! identifier of the conditioning variables - data needed ; 26 27 RV rvc; -
library/bdm/math/functions.h
r1064 r1130 38 38 //! Class representing function \f$f(x) = Ax+B\f$ 39 39 class linfn: public fnc { 40 public: 40 41 //! Identification of \f$x\f$ 41 42 RV rv; … … 53 54 //!default constructor 54 55 linfn ( ) : fnc(), A ( ), B () { }; 56 linfn ( const mat &A0, const vec &B0 ) : fnc(), A (A0 ), B (B0) { }; 55 57 //! Set values of \c A and \c B 56 58 void set_parameters ( const mat &A0 , const vec &B0 ) { … … 70 72 UIREGISTER(linfn); 71 73 74 75 //! Class representing function \f$ f(x) = [x' 1] Q [x' 1]' \f$ with Q in choleski decomposition 76 class quadraticfn: public fnc { 77 public : 78 //! Identification of \f$x\f$ 79 RV rv; 80 //! Matrix Q 81 chmat Q; 82 83 84 vec eval ( const vec &cond ) { 85 bdm_assert_debug ( cond.length() == Q.cols(), "quadraticfc::eval Wrong cond." ); 86 return vec_1( Q.qform(concat(cond,1.0)) ); 87 } 88 89 void from_setting(const Setting &set) { 90 // UI::get(Q,set,"Q",UI::compulsory); 91 } 92 void validate() { 93 dimy = 1; 94 dimc = Q.cols()-1; 95 } 96 97 }; 98 UIREGISTER(quadraticfn); 72 99 73 100 /*! -
library/tests/testsuite/LQG_test.cpp
r1064 r1130 1 1 #define BDMLIB 2 2 #include "../mat_checks.h" 3 #include "design/ ctrlbase.h"3 #include "design/lq_ctrl.h" 4 4 5 5 using namespace bdm; … … 91 91 cout << L.to_string() << endl; 92 92 } 93 94 TEST (quadratic_test){ 95 quadraticfn qf; 96 qf.Q = chmat(2); 97 qf.Q._Ch() = mat("1 -1 0; 0 0 0; 0 0 0"); 98 CHECK_CLOSE_EX(qf.eval(vec("1 2")), vec_1(1.0), 0.0000000000000001); 99 100 LQG_universal lq; 101 lq.Losses = Array<quadraticfn>(1); 102 lq.Losses(0) = quadraticfn(); 103 lq.Losses(0).Q._Ch() = mat("1 -1 0; 0 0 0; 0 0 0"); 104 lq.Losses(0).rv = RV("{u up }"); 105 106 lq.Models = Array<linfn>(1); 107 lq.Models(0) = linfn(mat("1"),vec("1")); 108 lq.Models(0).rv = RV("{x }"); 109 110 lq.rv = RV("u",1); 111 112 lq.redesign(); 113 CHECK_CLOSE_EX(lq.ctrlaction(vec("1,0")), vec("1.24, -5.6"), 0.0000001); 114 }