Changeset 565 for library/bdm/base

Show
Ignore:
Timestamp:
08/19/09 16:54:24 (15 years ago)
Author:
vbarta
Message:

using own error macros (basically copied from IT++, but never aborting)

Location:
library/bdm/base
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/base/bdmbase.cpp

    r545 r565  
    4242        } else { 
    4343                id = iter->second; 
    44                 it_assert ( RV_SIZES ( id ) == size, "RV " + name + " of different size already exists" ); 
     44                bdm_assert_debug ( RV_SIZES ( id ) == size, "RV " + name + " of different size already exists" ); 
    4545        } 
    4646        return id; 
     
    6767void RV::init ( const Array<std::string> &in_names, const ivec &in_sizes, const ivec &in_times ) { 
    6868        len = in_names.length(); 
    69         it_assert_debug ( in_names.length() == in_times.length(), "check \"times\" " ); 
    70         it_assert_debug ( in_names.length() == in_sizes.length(), "check \"sizes\" " ); 
     69        bdm_assert_debug ( in_names.length() == in_times.length(), "check \"times\" " ); 
     70        bdm_assert_debug ( in_names.length() == in_sizes.length(), "check \"sizes\" " ); 
    7171 
    7272        times.set_length ( len ); 
     
    135135 
    136136shared_ptr<mpdf> epdf::condition (const RV &rv) const { 
    137         it_warning ("Not implemented"); 
     137        bdm_warning ("Not implemented"); 
    138138        return shared_ptr<mpdf>(); 
    139139} 
    140140 
    141141shared_ptr<epdf> epdf::marginal (const RV &rv) const { 
    142         it_warning ("Not implemented"); 
     142        bdm_warning ("Not implemented"); 
    143143        return shared_ptr<epdf>(); 
    144144} 
     
    194194        v2v_up = rv.dataind (rv_up); 
    195195 
    196         it_assert_debug (v2v_up.length() == downsize, "rv is not fully in rv_up"); 
     196        bdm_assert_debug (v2v_up.length() == downsize, "rv is not fully in rv_up"); 
    197197} 
    198198 
     
    202202        v2v_up = upind; 
    203203 
    204         it_assert_debug (v2v_up.length() == downsize, "rv is not fully in rv_up"); 
     204        bdm_assert_debug (v2v_up.length() == downsize, "rv is not fully in rv_up"); 
    205205} 
    206206 
     
    219219 
    220220void datalink_m2e::pushup_cond (vec &val_up, const vec &val, const vec &cond) { 
    221         it_assert_debug (downsize == val.length(), "Wrong val"); 
    222         it_assert_debug (upsize == val_up.length(), "Wrong val_up"); 
     221        bdm_assert_debug (downsize == val.length(), "Wrong val"); 
     222        bdm_assert_debug (upsize == val_up.length(), "Wrong val_up"); 
    223223        set_subvector (val_up, v2v_up, val); 
    224224        set_subvector (val_up, v2c_up, cond); 
     
    259259                } 
    260260        } 
    261         it_assert_debug ( res.length() == dsize, "this rv is not fully present in crv!" ); 
     261 
     262        bdm_assert_debug ( res.length() == dsize, "this rv is not fully present in crv!" ); 
    262263        return res; 
    263264 
     
    294295                } 
    295296        } 
    296         it_assert_debug ( selfi.length() == rv2i.length(), "this should not happen!" ); 
     297        bdm_assert_debug ( selfi.length() == rv2i.length(), "this should not happen!" ); 
    297298} 
    298299 
     
    322323void RV::from_setting ( const Setting &set ) { 
    323324        Array<string> A; 
    324         it_assert ( !A.length(), "default array not empty" ); 
    325325        UI::get ( A, set, "names" ); 
    326326 
     
    356356                rvaddok = rv.add ( mpdfs ( i )->_rv() ); //add rv to common rvs. 
    357357                // If rvaddok==false, mpdfs overlap => assert error. 
    358                 it_assert_debug ( rvaddok || !checkoverlap, "mprod::mprod() input mpdfs overlap in rv!" ); 
     358                bdm_assert_debug ( rvaddok || !checkoverlap, "mprod::mprod() input mpdfs overlap in rv!" ); 
    359359        } 
    360360 
  • library/bdm/base/bdmbase.h

    r545 r565  
    4444                //!Default constructor 
    4545                str (ivec ids0, ivec times0) : ids (ids0), times (times0) { 
    46                         it_assert_debug (times0.length() == ids0.length(), "Incompatible input"); 
     46                        bdm_assert_debug (times0.length() == ids0.length(), "Incompatible input"); 
    4747                }; 
    4848}; 
     
    298298                //! Returns a sample, \f$ x \f$ from density \f$ f_x()\f$ 
    299299                virtual vec sample() const { 
    300                         it_error ("not implemented"); 
    301                         return vec (0); 
     300                        bdm_error ("not implemented"); 
     301                        return vec(); 
    302302                } 
    303303 
     
    308308                //! In case the argument is out of suport return -Infinity 
    309309                virtual double evallog (const vec &val) const { 
    310                         it_error ("not implemented"); 
     310                        bdm_error ("not implemented"); 
    311311                        return 0.0; 
    312312                } 
     
    326326                //! return expected value 
    327327                virtual vec mean() const { 
    328                         it_error ("not implemneted"); 
    329                         return vec (0); 
    330                 }; 
     328                        bdm_error ("not implemneted"); 
     329                        return vec(); 
     330                } 
    331331 
    332332                //! return expected variance (not covariance!) 
    333333                virtual vec variance() const { 
    334                         it_error ("not implemneted"); 
    335                         return vec (0); 
    336                 }; 
     334                        bdm_error ("not implemneted"); 
     335                        return vec(); 
     336                } 
     337 
    337338                //! Lower and upper bounds of \c percentage % quantile, returns mean-2*sigma as default 
    338339                virtual void qbounds (vec &lb, vec &ub, double percentage = 0.95) const { 
     
    353354                void set_rv (const RV &rv0) { 
    354355                        rv = rv0; 
    355                 }   //it_assert_debug(isnamed(),""); }; 
     356                } 
     357 
    356358                //! True if rv is assigned 
    357359                bool isnamed() const { 
     
    359361                        return b; 
    360362                } 
     363 
    361364                //! Return name (fails when isnamed is false) 
    362365                const RV& _rv() const { 
    363                         it_assert_debug (isnamed(), ""); 
     366                        bdm_assert_debug (isnamed(), ""); 
    364367                        return rv; 
    365368                } 
     
    425428 
    426429                //! Returns a sample from the density conditioned on \c cond, \f$x \sim epdf(rv|cond)\f$. \param cond is numeric value of \c rv 
    427                 virtual vec samplecond (const vec &cond) {it_error ("Not implemented");return vec (0);}; 
     430                virtual vec samplecond (const vec &cond) { 
     431                        bdm_error ("Not implemented"); 
     432                        return vec(); 
     433                } 
    428434 
    429435                //! Returns \param N samples from the density conditioned on \c cond, \f$x \sim epdf(rv|cond)\f$. \param cond is numeric value of \c rv 
     
    431437 
    432438                //! Shortcut for conditioning and evaluation of the internal epdf. In some cases,  this operation can be implemented efficiently. 
    433                 virtual double evallogcond (const vec &dt, const vec &cond) {it_error ("Not implemented");return 0.0;} 
     439                virtual double evallogcond (const vec &dt, const vec &cond) { 
     440                        bdm_error ("Not implemented"); 
     441                        return 0.0; 
     442                } 
    434443 
    435444                //! Matrix version of evallogcond 
     
    441450 
    442451                //! Array<vec> version of evallogcond 
    443                 virtual vec evallogcond_m (const Array<vec> &Dt, const vec &cond) {it_error ("Not implemented");return vec (0);} 
     452                virtual vec evallogcond_m (const Array<vec> &Dt, const vec &cond) { 
     453                        bdm_error ("Not implemented"); 
     454                        return vec(); 
     455                } 
    444456 
    445457                //! \name Access to attributes 
     
    497509                //! constructor 
    498510                mpdf_internal() : mpdf(), iepdf() {set_ep (iepdf);} 
     511 
    499512                //! Update \c iepdf so that it represents this mpdf conditioned on \c rvc = cond 
    500513                //! This function provides convenient reimplementation in offsprings 
    501514                virtual void condition (const vec &cond) { 
    502                         it_error ("Not implemented"); 
    503                 }; 
     515                        bdm_error ("Not implemented"); 
     516                } 
     517 
    504518                //!access function to iepdf 
    505519                EPDF& e() {return iepdf;} 
     
    571585                //! Get val for myself from val of "Up" 
    572586                vec pushdown (const vec &val_up) { 
    573                         it_assert_debug (upsize == val_up.length(), "Wrong val_up"); 
     587                        bdm_assert_debug (upsize == val_up.length(), "Wrong val_up"); 
    574588                        return get_vec (val_up, v2v_up); 
    575589                } 
     
    577591                //! Fill val of "Up" by my pieces 
    578592                void pushup (vec &val_up, const vec &val) { 
    579                         it_assert_debug (downsize == val.length(), "Wrong val"); 
    580                         it_assert_debug (upsize == val_up.length(), "Wrong val_up"); 
     593                        bdm_assert_debug (downsize == val.length(), "Wrong val"); 
     594                        bdm_assert_debug (upsize == val_up.length(), "Wrong val_up"); 
    581595                        set_subvector (val_up, v2v_up, val); 
    582596                } 
     
    628642                        //establish c2c connection 
    629643                        rvc.dataind (rvc_up, c2c_lo, c2c_up); 
    630                         it_assert_debug (c2c_lo.length() + v2c_lo.length() == condsize, "cond is not fully given"); 
     644                        bdm_assert_debug (c2c_lo.length() + v2c_lo.length() == condsize, "cond is not fully given"); 
    631645                } 
    632646 
     
    746760                //! default constructors 
    747761                DS() : Drv(), Urv() {}; 
     762 
    748763                //! Returns full vector of observed data=[output, input] 
    749764                virtual void getdata (vec &dt) { 
    750                         it_error ("abstract class"); 
    751                 }; 
     765                        bdm_error ("abstract class"); 
     766                } 
     767 
    752768                //! Returns data records at indeces. 
    753769                virtual void getdata (vec &dt, const ivec &indeces) { 
    754                         it_error ("abstract class"); 
    755                 }; 
     770                        bdm_error ("abstract class"); 
     771                } 
     772 
    756773                //! Accepts action variable and schedule it for application. 
    757774                virtual void write (vec &ut) { 
    758                         it_error ("abstract class"); 
    759                 }; 
     775                        bdm_error ("abstract class"); 
     776                } 
     777 
    760778                //! Accepts action variables at specific indeces 
    761779                virtual void write (vec &ut, const ivec &indeces) { 
    762                         it_error ("abstract class"); 
    763                 }; 
     780                        bdm_error ("abstract class"); 
     781                } 
    764782 
    765783                //! Moves from \f$ t \f$ to \f$ t+1 \f$, i.e. perfroms the actions and reads response of the system. 
     
    768786                //! Register DS for logging into logger L 
    769787                virtual void log_add (logger &L) { 
    770                         it_assert_debug (dtsize == Drv._dsize(), ""); 
    771                         it_assert_debug (utsize == Urv._dsize(), ""); 
     788                        bdm_assert_debug (dtsize == Drv._dsize(), "invalid DS: dtsize different from Drv"); 
     789                        bdm_assert_debug (utsize == Urv._dsize(), "invalid DS: utsize different from Urv"); 
    772790 
    773791                        L_dt = L.add (Drv, ""); 
     
    857875                //! I.e. marginal likelihood of the data with the posterior integrated out. 
    858876                virtual double logpred (const vec &dt) const { 
    859                         it_error ("Not implemented"); 
     877                        bdm_error ("Not implemented"); 
    860878                        return 0.0; 
    861879                } 
     880 
    862881                //! Matrix version of logpred 
    863882                vec logpred_m (const mat &dt) const { 
     
    871890                //!Constructs a predictive density \f$ f(d_{t+1} |d_{t}, \ldots d_{0}) \f$ 
    872891                virtual epdf* epredictor() const { 
    873                         it_error ("Not implemented"); 
     892                        bdm_error ("Not implemented"); 
    874893                        return NULL; 
    875894                }; 
    876895                //!Constructs conditional density of 1-step ahead predictor \f$ f(d_{t+1} |d_{t+h-1}, \ldots d_{t}) \f$ 
    877896                virtual mpdf* predictor() const { 
    878                         it_error ("Not implemented"); 
     897                        bdm_error ("Not implemented"); 
    879898                        return NULL; 
    880899                }; 
     
    895914                //! Substitute \c val for \c rvc. 
    896915                virtual void condition (const vec &val) { 
    897                         it_error ("Not implemented!"); 
    898                 }; 
     916                        bdm_error ("Not implemented!"); 
     917                } 
    899918 
    900919                //!@} 
     
    10021021        condition (cond); 
    10031022        tmp = iepdf.evallog (dt); 
    1004         // it_assert_debug(std::isfinite(tmp), "Infinite value"); 
    10051023        return tmp; 
    10061024} 
  • library/bdm/base/datasources.cpp

    r527 r565  
    77        int i; 
    88 
    9         it_assert_debug ( dt.length() == rowid.length(), "MemDS:getdata incompatible dt" ); 
     9        bdm_assert_debug ( dt.length() == rowid.length(), "MemDS:getdata incompatible dt" ); 
    1010        for ( i = 0; i < rowid.length(); i++ ) { 
    1111                dt ( i ) = Data ( rowid ( i ), time - delays ( i ) ); 
     
    1515void MemDS::getdata ( vec &dt, const ivec &indeces ) { 
    1616        int j, i; 
    17         it_assert_debug ( dt.length() == indeces.length(), "MemDS:getdata incompatible dt" ); 
     17        bdm_assert_debug ( dt.length() == indeces.length(), "MemDS:getdata incompatible dt" ); 
    1818        for ( i = 0; i < indeces.length(); i++ ) { 
    1919                j = indeces ( i ); 
     
    2929 
    3030void MemDS::set_rvs ( RV &drv, RV &urv ) { 
    31         it_assert_debug ( drv._dsize() == rowid.length(), "MemDS::set_rvs incompatible drv" ); 
    32         it_assert_debug ( urv._dsize() == 0, "MemDS does not support urv." ); 
     31        bdm_assert_debug ( drv._dsize() == rowid.length(), "MemDS::set_rvs incompatible drv" ); 
     32        bdm_assert_debug ( urv._dsize() == 0, "MemDS does not support urv." ); 
    3333 
    3434        Drv = drv; 
     
    3636 
    3737MemDS::MemDS ( mat &Dat, ivec &rowid0, ivec &delays0 ) : rowid ( rowid0 ), delays ( delays0 ) { 
    38         it_assert_debug ( max ( rowid ) <= Dat.rows(), "MemDS rowid is too high for given Dat." ); 
    39         it_assert_debug ( max ( delays ) < Dat.cols(), "MemDS delays are too high." ); 
     38        bdm_assert_debug ( max ( rowid ) <= Dat.rows(), "MemDS rowid is too high for given Dat." ); 
     39        bdm_assert_debug ( max ( delays ) < Dat.cols(), "MemDS delays are too high." ); 
    4040 
    4141        time = max ( delays ); 
  • library/bdm/base/datasources.h

    r529 r565  
    4242        void getdata ( vec &dt, const ivec &indeces ); 
    4343        void set_rvs ( RV &drv, RV &urv ); 
     44 
    4445        void write ( vec &ut ) { 
    45                 it_error ( "MemDS::write is not supported" ); 
    46         } 
     46                bdm_error ( "MemDS::write is not supported" ); 
     47        } 
     48 
    4749        void write ( vec &ut, ivec &indices ) { 
    48                 it_error ( "MemDS::write is not supported" ); 
    49         } 
     50                bdm_error ( "MemDS::write is not supported" ); 
     51        } 
     52 
    5053        void step(); 
    5154        //!Default constructor 
     
    6164public: 
    6265        void getdata ( vec &dt ) { 
    63                 it_assert_debug ( dt.length() == Data.rows(), "" ); 
    6466                dt = Data.get_col ( time ); 
    65         }; 
    66         void getdata ( vec &dt, const ivec &indeces ) { 
    67                 it_assert_debug ( dt.length() == indeces.length(), "" ); 
    68                 vec tmp ( indeces.length() ); 
    69                 tmp = Data.get_col ( time ); 
    70                 dt = tmp ( indeces ); 
    71         }; 
     67        } 
     68 
     69        void getdata ( vec &dt, const ivec &indices ) { 
     70                vec tmp = Data.get_col ( time ); 
     71                dt = tmp ( indices ); 
     72        } 
     73 
    7274        //! returns number of data in the file; 
    7375        int ndat() { 
     
    151153public: 
    152154        void getdata ( vec &dt ) { 
    153                 //it_assert_debug ( dt.length() ==Drv.count(),"ArxDS" ); 
    154155                dt = H; 
    155         }; 
     156        } 
     157 
    156158        void getdata ( vec &dt, const ivec &indices ) { 
    157                 it_assert_debug ( dt.length() == indices.length(), "ArxDS" ); 
    158159                dt = H ( indices ); 
    159         }; 
     160        } 
     161 
    160162        void write ( vec &ut ) { 
    161                 //it_assert_debug ( ut.length() ==Urv.count(),"ArxDS" ); 
    162163                U = ut; 
    163         }; 
     164        } 
     165 
    164166        void write ( vec &ut, const ivec &indices ) { 
    165                 it_assert_debug ( ut.length() == indices.length(), "ArxDS" ); 
     167                bdm_assert_debug ( ut.length() == indices.length(), "ArxDS" ); 
    166168                set_subvector ( U, indices, ut ); 
    167         }; 
     169        } 
     170 
    168171        void step(); 
     172 
    169173        //!Default constructor 
    170174        ArxDS ( ) {}; 
     
    288292                dt0 = dt; 
    289293        } 
    290         void getdata ( vec &dt0, const ivec &indeces ) { 
    291                 dt0 = dt ( indeces ); 
     294 
     295        void getdata ( vec &dt0, const ivec &indices ) { 
     296                dt0 = dt ( indices ); 
    292297        } 
    293298 
  • library/bdm/base/loggers.cpp

    r554 r565  
    127127        char filename[200]; 
    128128 
    129         it_assert_debug ( Len <= maxlen, "diffilelog" ); 
     129        bdm_assert_debug ( Len <= maxlen, "diffilelog::write_buffers: Len too large" ); 
    130130 
    131131        ii = 0; 
  • library/bdm/base/loggers.h

    r551 r565  
    4545        void step() { 
    4646                if ( ind < maxlen ) ind++; 
    47                 else it_error ( "memlog::ind is too high;" ); 
     47                else bdm_error ( "memlog::ind is too high;" ); 
    4848        } 
     49 
    4950        void logit ( int id, const vec &v ) { 
    50                 it_assert_debug ( id < vectors.length(), "Logger was not initialized, run init()." ); 
     51                bdm_assert_debug ( id < vectors.length(), "Logger was not initialized, run init()." ); 
    5152                if ( id >= 0 ) { 
    5253                        vectors ( id ).set_row ( ind, v ); 
     
    5455        } 
    5556        void logit ( int id, const double &d ) { 
    56                 it_assert_debug ( id < vectors.length(), "Logger was not initialized, run init()." ); 
    57                 it_assert_debug ( vectors ( id ).cols() == 1, "Vector expected" ); 
     57                bdm_assert_debug ( id < vectors.length(), "Logger was not initialized, run init()." ); 
     58                bdm_assert_debug ( vectors ( id ).cols() == 1, "Vector expected" ); 
    5859                if ( id >= 0 ) { 
    5960                        vectors ( id ) ( ind ) = d; 
  • library/bdm/base/user_info.cpp

    r540 r565  
    3333                setAutoConvert ( true ); 
    3434        } catch ( FileIOException f ) { 
    35                 it_error ( "UI error: file " + file_name + " not found." ); 
     35                string msg = "UI error: file "; 
     36                msg += file_name; 
     37                msg += " not found."; 
     38                bdm_error ( msg ); 
    3639        } catch ( ParseException& P ) { 
    3740                stringstream msg; 
    3841                msg << "UI error: parsing error """ << P.getError() << """ in file " << file_name << " on line " <<  P.getLine() << "."; 
    39                 it_error ( msg.str() ); 
     42                bdm_error ( msg.str() ); 
    4043        } 
    4144} 
     
    4649                writeFile ( file_name.c_str() ); 
    4750        } catch ( FileIOException f ) { 
    48                 it_error ( "UI error: file " + file_name + " is inacessible." ); 
     51                string msg = "UI error: file "; 
     52                msg += file_name; 
     53                msg += " is inacessible."; 
     54                bdm_error ( msg ); 
    4955        } 
    5056} 
     
    94100                msg << "There is not any registered class yet!" << endl; 
    95101 
    96         it_error ( msg.str() ); 
     102        bdm_error ( msg.str() ); 
    97103} 
    98104 
  • library/bdm/base/user_info.h

    r544 r565  
    321321 
    322322                root *typeless_instance = related_UI.new_instance(); 
    323                 it_assert_debug ( typeless_instance, "UI::new_instance failed" ); 
     323                bdm_assert_debug ( typeless_instance, "UI::new_instance failed" ); 
    324324 
    325325                instance = dynamic_cast<T*> ( typeless_instance ); 
     
    351351                T *tmp_inst = 0; 
    352352                from_setting ( tmp_inst, element ); 
    353                 it_assert_debug ( tmp_inst, "UI::from_setting failed" ); 
     353                bdm_assert_debug ( tmp_inst, "UI::from_setting failed" ); 
    354354                instance = tmp_inst; 
    355355        }