Changeset 744 for applications
- Timestamp:
- 11/28/09 14:38:48 (15 years ago)
- Location:
- applications
- Files:
-
- 1 added
- 9 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/bdmtoolbox/Doxyfile
r613 r744 26 26 INLINE_INHERITED_MEMB = YES 27 27 FULL_PATH_NAMES = NO 28 STRIP_FROM_PATH = /home/smidl/ 28 STRIP_FROM_PATH = /home/smidl/work/git/mixpp 29 29 STRIP_FROM_INC_PATH = 30 30 SHORT_NAMES = NO … … 246 246 # configuration options related to the XML output 247 247 #--------------------------------------------------------------------------- 248 GENERATE_XML = yes248 GENERATE_XML = NO 249 249 XML_OUTPUT = xml 250 250 XML_SCHEMA = -
applications/bdmtoolbox/mex/controlloop.cpp
r723 r744 7 7 digraph estimation{ 8 8 node [shape=box]; 9 {rank="same"; "Data Source"; "Bayesian Model"} 10 "Data Source" -> "Bayesian Model" [label="data"]; 11 "Bayesian Model" -> "Result Logger" [label="estimated\n statistics"]; 9 subgraph cl0 { 10 "Data Source" -> "Controller" [label="observations"]; 11 "Controller" -> "Data Source" [label="actions"]; 12 } 13 {rank="same"; "Controller"; "Result Logger"} 14 "Controller" -> "Result Logger" [label="internals"]; 12 15 "Data Source" -> "Result Logger" [label="Simulated\n data"]; 13 16 } … … 87 90 if ( n_input>3 ) { 88 91 Cfg.addGroup ( input[3],"logger" ); 89 }/*else{ 90 // define logger as mexlog 91 Setting &S=Cfg.getRoot(); 92 S.add("logger",Setting::TypeGroup); 93 S["logger"].add("class",Setting::TypeString); 94 S["logger"]["class"]="mexlog"; 95 S["logger"].add("maxlen",Setting::TypeInt); 96 int maxlen; 97 S["experiment"].lookupValue("ndat",maxlen); 98 S["logger"]["maxlen"]=maxlen; 99 }*/ 92 } 100 93 } catch ( SettingException e ) { 101 94 it_error ( "error: "+string ( e.getPath() ) ); … … 116 109 #endif 117 110 111 RNG_randomize(); 112 118 113 shared_ptr<DS> Ds = UI::build<DS> ( Cfg, "system" ); 119 114 Array<shared_ptr<Controller> > Cs; 120 115 UI::get ( Cs,Cfg, "controllers" ); 121 116 int Ndat=100; 117 int burnin=10; 122 118 if ( Cfg.exists ( "experiment" ) ) { 123 119 if ( Cfg.getRoot().lookupValue ( "experiment.ndat",Ndat ) ) { … … 178 174 } 179 175 176 vec ut(Ds->_urv()._dsize()); 180 177 for ( int tK=0;tK<Ndat;tK++ ) { 181 178 Ds->getdata ( dt ); // read data … … 186 183 Cs(i) -> redesign(); 187 184 Cs(i) -> adapt( Dlsc(i) ->pushdown(dt)); 188 vec ut=Cs ( i )->ctrlaction ( Dlsc(i) ->pushdown(dt) ); // update estimates 189 Ds->write(ut, vec_1(0)); 185 } 186 if (tK > burnin){ 187 vec uti=Cs ( i )->ctrlaction ( Dlsc(i) ->pushdown(dt) ); // update estimates 188 Dlsu(i)->filldown(uti, ut); 190 189 } else { 191 Ds->write(0.001*randn(Ds->_urv()._dsize()));190 ut = 0.1*randn(Ds->_urv()._dsize()); 192 191 } 193 192 194 193 Cs ( i )->log_write (); 195 194 } 195 Ds->write(ut); 196 196 197 197 L->step(); -
applications/bdmtoolbox/tutorial/merging/merge_frag.m
r706 r744 16 16 Merger.ncoms=20; 17 17 Merger.stop_niter=50; 18 Merger.effss_coef= 1;18 Merger.effss_coef=0.9; 19 19 %Merger.dbg_file='merger_mix_dbg'; 20 20 … … 32 32 'R',1); 33 33 % 2D support 34 support2.grid={[-5,5],[0.001,9]}; 35 support2.nbins=[30,30]; 34 support2.class='rectangular_support'; 35 support2.ranges={[-5,5],[0.001,9]}; 36 support2.gridsizes=[30,30]; 36 37 37 38 % 2D -
applications/bdmtoolbox/tutorial/userguide/arx_ctrl_example.m
r724 r744 1 1 % name random variables 2 2 y = RV({'y'},1); 3 u = RV({'u'},1); 3 u1 = RV({'u1'},1); 4 u2 = RV({'u2'},1); 4 5 5 6 % create f(y_t| y_{t-3}, u_{t-1}) 6 7 fy.class = 'mlnorm<ldmat>'; 7 8 fy.rv = y; 8 fy.rvc = RVtimes([y,u ], [-3, -1]);9 fy.A = [0.5, -0.9 ];9 fy.rvc = RVtimes([y,u1,u2], [-3, 0, 0]); 10 fy.A = [0.5, -0.9, 0.9]; 10 11 fy.const = 0; 11 12 fy.R = 1e-2; … … 17 18 A1.class = 'ARX'; 18 19 A1.rv = y; 19 A1.rgr = RVtimes([y,u ],[-3,-1]) ; % correct structure is {y,y}20 A1.rgr = RVtimes([y,u1,u2],[-3,0,0]) ; % correct structure is {y,y} 20 21 A1.options ='logbounds,logll'; 21 22 22 23 C1.class = 'LQG_ARX'; 23 24 C1.ARX = A1; 24 C1.Qu = 0.1*eye( 1);25 C1.Qu = 0.1*eye(2); 25 26 C1.Qy = eye(1); 26 27 C1.yreq = 1; 27 28 C1.horizon = 100; 28 29 30 % participant 1 31 Cp1. 32 29 33 M= controlloop(DS,{C1}); -
applications/pmsm/CMakeLists.txt
r654 r744 33 33 #EXEC (sim_var pmsmsim) 34 34 35 #add_subdirectory (TR2245)35 add_subdirectory (TR2245) -
applications/pmsm/TR2245/CMakeLists.txt
r294 r744 2 2 EXEC (unitsteps pmsmsim) 3 3 EXEC (wishart pmsmsim) 4 EXEC (pmsm_wishart pmsmsim)4 #EXEC (pmsm_wishart pmsmsim) -
applications/pmsm/TR2245/unitsteps.cfg
r294 r744 1 1 ndat = 9000; 2 Npart = 100 0;2 Npart = 100; 3 3 4 4 //simulator 5 5 profile = [1,2,4,9,4,2,0,-4,-9,-16,-4,0,0]; 6 6 7 logger = { type="dirfilelog"; dirname="exp/unitstep"; maxlen=100;};7 logger = {class="dirfilelog"; dirname="kst/unitstep"; maxlen=100;}; 8 8 9 Qrw = { type="migamma_ref";10 ref = [1e- 6, 1e-6, 1e-3, 1e-4];9 Qrw = {class="migamma_ref"; 10 ref = [1e-4, 1e-4, 1e-3, 1e-4]; 11 11 l = 0.999; 12 k = 0. 1;12 k = 0.06; 13 13 }; 14 14 // For EKF 15 15 dQ=[1e-5, 1e-5, 1e-4, 1e-5]; 16 dR=[1e- 8, 1e-8];16 dR=[1e-10, 1e-10]; 17 17 -
applications/pmsm/TR2245/unitsteps.cpp
r706 r744 15 15 #include <estim/particles.h> 16 16 #include <estim/ekf_template.h> 17 #include < stat/functions.h>17 #include <base/loggers.h> 18 18 19 19 … … 21 21 #include "simulator.h" 22 22 #include "../sim_profiles.h" 23 #include "user_info.h"24 #include "stat/loggers.h"25 23 26 24 using namespace bdm; … … 41 39 F.lookupValue ( "ndat", Ndat ); 42 40 F.lookupValue ( "Npart",Npart ); 43 pdf*evolQ = UI::build<pdf>( F, "Qrw" );41 shared_ptr<pdf> evolQ = UI::build<pdf>( F, "Qrw" ); 44 42 vec Qdiag; 45 43 vec Rdiag; … … 49 47 // internal model 50 48 51 IMpmsm fxu;49 shared_ptr<IMpmsm> fxu= new IMpmsm; 52 50 // Rs Ls dt Fmag(Ypm) kp p J Bf(Mz) 53 fxu.set_parameters ( 0.28, 0.003465, Nsimstep*h, 0.1989, 1.5 ,4.0, 0.04, 0.0 );51 fxu->set_parameters ( 0.28, 0.003465, Nsimstep*h, 0.1989, 1.5 ,4.0, 0.04, 0.0 ); 54 52 // observation model 55 OMpmsm hxu;53 shared_ptr<OMpmsm> hxu=new OMpmsm; 56 54 57 55 vec mu0= "0.0 0.0 0.0 0.0"; … … 59 57 chmat R ( Rdiag ); 60 58 EKFCh KFE ; 61 KFE.set_parameters ( &fxu,&hxu,Q,R );62 KFE.set_ est( mu0, chmat ( zeros ( 4 ) ) );59 KFE.set_parameters ( fxu,hxu,Q,R ); 60 KFE.set_statistics ( mu0, chmat ( zeros ( 4 ) ) ); 63 61 KFE.set_rv ( rx ); 62 KFE.validate(); 64 63 65 64 RV rQ ( "{Q }","4" ); 65 RV rU ("{u }","2"); 66 RV rY ("{y }","2"); 66 67 EKFCh_dQ KFEp ; 67 KFEp.set_parameters ( &fxu,&hxu,Q,R ); 68 KFEp.set_est ( mu0, chmat ( zeros ( 4 ) ) ); 68 KFEp.set_parameters ( fxu,hxu,Q,R ); 69 KFEp.set_statistics ( mu0, chmat ( zeros ( 4 ) ) ); 70 KFEp.set_rv(rx); 71 KFEp.set_yrv(rY); 72 KFEp.set_rvc(concat(rU, rQ)); 73 KFEp.validate(); 69 74 70 MPF<EKFCh_dQ> M; 71 M.set_parameters ( evolQ,evolQ,Npart ); 72 // initialize 73 evolQ->condition ( 10*Qdiag ); //Zdenek default 74 M.set_statistics ( evolQ->_e() , &KFEp ); 75 // 75 MPF M; 76 evolQ->set_rv(rQ); 77 M.set_pf ( evolQ,Npart ); 78 M._pf().set_statistics(ones(Npart), euni(zeros(4),2*Qdiag)); 79 M.set_BM(KFEp); 80 M.set_yrv ( rY ); 81 M.set_rvc ( rU ); 82 M.validate(); 76 83 77 M.set_rv ( concat ( rQ,rx ) ); 78 79 dirfilelog *L = UI::build<dirfilelog>( F, "logger" );// ( "exp/mpf_test",100 ); 80 int l_X = L->add ( rx, "xt" ); 81 int l_D = L->add ( concat ( ry,ru ), "" ); 82 int l_Q= L->add ( rQ, "" ); 84 shared_ptr<dirfilelog> L = UI::build<dirfilelog>( F, "logger" );// ( "exp/mpf_test",100 ); 85 int l_X = L->add_vector ( rx, "xt" ); 86 int l_D = L->add_vector ( concat ( ry,ru ), "" ); 87 int l_Q= L->add_vector ( rQ, "" ); 83 88 84 89 KFE.set_options ( "logbounds" ); 85 KFE.log_ add( *L,"KF" );90 KFE.log_register ( *L,"KF" ); 86 91 M.set_options ( "logbounds" ); 87 M.log_ add( *L,"M" );92 M.log_register ( *L,"M" ); 88 93 L->init(); 89 94 … … 107 112 ut ( 0 ) = KalmanObs[4]; 108 113 ut ( 1 ) = KalmanObs[5]; 109 xt = fxu .eval ( xtm,ut ) + diag ( sqrt ( Qdiag ) ) *randn ( 4 );110 dt = hxu .eval ( xt,ut);114 xt = fxu->eval ( xtm,ut ) + diag ( sqrt ( Qdiag ) ) *randn ( 4 ); 115 dt = hxu->eval ( xt,ut ) + diag(sqrt(Rdiag))*randn(2); 111 116 xtm = xt; 112 117 … … 122 127 123 128 //estimator 124 KFE.bayes ( concat ( dt,ut ));125 M.bayes ( concat ( dt,ut ));129 KFE.bayes ( dt,ut ); 130 M.bayes ( dt,ut ); 126 131 127 L->log it( l_X,xt );128 L->log it( l_D,concat ( dt,ut ) );129 L->log it( l_Q,Qdiag );132 L->log_vector ( l_X,xt ); 133 L->log_vector ( l_D,concat ( dt,ut ) ); 134 L->log_vector ( l_Q,Qdiag ); 130 135 131 KFE.log it ( *L);132 M.log it ( *L);136 KFE.log_write ( ); 137 M.log_write ( ); 133 138 L->step(); 134 139 } … … 136 141 //Exit program: 137 142 138 delete L;139 143 return 0; 140 144 } -
applications/pmsm/pmsmDS.h
r686 r744 118 118 void log_register ( logger &L ) 119 119 { 120 L_x = L.add ( rx, "x" );121 L_oy = L.add ( ry, "o" );122 L_ou = L.add ( ru, "o" );123 L_iu = L.add ( ru, "t" );120 L_x = L.add_vector ( rx, "x" ); 121 L_oy = L.add_vector ( ry, "o" ); 122 L_ou = L.add_vector ( ru, "o" ); 123 L_iu = L.add_vector ( ru, "t" ); 124 124 // log differences 125 125 if ( opt_modu ) 126 126 { 127 L_optu = L.add ( ru, "model" );127 L_optu = L.add_vector ( ru, "model" ); 128 128 } 129 129 } … … 131 131 void log_write ( logger &L ) 132 132 { 133 L.log it( L_x, vec ( x,4 ) );134 L.log it( L_oy, vec_2 ( KalmanObs[2],KalmanObs[3] ) );135 L.log it( L_ou, vec_2 ( KalmanObs[0],KalmanObs[1] ) );136 L.log it( L_iu, vec_2 ( KalmanObs[4],KalmanObs[5] ) );133 L.log_vector ( L_x, vec ( x,4 ) ); 134 L.log_vector ( L_oy, vec_2 ( KalmanObs[2],KalmanObs[3] ) ); 135 L.log_vector ( L_ou, vec_2 ( KalmanObs[0],KalmanObs[1] ) ); 136 L.log_vector ( L_iu, vec_2 ( KalmanObs[4],KalmanObs[5] ) ); 137 137 if ( opt_modu ) 138 138 { … … 151 151 ua = ( 2.0* ( u1-du1 )- ( u2-du2 )- ( u3-du3 ) ) /3.0; 152 152 ub = ( ( u2-du2 )- ( u3-du3 ) ) /sq3; 153 L.log it( L_optu , vec_2 ( ua,ub ) );153 L.log_vector ( L_optu , vec_2 ( ua,ub ) ); 154 154 } 155 155 … … 238 238 void log_add(logger &L, const string &name="" ) 239 239 { 240 L_CRB=L.add (rx,"crb");241 L_err=L.add (rx,"err");242 L_sec=L.add (rx,"d2");240 L_CRB=L.add_vector(rx,"crb"); 241 L_err=L.add_vector(rx,"err"); 242 L_sec=L.add_vector(rx,"d2"); 243 243 } 244 244 void logit(logger &L) 245 245 { 246 L.log it(L_err, interr);247 L.log it(L_CRB,diag(_R()));248 L.log it(L_sec,secder);246 L.log_vector(L_err, interr); 247 L.log_vector(L_CRB,diag(_R())); 248 L.log_vector(L_sec,secder); 249 249 } 250 250 … … 322 322 void log_add(logger &L, const string &name="" ) 323 323 { 324 L_CRB=L.add (concat(rx,RV("Mz",1,0)),"crbz");324 L_CRB=L.add_vector(concat(rx,RV("Mz",1,0)),"crbz"); 325 325 } 326 326 void logit(logger &L) 327 327 { 328 L.log it(L_CRB,diag(_R()));328 L.log_vector(L_CRB,diag(_R())); 329 329 } 330 330