Changeset 895
- Timestamp:
- 04/08/10 16:01:03 (15 years ago)
- Files:
-
- 7 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/bdmtoolbox/tutorial/userguide/frg_estim.m
r871 r895 11 11 A1.rv = y; 12 12 A1.rgr = RVtimes([y,u],[-3,-1]) ; 13 A1.log_level = 'logbounds,logevidence';13 A1.log_level = 'logbounds,logevidence'; 14 14 A1.frg = 0.9; 15 15 A1.name = 'A1'; 16 16 17 17 18 %%%%%% Random walk on frg - Dirichlet … … 19 20 phi_pdf.rv = RV({'phi','1_phi'}); % 2D random walk - frg is the first element 20 21 phi_pdf.k = 0.01; % width of the random walk 21 phi_pdf.betac = [0.1 0.1]; % stabilizing elememnt of random walk22 phi_pdf.betac = [0.1 0.1]; % stabilizing elememnt of random walk 22 23 24 %%%%%% Particle 25 p.class = 'MarginalizedParticle'; 26 p.parameter_pdf = phi_pdf; % Random walk is the parameter evolution model 27 p.bm = A1; 28 29 % prior on ARX 23 30 %%%%%% Combining estimators in Marginalized particle filter 24 E.class = 'MPF'; 25 E.BM = A1; % ARX is the analytical part 26 E.parameter_pdf = phi_pdf; % Random walk is the parameter evolution model 31 E.class = 'PF'; 32 E.particle = p; % ARX is the analytical part 27 33 E.res_threshold = 1.0; % resampling parameter 28 34 E.n = 10; % number of particles 29 35 E.prior.class = 'eDirich'; % prior on non-linear part 30 36 E.prior.beta = [2 1]; % 31 E.log_level = 'logbounds,logevidence';37 E.log_level = 'logbounds,logevidence'; 32 38 E.name = 'MPF'; 33 39 -
applications/pmsm/pmsmDS.h
r894 r895 39 39 { 40 40 Dt=125; 41 Yrv=RV ( "{o_ua o_ub o_ia o_ib t_ua t_ub o_om o_th Mz }" ); 42 ytsize = Yrv._dsize(); 43 Drv = Yrv; 41 Drv=RV ( "{o_ua o_ub o_ia o_ib t_ua t_ub o_om o_th Mz }" ); 42 dtsize = Drv._dsize(); 44 43 } 45 44 void set_parameters ( double Rs0, double Ls0, double Fmag0, double Bf0, double p0, double kp0, double J0, double Uc0, double DT0, double dt0 ) -
library/bdm/base/bdmbase.h
r889 r895 915 915 //! size of data 916 916 int utsize; 917 //!size of output918 int ytsize;919 917 //!Description of data returned by \c getdata(). 920 918 RV Drv; 921 919 //!Description of data witten by by \c write(). 922 920 RV Urv; // 923 //!Description of output data924 RV Yrv; //925 921 public: 926 922 //! default constructors 927 DS() : dtsize ( 0 ), utsize ( 0 ), ytsize ( 0 ), Drv(), Urv(), Yrv(){923 DS() : dtsize ( 0 ), utsize ( 0 ), Drv(), Urv(){ 928 924 log_level[dt] = true; 929 925 }; … … 964 960 return Urv; 965 961 } 966 //!access function967 const RV& _yrv() const {968 return Yrv;969 }970 962 //! set random variables 971 virtual void set_drv ( const RV &yrv, const RV &urv ) { 972 Yrv = yrv; 973 Drv = concat ( yrv, urv ); 963 virtual void set_drv ( const RV &drv, const RV &urv) { 964 Drv = drv; 974 965 Urv = urv; 975 966 } -
library/bdm/base/datasources.cpp
r892 r895 63 63 64 64 void PdfDS::getdata ( vec &dt_out ) const { 65 bdm_assert_debug ( dt_out.length() >= utsize + ytsize, "Short output vector" );65 bdm_assert_debug ( dt_out.length() >= dtsize, "Short output vector" ); 66 66 dt_out.set_subvector ( 0, yt ); 67 dt_out.set_subvector ( yt size, ut );67 dt_out.set_subvector ( yt.length(), ut ); 68 68 } 69 69 … … 82 82 dt.set_subvector ( 0, yt ); 83 83 dt.set_subvector ( yt.length(), xt ); 84 dt.set_subvector ( yt size, ut );84 dt.set_subvector ( yt.length()+xt.length(), ut ); 85 85 } 86 86 … … 99 99 DS::validate(); 100 100 101 Yrv = concat ( OM->_rv() , IM->_rv() ); // export also true state102 ytsize = Yrv._dsize();101 RV Yrv = concat ( OM->_rv() , IM->_rv() ); // export also true state 102 int ytsize = Yrv._dsize(); 103 103 104 104 RV tmp = concat ( OM->_rvc(), IM->_rvc() ); // what i not in rvc -
library/bdm/base/datasources.h
r892 r895 97 97 set_drv ( *r, RV() ); //empty urv 98 98 dtsize = r->_dsize(); 99 ytsize = dtsize;100 99 utsize = 0; 101 100 } … … 219 218 dt = zeros ( iepdf->dimension() ); 220 219 dtsize = dt.length(); 221 ytsize = dt.length();222 220 set_drv ( iepdf->_rv(), RV() ); 223 221 utsize = 0; … … 281 279 ipdf = UI::build<pdf> ( set, "pdf", UI::compulsory ); 282 280 283 Yrv = ipdf->_rv();281 RV Yrv = ipdf->_rv(); 284 282 // get unique rvs form rvc 285 283 RV rgrv0 = ipdf->_rvc().remove_time(); 286 284 // input is what in not in Yrv 287 285 Urv = rgrv0.subt ( Yrv ); 288 set_drv ( Yrv, Urv );286 set_drv ( concat(Yrv,Urv), Urv ); 289 287 // connect input and output to rvc 290 288 ut2rgr.set_connection ( ipdf->_rvc(), Urv ); … … 308 306 ut = zeros ( Urv._dsize() ); 309 307 310 ytsize = yt.length();311 308 utsize = ut.length(); 312 dtsize = yt size+ utsize;309 dtsize = yt.length() + utsize; 313 310 } 314 311 -
library/bdm/mex/mex_datasource.h
r766 r895 45 45 rowid = linspace ( 0, Data.rows() - 1 ); 46 46 dtsize = rowid.length(); 47 ytsize = rowid.length();48 47 utsize = 0; 49 48 … … 87 86 mexDS () : DS() {}; 88 87 89 /*! \brief Create memory data source from mxArray88 /*! \brief Data source computed by matlab function 90 89 91 90 \code … … 94 93 step_name=""; // name of function to call 95 94 input_name=""; // name of workspace variable where inputs are written 96 yrv = {class='RV',...} // identification of outputs95 drv = {class='RV',...} // identification of outputs 97 96 urv = {class='RV',...} // identification of inputs 98 97 }; … … 106 105 UI::get ( input_name, set, "input_name", UI::compulsory ); 107 106 108 shared_ptr<RV> r y = UI::build<RV> ( set, "yrv", UI::compulsory );107 shared_ptr<RV> rd = UI::build<RV> ( set, "drv", UI::compulsory ); 109 108 shared_ptr<RV> ru = UI::build<RV> ( set, "urv", UI::compulsory ); 110 109 111 ytsize = ry->_dsize();110 dtsize = rd->_dsize(); 112 111 utsize = ru->_dsize(); 113 dtsize = ytsize + utsize;114 112 115 set_drv ( *r y, *ru );113 set_drv ( *rd, *ru ); 116 114 validate(); 117 115 } … … 142 140 mexCallMATLAB ( 1, &tmp, 0, ( mxArray ** ) &dummy, step_name.c_str() ); 143 141 // save its results 144 bdm_assert_debug ( ( int ) mxGetM ( tmp ) == ytsize || ( int ) mxGetN ( tmp ) == ytsize, "mexDS.step() expected return vector of length " + num2str ( dtsize ) +142 bdm_assert_debug ( ( int ) mxGetM ( tmp ) == dtsize || ( int ) mxGetN ( tmp ) == dtsize, "mexDS.step() expected return vector of length " + num2str ( dtsize ) + 145 143 "got vector " + num2str ( ( int ) mxGetM ( tmp ) ) + "x" + num2str ( ( int ) mxGetN ( tmp ) ) ); 146 144 //write y 147 145 dt.set_subvector ( 0, mxArray2vec ( tmp ) ); 148 146 //write u 149 dt.set_subvector ( ytsize, ut );150 147 } 151 148 void write ( const vec &ut0 ) { -
library/bdm/mex/mex_logger.h
r737 r895 62 62 istart = 0; 63 63 for ( int j = 0; j < entries ( i ).length(); j++ ) { // same for as in add!!! 64 vec_name = names ( i ) + prefix_sep()+ entries ( i ).name ( j );64 vec_name = names ( i ) + "_" + entries ( i ).name ( j ); 65 65 iend = istart + entries ( i ).size ( j ) - 1; 66 66 M = vectors ( i ).get_cols ( istart, iend );