Changeset 727 for library/bdm/base
- Timestamp:
- 11/17/09 00:54:12 (15 years ago)
- Location:
- library/bdm/base
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/base/bdmbase.h
r723 r727 319 319 //!separator of prefixes of entries 320 320 const string separator; 321 //! Root Setting for storing Settings 322 Config setting_conf; 323 //! list of Settings for specific ids 324 Array<Setting*> settings; 321 325 public: 322 326 //!Default constructor … … 325 329 //! returns an identifier which will be later needed for calling the \c logit() function 326 330 //! For empty RV it returns -1, this entry will be ignored by \c logit(). 327 virtual int add ( const RV &rv, string prefix = "" ) {331 virtual int add_vector ( const RV &rv, string prefix = "" ) { 328 332 int id; 329 333 if ( rv._dsize() > 0 ) { … … 337 341 return id; // identifier of the last entry 338 342 } 343 virtual int add_setting(const string &prefix){ 344 Setting &root=setting_conf.getRoot(); 345 int id=root.getLength(); //root must be group!! 346 if (prefix.length()>0){ 347 settings.set_length(id+1,true); 348 settings(id) = &root.add(prefix, Setting::TypeList); 349 } else {id=-1;} 350 return id; 351 } 339 352 340 353 //! log this vector 341 virtual void log it( int id, const vec &v ) {354 virtual void log_vector ( int id, const vec &v ) { 342 355 bdm_error ( "Not implemented" ); 343 356 }; 357 358 virtual Setting & log_to_setting (int id){ 359 return settings(id)->add(Setting::TypeGroup); 360 } 361 344 362 //! log this double 345 363 virtual void logit ( int id, const double &d ) { … … 595 613 logrec->ids.set_size(3); 596 614 if (log_level >0){ 597 logrec->ids(0) = logrec->L.add ( r, prefix + logrec->L.prefix_sep()+ "mean" );615 logrec->ids(0) = logrec->L.add_vector ( r, prefix + logrec->L.prefix_sep()+ "mean" ); 598 616 } 599 617 if (log_level >1){ 600 logrec->ids(1) = logrec->L.add ( r, prefix + logrec->L.prefix_sep()+ "lb" );601 logrec->ids(2) = logrec->L.add ( r, prefix + logrec->L.prefix_sep()+ "ub" );618 logrec->ids(1) = logrec->L.add_vector ( r, prefix + logrec->L.prefix_sep()+ "lb" ); 619 logrec->ids(2) = logrec->L.add_vector ( r, prefix + logrec->L.prefix_sep()+ "ub" ); 602 620 } 603 621 } 604 622 void log_write() const { 605 623 if (log_level>0) { 606 logrec->L.log it( logrec->ids(0), mean() );624 logrec->L.log_vector( logrec->ids(0), mean() ); 607 625 } 608 626 if (log_level>1) { 609 627 vec lb; vec ub; 610 628 qbounds(lb,ub); 611 logrec->L.log it( logrec->ids(1), lb );612 logrec->L.log it( logrec->ids(2), ub );629 logrec->L.log_vector( logrec->ids(1), lb ); 630 logrec->L.log_vector( logrec->ids(2), ub ); 613 631 } 614 632 } … … 1013 1031 if (log_level >0){ 1014 1032 logrec->ids.set_size(2); 1015 logrec->ids(0) = logrec->L.add ( Yrv, prefix );1016 logrec->ids(1) = logrec->L.add ( Urv, prefix );1033 logrec->ids(0) = logrec->L.add_vector ( Yrv, prefix ); 1034 logrec->ids(1) = logrec->L.add_vector ( Urv, prefix ); 1017 1035 } 1018 1036 } … … 1023 1041 getdata ( tmp ); 1024 1042 // d is first in getdata 1025 logrec->L.log it( logrec->ids(0), tmp.left ( Yrv._dsize() ) );1043 logrec->L.log_vector ( logrec->ids(0), tmp.left ( Yrv._dsize() ) ); 1026 1044 // u follows after d in getdata 1027 logrec->L.log it( logrec->ids(1), tmp.mid ( Yrv._dsize(), Urv._dsize() ) );1045 logrec->L.log_vector ( logrec->ids(1), tmp.mid ( Yrv._dsize(), Urv._dsize() ) ); 1028 1046 } 1029 1047 } … … 1189 1207 //! Set boolean options from a string, recognized are: "logbounds,logll" 1190 1208 virtual void set_options ( const string &opt ) { 1191 if ( opt.find ( "log bounds" ) != string::npos ) {1192 const_cast<epdf&>(posterior()).set_log_level( 2) ;1209 if ( opt.find ( "logstat" ) != string::npos ) { 1210 const_cast<epdf&>(posterior()).set_log_level(3) ; 1193 1211 } else { 1194 const_cast<epdf&>(posterior()).set_log_level(1) ; 1195 } 1196 if ( opt.find ( "logll" ) != string::npos ) { 1197 log_level = 1; 1212 if ( opt.find ( "logbounds" ) != string::npos ) { 1213 const_cast<epdf&>(posterior()).set_log_level(2) ; 1214 } else { 1215 const_cast<epdf&>(posterior()).set_log_level(1) ; 1216 } 1217 if ( opt.find ( "logll" ) != string::npos ) { 1218 log_level = 1; 1219 } 1198 1220 } 1199 1221 } … … 1210 1232 if ((log_level) > 0){ 1211 1233 logrec->ids.set_size(1); 1212 logrec->ids(0) = L.add (RV("ll",1), prefix+L.prefix_sep()+"ll");1234 logrec->ids(0) = L.add_vector(RV("",1), prefix+L.prefix_sep()+"ll"); 1213 1235 } 1214 1236 } -
library/bdm/base/loggers.h
r685 r727 49 49 } 50 50 51 void log it( int id, const vec &v ) {51 void log_vector ( int id, const vec &v ) { 52 52 bdm_assert ( id < vectors.length(), "Logger was not initialized, run init()." ); 53 53 if ( id >= 0 ) { … … 67 67 void finalize() { 68 68 if ( itfilename.length() > 0 ) itsave ( itfilename.c_str() ); 69 if (settings.length()>0){ 70 setting_conf.writeFile("memlog_setting.cfg"); 71 } 69 72 }; 70 73