Changeset 338 for bdm/stat/libBM.h

Show
Ignore:
Timestamp:
05/06/09 15:25:59 (15 years ago)
Author:
smidl
Message:

Multiple Models + changes in loggers

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • bdm/stat/libBM.h

    r325 r338  
    513513        //! log this vector 
    514514        virtual void logit ( int id, const vec &v ) =0; 
     515        //! log this double 
     516        virtual void logit ( int id, const double &d ) =0; 
    515517 
    516518        //! Shifts storage position for another time step. 
     
    640642        //! @{ 
    641643 
    642         BM () :ll ( 0 ),evalll ( true ), LIDs ( 3 ), opt_L_bounds ( false ) {}; 
     644        BM () :ll ( 0 ),evalll ( true ), LIDs ( 4 ), LFlags(4) { 
     645                LIDs=-1;/*empty IDs*/ LFlags=0; LFlags(0)=1;/*log only mean*/}; 
    643646        BM ( const BM &B ) :  drv ( B.drv ), ll ( B.ll ), evalll ( B.evalll ) {} 
    644647        //! Copy function required in vectors, Arrays of BM etc. Have to be DELETED manually! 
     
    699702        //!@{ 
    700703 
    701         //! Set boolean options from a string 
     704        //! Set boolean options from a string recognized are: "logbounds,logll" 
    702705        virtual void set_options ( const string &opt ) { 
    703                 opt_L_bounds= ( opt.find ( "logbounds" ) !=string::npos ); 
    704         } 
    705         //! IDs of storages in loggers 
     706                LFlags(0)=1; 
     707                if ( opt.find ( "logbounds" ) !=string::npos ) {LFlags(1)=1; LFlags(2)=1;} 
     708                if ( opt.find ( "logll" ) !=string::npos ) {LFlags(3)=1;} 
     709        } 
     710        //! IDs of storages in loggers 4:[1=mean,2=lb,3=ub,4=ll] 
    706711        ivec LIDs; 
    707712 
    708         //! Option for logging bounds 
    709         bool opt_L_bounds; 
     713        //! Flags for logging - same size as LIDs, each entry correspond to the same in LIDs 
     714        ivec LFlags; 
    710715        //! Add all logged variables to a logger 
    711716        virtual void log_add ( logger &L, const string &name="" ) { 
     
    716721 
    717722                // Add mean value 
    718                 LIDs ( 0 ) =L.add ( r,name ); 
    719                 if ( opt_L_bounds ) { 
    720                         LIDs ( 1 ) =L.add ( r,name+"_lb" ); 
    721                         LIDs ( 2 ) =L.add ( r,name+"_ub" ); 
    722                 } 
     723                if (LFlags(0)) LIDs ( 0 ) =L.add ( r,name ); 
     724                if (LFlags(1)) LIDs ( 1 ) =L.add ( r,name+"_lb" ); 
     725                if (LFlags(2)) LIDs ( 2 ) =L.add ( r,name+"_ub" ); 
     726                if (LFlags(3)) LIDs ( 3 ) =L.add ( RV("ll",1,0),r.name(0)+name ); //TODO: "local" RV  
    723727        } 
    724728        virtual void logit ( logger &L ) { 
    725729                L.logit ( LIDs ( 0 ), posterior().mean() ); 
    726                 if ( opt_L_bounds ) { 
     730                if ( LFlags(1) || LFlags(2)) { //if one of them is off, its LID==-1 and will not be stored 
    727731                        vec ub,lb; 
    728732                        posterior().qbounds ( lb,ub ); 
    729                         L.logit ( LIDs ( 1 ), lb ); 
     733                        L.logit ( LIDs ( 1 ), lb );  
    730734                        L.logit ( LIDs ( 2 ), ub ); 
    731735                } 
     736                if (LFlags(3)) L.logit ( LIDs ( 3 ), ll ); 
    732737        } 
    733738        //!@}