Changeset 727
- Timestamp:
- 11/17/09 00:54:12 (15 years ago)
- Files:
-
- 1 added
- 8 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/dual/src/iterativemc.cpp
r723 r727 91 91 RV y("y",1); // name random variable 92 92 RV u("u",1); // name random variable 93 int L_yt=L->add (y,"S");94 int L_ut=L->add (u,"S");93 int L_yt=L->add_vector(y,"S"); 94 int L_ut=L->add_vector(u,"S"); 95 95 C->log_register(*L,"C"); 96 96 L->init(); -
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 -
library/bdm/stat/exp_family.h
r725 r727 293 293 logrec->ids.set_length(2); 294 294 int th_dim=dimension()-dimx*(dimx+1)/2; 295 logrec->ids(0)=L.add (RV("",th_dim), prefix + logrec->L.prefix_sep() +"mean");296 logrec->ids(1)=L.add (RV("",th_dim*th_dim),prefix + logrec->L.prefix_sep() + "variance");295 logrec->ids(0)=L.add_vector(RV("",th_dim), prefix + logrec->L.prefix_sep() +"mean"); 296 logrec->ids(1)=L.add_vector(RV("",th_dim*th_dim),prefix + logrec->L.prefix_sep() + "variance"); 297 297 } else { 298 298 epdf::log_register(L,prefix); … … 305 305 ldmat Vz; 306 306 factorize(M,Vz,Lam); 307 logrec->L.log it(logrec->ids(0), est_theta() );308 logrec->L.log it(logrec->ids(1), cvectorize(est_theta_cov().to_mat()));307 logrec->L.log_vector(logrec->ids(0), est_theta() ); 308 logrec->L.log_vector(logrec->ids(1), cvectorize(est_theta_cov().to_mat())); 309 309 } else { 310 310 epdf::log_write(); -
library/tests/mat_checks.h
r722 r727 57 57 inline itpp::vec make_close_tolerance ( const itpp::vec & variance, int nsamples ) { 58 58 // simplify overloading for Visual Studio 59 return 2* ( sqrt ( variance ) / sqrt ( static_cast<double> ( nsamples ) ) );59 return 3 * ( sqrt ( variance ) / sqrt ( static_cast<double> ( nsamples ) ) ); 60 60 } 61 61 -
library/tests/testsuite/epdf_test.cpp
r725 r727 43 43 44 44 TEST ( ewishart_test ) { 45 mat wM = "1 0.00.9; 0.9 1.0";45 mat wM = "1.1 0.9; 0.9 1.0"; 46 46 eWishartCh eW; 47 47 eW.set_parameters ( wM / 100, 100 ); -
library/tests/testsuite/logger_test.cpp
r723 r727 41 41 memlog logger ( 100, ls ); 42 42 43 int rid = logger.add ( r, "" ); 44 int thid = logger.add ( th, "th" ); 43 int pol = 11; 44 45 int rid = logger.add_vector ( r, "" ); 46 int thid = logger.add_vector ( th, "th" ); 47 int polid = logger.add_setting("pols"); 45 48 46 49 logger.init(); 47 50 48 51 for ( int i = 0; i < 10; i++ ) { 49 logger.logit ( rid, vec_2 ( ( double ) i, ( double ) ( i + 1 ) ) ); 50 logger.logit ( thid, vec_2 ( ( double ) ( 100 - i ), ( double ) ( i - 50 ) ) ); 52 logger.log_vector ( rid, vec_2 ( ( double ) i, ( double ) ( i + 1 ) ) ); 53 logger.log_vector ( thid, vec_2 ( ( double ) ( 100 - i ), ( double ) ( i - 50 ) ) ); 54 UI::save(pol, logger.log_to_setting(polid), "polozka"); 51 55 logger.step(); 52 56 } … … 55 59 56 60 CHECK_EQUAL ( get_file_size ( "logger_test.matrix" ), get_file_size ( ls.c_str() ) ); 61 CHECK_EQUAL ( get_file_size ( "memlog_setting.cfg.check" ), get_file_size ( "memlog_setting.cfg" ) ); 57 62 } 58 63 … … 68 73 dirfilelog L ( "dirfilelog_files", 10 ); 69 74 70 int rid = L.add ( r, "" );71 int thid = L.add ( th, "th" );75 int rid = L.add_vector ( r, "" ); 76 int thid = L.add_vector ( th, "th" ); 72 77 73 78 L.init(); 74 79 75 80 for ( int i = 0; i < 150; i++ ) { 76 L.log it( rid, vec_2 ( ( double ) i, ( double ) ( i + 1 ) ) );77 L.log it( thid, vec_2 ( ( double ) ( 100 - i ), ( double ) ( i - 50 ) ) );81 L.log_vector ( rid, vec_2 ( ( double ) i, ( double ) ( i + 1 ) ) ); 82 L.log_vector ( thid, vec_2 ( ( double ) ( 100 - i ), ( double ) ( i - 50 ) ) ); 78 83 L.step(); 79 84 } -
library/tests/testsuite/logger_test_dirfile_format.matrix
r721 r727 1 r .0 RAW d 12 r .1 RAW d 13 th .alog RAW d 14 th .blog RAW d 11 r_0 RAW d 1 2 r_1 RAW d 1 3 th_alog RAW d 1 4 th_blog RAW d 1