Changeset 744 for applications/bdmtoolbox/mex
- Timestamp:
- 11/28/09 14:38:48 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
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();