Changeset 586 for library/bdm/design/ctrlbase.h
- Timestamp:
- 08/27/09 15:39:35 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/design/ctrlbase.h
r565 r586 12 12 13 13 #include "../base/bdmbase.h" 14 #include "../estim/kalman.h" 14 15 15 16 namespace bdm{ 16 17 17 //! Base class of designers of control strategy 18 class Designer : public root { 18 //! Low-level class for design of control strategy 19 class Designer { 20 19 21 public: 20 22 //! Redesign control strategy … … 34 36 class LQG : public Designer { 35 37 protected: 36 //! dimension of state 37 int dimx; 38 //! dimension of inputs 39 int dimu; 40 //! dimension of output 41 int dimy; 42 43 //! matrix A of the linear system 44 mat A; 45 //! matrix B of the linear system 46 mat B; 47 //! matrix C of the linear system 48 mat C; 38 //! StateSpace model from which we read data 39 shared_ptr<StateSpace<fsqmat> > S; 49 40 //! required value of the output y at time t (assumed constant) 50 41 vec y_req; 42 //! required value of the output y at time t (assumed constant) 43 vec u_req; 51 44 52 45 //! Control horizon, set to maxint for infinite horizons … … 61 54 mat L; 62 55 63 //!@{ \name temporary storage for ricatti 56 //!@{ \name temporary storage for ricatti - use initialize 57 //! convenience parameters 58 int dimx; 59 //! convenience parameters 60 int dimy; 61 //! convenience parameters 62 int dimu; 63 64 64 //! parameters 65 65 mat pr; … … 82 82 public: 83 83 //! set system parameters from given matrices 84 void set_system _parameters(const mat &A, const mat &B, const mat &C);84 void set_system(shared_ptr<StateSpace<fsqmat> > S0); 85 85 //! set penalization matrices and control horizon 86 void set_control_parameters(const mat &Qy0, const mat &Qu0, const vec y_req0, int horizon0);86 void set_control_parameters(const mat &Qy0, const mat &Qu0, const vec &y_req0, int horizon0); 87 87 //! set system parameters from Kalman filter 88 88 // void set_system_parameters(const Kalman &K); 89 89 //! refresh temporary storage - inefficient can be improved 90 void prepare_qr(); 91 //! function for future use which is called at each time td; Should call prepare_qr()! 90 void initialize(); 91 void validate(); 92 //! function for future use which is called at each time td; Should call initialize()! 92 93 virtual void update_state(){}; 93 94 //! redesign one step of the … … 113 114 } ; 114 115 116 //! Base class for adaptive controllers 117 //! The base class is however non-adaptive, method \c adapt() is empty. 118 //! \note advanced Controllers will probably include estimator as their internal attribute (e.g. dual controllers) 119 class Controller : public root { 120 //! identifier of the system output; 121 RV yrv; 122 //! identifier of the system input; 123 RV urv; 124 //! description of data needed for \c ctrlaction , required for automatic connection to DS 125 RV drv; 126 public: 127 //! function processing new observations and adapting control strategy accordingly 128 virtual void adapt(const vec &data){}; 129 //! returns designed control action 130 virtual vec ctrlaction(const vec &data){return vec(0);} 131 132 void from_setting(const Setting &set){ 133 UI::get(yrv,set,"yrv",UI::optional); 134 UI::get(yrv,set,"urv",UI::optional); 135 } 136 //! access function 137 const RV& _urv() {return urv;} 138 //! access function 139 const RV& _yrv() {return yrv;} 140 //! access function 141 const RV& _drv() {return drv;} 142 }; 143 115 144 } // namespace