Changeset 1020

Show
Ignore:
Timestamp:
05/28/10 22:50:46 (14 years ago)
Author:
smidl
Message:

DEBUG macro for conditional output + new class

Files:
5 modified

Legend:

Unmodified
Added
Removed
  • applications/bdmtoolbox/mex/estimator.cpp

    r979 r1020  
    9595 
    9696        //DBG 
    97         Cfg.writeFile ( "estimator.cfg" ); 
     97        DEBUG(  Cfg.writeFile ( "estimator.cfg" );) 
    9898 
    9999#else 
  • library/bdm/base/bdmbase.h

    r1009 r1020  
    7676} 
    7777\enddot 
     78 
     79RV name may be empty string! In that case, it is not a valid name but only a size holder. It will fail in comparison. 
    7880*/ 
    7981 
     
    10231025        protected: 
    10241026                datalink_part dl; 
     1027                int vecfromlen; 
    10251028        public: 
    10261029                void update(const vec &v1){ 
    10271030                        bdm_assert_debug(length()==dl._downsize(),"vec_from_vec incompatible"); 
    1028                         bdm_assert_debug(v1.length()>=dl._upsize(),"vec_from_vec incompatible");//does not guarantee anything! 
     1031                        bdm_assert_debug(v1.length()==vecfromlen,"This vec was connected to vec of length "+num2str(vecfromlen)+ 
     1032                        ", but vec of length "+num2str(v1.length())+" was obtained"  ); 
    10291033                        dl.filldown(v1,*this); 
    10301034                }; 
    1031                 void connect(const RV &vecrv, const RV & vec1){dl.set_connection(vecrv,vec1);set_length(vecrv._dsize());}; 
     1035                void connect(const RV &vecrv, const RV & vec1){ 
     1036                        bdm_assert(vecrv._dsize()==length(),"Description of this vector, "+ vecrv.to_string() +" does not math it length: " + num2str(length())); 
     1037                        dl.set_connection(vecrv,vec1); 
     1038                        bdm_assert(dl._downsize()==length(), "Rv of this vector, "+vecrv.to_string() +" was not found in given rv: "+vec1.to_string()); 
     1039                }; 
    10321040}; 
    10331041 
     
    12521260class BM : public root { 
    12531261        //! \var log_level_enums logfull 
    1254         //! TODO DOPLNIT 
     1262        //! log full description of posterior in descriptive structure 
    12551263 
    12561264        //! \var log_level_enums logevidence 
    1257         //! TODO DOPLNIT 
     1265        //! log value of eveidence in each step 
    12581266         
    12591267        //! \var log_level_enums logbounds 
    1260         //! TODO DOPLNIT         
     1268        //! log lower and upper bounds of estimates 
    12611269        LOG_LEVEL(BM,logfull,logevidence,logbounds); 
    12621270 
  • library/bdm/bdmerror.h

    r766 r1020  
    4848#endif // if defined(NDEBUG) 
    4949 
     50#if defined(NDEBUG) 
     51//! DO argument if in DEBUG model 
     52#define DEBUG(command) ((void) 0) 
     53#else 
     54//! DO argument if in DEBUG model 
     55#define DEBUG(command) command 
     56#endif // if defined(NDEBUG) 
     57 
    5058//! Unconditionally throw std::runtime_error 
    5159#define bdm_error(s) \ 
  • library/bdm/stat/emix.h

    r979 r1020  
    476476UIREGISTER(ProdBM); 
    477477 
     478//! \brief class for on-line model selection  
     479class ModelComparator: public ProdBM{ 
     480        protected: 
     481                multiBM weights; 
     482        public: 
     483                void bayes(const vec &yt, const vec &cond){ 
     484                        vec w_nn(no_bms()); 
     485                        for (int i=0; i<no_bms(); i++){ 
     486                                bm(i)->bayes(yt,cond); 
     487                                w_nn(i) += bm(i)->_ll(); 
     488                        } 
     489                        vec w=exp(w_nn-max(w_nn)); 
     490                        weights.bayes(w/sum(w)); 
     491                } 
     492                void validate(){ 
     493                        ProdBM::validate(); 
     494                        weights.validate(); 
     495                } 
     496                void from_setting(const Setting& set){ 
     497                        ProdBM::from_setting(set); 
     498                        UI::get(weights.frg, set, "frg",UI::optional); 
     499                } 
     500                void to_setting(Setting& set) const{ 
     501                        ProdBM::to_setting(set); 
     502                        UI::save(weights.frg, set, "frg"); 
     503                } 
     504}; 
     505 
    478506} 
    479507#endif //MX_H 
  • library/bdm/stat/exp_family.h

    r1015 r1020  
    7676//! Estimator for Exponential family 
    7777class BMEF : public BM { 
    78 protected: 
     78        public: 
    7979        //! forgetting factor 
    8080        double frg; 
     81        protected: 
    8182        //! cached value of lognc() in the previous step (used in evaluation of \c ll ) 
    8283        double last_lognc;