Changeset 764
- Timestamp:
- 01/11/10 14:39:47 (15 years ago)
- Location:
- applications/bdmtoolbox
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/bdmtoolbox/mex/controlloop.cpp
r744 r764 70 70 // Check the number of inputs and output arguments 71 71 if ( n_input<2 ) mexErrMsgTxt ( "Usage:\n" 72 "result= estimator(system, estimators, experiment, logger)\n"72 "result=controlloop(system, controllers, experiment, logger)\n" 73 73 " system = struct('class','datasource',...); % Estimated system\n" 74 " estimators = {struct('class','estimator',...), % Estimators\n"75 " struct('class',' estimator',...),...} \n"74 " controllers= {struct('class','controller',...), % Controllers\n" 75 " struct('class','controller',...),...} \n" 76 76 " === optional ===" 77 " experiment = struct('ndat',10); % number of data in experiment, full length of finite datasources, 10 otherwise \n" 77 " experiment = struct('ndat',100,... % number of data in experiment, full length of finite datasources, 100 otherwise \n" 78 " 'burnin',10,... % initial time with different control\n" 79 " 'burn_pdf', struct('class','epdf_offspring') );\n" 80 " % sampler of the initial control\n" 78 81 " logger = struct('class','mexlogger'); % How to store results, default=mexlog, i.e. matlab structure\n\n" 79 82 "see documentation of classes datasource, BM, and mexlogger and their offsprings in BDM." ); … … 115 118 UI::get ( Cs,Cfg, "controllers" ); 116 119 int Ndat=100; 117 int burnin=10; 120 int burnin=0; 121 shared_ptr<epdf> burn_pdf; 122 118 123 if ( Cfg.exists ( "experiment" ) ) { 119 if ( Cfg.getRoot().lookupValue ( "experiment.ndat",Ndat ) ) { 124 Setting &exper=Cfg.getRoot()["experiment"]; 125 if (UI::get(Ndat, exper, "Ndat", UI::optional ) ) { 120 126 bdm_assert ( Ndat<=Ds->max_length(), "Data source has less data then required" ); 121 127 }; 128 if (UI::get(burnin, exper, "burnin",UI::optional )){ 129 burn_pdf = UI::build<epdf>(exper,"burn_pdf", UI::compulsory); 130 if (burn_pdf){ 131 bdm_assert(burn_pdf->dimension()==Ds->_urv()._dsize(),"Given burn_pdf does not match the DataSource"); 132 } else { 133 bdm_error("burn_pdf not specified!"); 134 } 135 136 } 122 137 } else { 123 138 if ( Ds->max_length() < std::numeric_limits< int >::max() ) { … … 183 198 Cs(i) -> redesign(); 184 199 Cs(i) -> adapt( Dlsc(i) ->pushdown(dt)); 200 if (tK >= burnin){ 201 vec uti=Cs ( i )->ctrlaction ( Dlsc(i) ->pushdown(dt) ); // update estimates 202 Dlsu(i)->filldown(uti, ut); 203 } 185 204 } 186 if (tK > burnin){ 187 vec uti=Cs ( i )->ctrlaction ( Dlsc(i) ->pushdown(dt) ); // update estimates 188 Dlsu(i)->filldown(uti, ut); 189 } else { 190 ut = 0.1*randn(Ds->_urv()._dsize()); 205 if(tK<burnin) { 206 ut = burn_pdf->sample(); 191 207 } 192 208 -
applications/bdmtoolbox/tutorial/userguide/dist_ctrl_example.m
r744 r764 36 36 C2.ARX = A2; 37 37 38 M= controlloop(DS,{C1,C2}); 38 exper.Ndat=100; 39 exper.burnin=3; 40 exper.burn_pdf.class='enorm<chmat>'; 41 exper.burn_pdf.mu=[0,0]; 42 exper.burn_pdf.R=0.1*eye(2); 43 44 45 M= controlloop(DS,{C1,C2},exper); 39 46 40 47