Changeset 870 for library/bdm/base
- Timestamp:
- 03/18/10 19:13:02 (14 years ago)
- Location:
- library/bdm/base
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/base/bdmbase.cpp
r863 r870 563 563 } 564 564 565 if (log_level[ bounds]){565 if (log_level[logbounds]){ 566 566 prior().log_level[epdf::loglb]=true; 567 567 prior().log_level[epdf::logub]=true; 568 568 } 569 if (log_level[ full]){569 if (log_level[logfull]){ 570 570 prior().log_level[epdf::logfull]=true; 571 571 } -
library/bdm/base/bdmbase.h
r864 r870 492 492 //! Probability density function with numerical statistics, e.g. posterior density. 493 493 class epdf : public pdf { 494 LOG_LEVEL(epdf, logmean, loglb, logub, logfull); 494 //! \var log_level_enums logmean 495 //! TODO DOPLNIT 496 497 //! \var log_level_enums loglb 498 //! TODO DOPLNIT 499 500 //! \var log_level_enums logub 501 //! TODO DOPLNIT 502 503 //! \var log_level_enums logfull 504 //! TODO DOPLNIT 505 LOG_LEVEL(epdf,logmean,loglb,logub,logfull); 495 506 496 507 public: … … 895 906 896 907 class DS : public root { 908 //! \var log_level_enums dt 909 //! TODO DOPLNIT 897 910 LOG_LEVEL(DS, dt); 911 898 912 protected: 899 913 //! size of data returned by \c getdata() … … 983 997 984 998 class BM : public root { 985 LOG_LEVEL(BM, full, likelihood, bounds); 999 //! \var log_level_enums logfull 1000 //! TODO DOPLNIT 1001 1002 //! \var log_level_enums logevidence 1003 //! TODO DOPLNIT 1004 1005 //! \var log_level_enums logbounds 1006 //! TODO DOPLNIT 1007 LOG_LEVEL(BM,logfull,logevidence,logbounds); 986 1008 987 1009 protected: … … 1145 1167 void validate() 1146 1168 { 1147 if ( log_level[ full] ) {1169 if ( log_level[logfull] ) { 1148 1170 const_cast<epdf&> ( posterior() ).log_level[epdf::logfull] = true; 1149 1171 } else { 1150 if ( log_level[ bounds] ) {1172 if ( log_level[logbounds] ) { 1151 1173 const_cast<epdf&> ( posterior() ).log_level[epdf::loglb] = true; 1152 1174 } else { 1153 1175 const_cast<epdf&> ( posterior() ).log_level[epdf::logmean] = true;; 1154 1176 } 1155 if ( log_level[likelihood] ) { 1156 // TODO testovat tedy likelyhood misto 1.. log_level = 1; 1177 if ( log_level[logevidence] ) { 1157 1178 } 1158 1179 } -
library/bdm/base/user_info.h
r863 r870 305 305 static void from_setting ( double &real, const Setting &element ); 306 306 307 //! This method converts a Setting into a specific log ged_options<T> variant and initialize options properly308 template< class T> static void from_setting ( log ged_options<T> &options, const Setting &element )307 //! This method converts a Setting into a specific log_level_template<T> variant and initialize options properly 308 template< class T> static void from_setting ( log_level_template<T> &log_level, const Setting &element ) 309 309 { 310 options.values.reset(); 311 Array<string> true_options; 312 UI::get( true_options, element ); 313 for( int i = 0; i < true_options.length(); i++ ) 314 for( int j = 0; j < options.names().length(); j++ ){ 315 if( true_options(i) == options.names()(j) ) 310 string raw_log_level; 311 UI::get( raw_log_level, element ); 312 Array<string> loaded_log_level = log_level_template<T>::string2Array( raw_log_level ); 313 314 log_level.values.reset(); 315 316 for( int i = 0; i < loaded_log_level.length(); i++ ) 317 for( int j = 0; j < log_level.names().length(); j++ ){ 318 if( loaded_log_level(i) == log_level.names()(j) ) 316 319 { 317 options.values[j] = true;320 log_level.values[j] = true; 318 321 break; 319 322 } … … 324 327 template<class T> static void from_setting ( T* &instance, const Setting &element ) { 325 328 const SettingResolver link ( element ); 326 assert_type 329 assert_type( link.result, Setting::TypeGroup ); 327 330 328 331 // we get a value stored in the "class" attribute … … 600 603 } 601 604 602 // The only difference from classical UserInfo approach to log ged_optionsis the fact603 // that the actual element related to logged_optionscould possibly exists yet. In this case,605 // The only difference from classical UserInfo approach to log_level_template is the fact 606 // that the actual UI element related to log_level_template could possibly exists yet. In this case, 604 607 // we do not want to throw an exception like in the case of any other type being loaded 605 // from Setting. Here, we rather add our optionsinto this existig element. This way, it is606 // possible that more instances of log ged_options class (all contained in one wrapping instance of607 // a particular class!)can be stored in only one line in a configuration file608 template< class T> static void save ( const log ged_options<T> &options, Setting &element, const string &name = "options" ) {608 // from Setting. We rather fill the current log_level into this existig element. This way, it is 609 // possible that more instances of log_level_template class (templated with different classes) 610 // can be stored in only one line in a configuration file 611 template< class T> static void save ( const log_level_template<T> &log_level, Setting &element, const string &name = "log_level" ) { 609 612 assert_type ( element, Setting::TypeGroup ); 613 614 string string_to_write; 610 615 611 616 Setting *list; … … 613 618 { 614 619 list = &element[name]; 615 assert_type ( *list, Setting::TypeList ); 620 assert_type ( *list, Setting::TypeString ); 621 string_to_write = ( const char* ) *list; 616 622 } 617 623 else 618 list = &element.add ( name, Setting::TypeList ); 619 620 Array<string> true_options; 621 int true_options_count = 0; 622 true_options.set_length( options.values.size() ); 623 for( unsigned int i = 0; i < options.values.size(); i++ ) 624 if( options.values[i] ) 625 true_options( true_options_count++ ) = options.names()(i); 626 save( true_options, *list, name ); 624 list = &element.add ( name, Setting::TypeString ); 625 626 for( unsigned int i = 0; i < log_level.values.size(); i++ ) 627 if( log_level.values[i] ) // a jeste zkontrolovat zda to jmeno uz neni obsazeno? 628 { 629 if( string_to_write.length() > 0 ) 630 string_to_write = string_to_write + ','; 631 string_to_write = string_to_write + log_level.names()(i); 632 } 633 634 *list = string_to_write; 627 635 } 628 636