Changeset 565 for library/bdm/base
- Timestamp:
- 08/19/09 16:54:24 (15 years ago)
- Location:
- library/bdm/base
- Files:
-
- 8 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/base/bdmbase.cpp
r545 r565 42 42 } else { 43 43 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" ); 45 45 } 46 46 return id; … … 67 67 void RV::init ( const Array<std::string> &in_names, const ivec &in_sizes, const ivec &in_times ) { 68 68 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\" " ); 71 71 72 72 times.set_length ( len ); … … 135 135 136 136 shared_ptr<mpdf> epdf::condition (const RV &rv) const { 137 it_warning ("Not implemented");137 bdm_warning ("Not implemented"); 138 138 return shared_ptr<mpdf>(); 139 139 } 140 140 141 141 shared_ptr<epdf> epdf::marginal (const RV &rv) const { 142 it_warning ("Not implemented");142 bdm_warning ("Not implemented"); 143 143 return shared_ptr<epdf>(); 144 144 } … … 194 194 v2v_up = rv.dataind (rv_up); 195 195 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"); 197 197 } 198 198 … … 202 202 v2v_up = upind; 203 203 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"); 205 205 } 206 206 … … 219 219 220 220 void 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"); 223 223 set_subvector (val_up, v2v_up, val); 224 224 set_subvector (val_up, v2c_up, cond); … … 259 259 } 260 260 } 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!" ); 262 263 return res; 263 264 … … 294 295 } 295 296 } 296 it_assert_debug ( selfi.length() == rv2i.length(), "this should not happen!" );297 bdm_assert_debug ( selfi.length() == rv2i.length(), "this should not happen!" ); 297 298 } 298 299 … … 322 323 void RV::from_setting ( const Setting &set ) { 323 324 Array<string> A; 324 it_assert ( !A.length(), "default array not empty" );325 325 UI::get ( A, set, "names" ); 326 326 … … 356 356 rvaddok = rv.add ( mpdfs ( i )->_rv() ); //add rv to common rvs. 357 357 // 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!" ); 359 359 } 360 360 -
library/bdm/base/bdmbase.h
r545 r565 44 44 //!Default constructor 45 45 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"); 47 47 }; 48 48 }; … … 298 298 //! Returns a sample, \f$ x \f$ from density \f$ f_x()\f$ 299 299 virtual vec sample() const { 300 it_error ("not implemented");301 return vec (0);300 bdm_error ("not implemented"); 301 return vec(); 302 302 } 303 303 … … 308 308 //! In case the argument is out of suport return -Infinity 309 309 virtual double evallog (const vec &val) const { 310 it_error ("not implemented");310 bdm_error ("not implemented"); 311 311 return 0.0; 312 312 } … … 326 326 //! return expected value 327 327 virtual vec mean() const { 328 it_error ("not implemneted");329 return vec (0);330 } ;328 bdm_error ("not implemneted"); 329 return vec(); 330 } 331 331 332 332 //! return expected variance (not covariance!) 333 333 virtual vec variance() const { 334 it_error ("not implemneted"); 335 return vec (0); 336 }; 334 bdm_error ("not implemneted"); 335 return vec(); 336 } 337 337 338 //! Lower and upper bounds of \c percentage % quantile, returns mean-2*sigma as default 338 339 virtual void qbounds (vec &lb, vec &ub, double percentage = 0.95) const { … … 353 354 void set_rv (const RV &rv0) { 354 355 rv = rv0; 355 } //it_assert_debug(isnamed(),""); }; 356 } 357 356 358 //! True if rv is assigned 357 359 bool isnamed() const { … … 359 361 return b; 360 362 } 363 361 364 //! Return name (fails when isnamed is false) 362 365 const RV& _rv() const { 363 it_assert_debug (isnamed(), "");366 bdm_assert_debug (isnamed(), ""); 364 367 return rv; 365 368 } … … 425 428 426 429 //! 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 } 428 434 429 435 //! 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 … … 431 437 432 438 //! 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 } 434 443 435 444 //! Matrix version of evallogcond … … 441 450 442 451 //! 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 } 444 456 445 457 //! \name Access to attributes … … 497 509 //! constructor 498 510 mpdf_internal() : mpdf(), iepdf() {set_ep (iepdf);} 511 499 512 //! Update \c iepdf so that it represents this mpdf conditioned on \c rvc = cond 500 513 //! This function provides convenient reimplementation in offsprings 501 514 virtual void condition (const vec &cond) { 502 it_error ("Not implemented"); 503 }; 515 bdm_error ("Not implemented"); 516 } 517 504 518 //!access function to iepdf 505 519 EPDF& e() {return iepdf;} … … 571 585 //! Get val for myself from val of "Up" 572 586 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"); 574 588 return get_vec (val_up, v2v_up); 575 589 } … … 577 591 //! Fill val of "Up" by my pieces 578 592 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"); 581 595 set_subvector (val_up, v2v_up, val); 582 596 } … … 628 642 //establish c2c connection 629 643 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"); 631 645 } 632 646 … … 746 760 //! default constructors 747 761 DS() : Drv(), Urv() {}; 762 748 763 //! Returns full vector of observed data=[output, input] 749 764 virtual void getdata (vec &dt) { 750 it_error ("abstract class"); 751 }; 765 bdm_error ("abstract class"); 766 } 767 752 768 //! Returns data records at indeces. 753 769 virtual void getdata (vec &dt, const ivec &indeces) { 754 it_error ("abstract class"); 755 }; 770 bdm_error ("abstract class"); 771 } 772 756 773 //! Accepts action variable and schedule it for application. 757 774 virtual void write (vec &ut) { 758 it_error ("abstract class"); 759 }; 775 bdm_error ("abstract class"); 776 } 777 760 778 //! Accepts action variables at specific indeces 761 779 virtual void write (vec &ut, const ivec &indeces) { 762 it_error ("abstract class");763 } ;780 bdm_error ("abstract class"); 781 } 764 782 765 783 //! Moves from \f$ t \f$ to \f$ t+1 \f$, i.e. perfroms the actions and reads response of the system. … … 768 786 //! Register DS for logging into logger L 769 787 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"); 772 790 773 791 L_dt = L.add (Drv, ""); … … 857 875 //! I.e. marginal likelihood of the data with the posterior integrated out. 858 876 virtual double logpred (const vec &dt) const { 859 it_error ("Not implemented");877 bdm_error ("Not implemented"); 860 878 return 0.0; 861 879 } 880 862 881 //! Matrix version of logpred 863 882 vec logpred_m (const mat &dt) const { … … 871 890 //!Constructs a predictive density \f$ f(d_{t+1} |d_{t}, \ldots d_{0}) \f$ 872 891 virtual epdf* epredictor() const { 873 it_error ("Not implemented");892 bdm_error ("Not implemented"); 874 893 return NULL; 875 894 }; 876 895 //!Constructs conditional density of 1-step ahead predictor \f$ f(d_{t+1} |d_{t+h-1}, \ldots d_{t}) \f$ 877 896 virtual mpdf* predictor() const { 878 it_error ("Not implemented");897 bdm_error ("Not implemented"); 879 898 return NULL; 880 899 }; … … 895 914 //! Substitute \c val for \c rvc. 896 915 virtual void condition (const vec &val) { 897 it_error ("Not implemented!");898 } ;916 bdm_error ("Not implemented!"); 917 } 899 918 900 919 //!@} … … 1002 1021 condition (cond); 1003 1022 tmp = iepdf.evallog (dt); 1004 // it_assert_debug(std::isfinite(tmp), "Infinite value");1005 1023 return tmp; 1006 1024 } -
library/bdm/base/datasources.cpp
r527 r565 7 7 int i; 8 8 9 it_assert_debug ( dt.length() == rowid.length(), "MemDS:getdata incompatible dt" );9 bdm_assert_debug ( dt.length() == rowid.length(), "MemDS:getdata incompatible dt" ); 10 10 for ( i = 0; i < rowid.length(); i++ ) { 11 11 dt ( i ) = Data ( rowid ( i ), time - delays ( i ) ); … … 15 15 void MemDS::getdata ( vec &dt, const ivec &indeces ) { 16 16 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" ); 18 18 for ( i = 0; i < indeces.length(); i++ ) { 19 19 j = indeces ( i ); … … 29 29 30 30 void 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." ); 33 33 34 34 Drv = drv; … … 36 36 37 37 MemDS::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." ); 40 40 41 41 time = max ( delays ); -
library/bdm/base/datasources.h
r529 r565 42 42 void getdata ( vec &dt, const ivec &indeces ); 43 43 void set_rvs ( RV &drv, RV &urv ); 44 44 45 void write ( vec &ut ) { 45 it_error ( "MemDS::write is not supported" ); 46 } 46 bdm_error ( "MemDS::write is not supported" ); 47 } 48 47 49 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 50 53 void step(); 51 54 //!Default constructor … … 61 64 public: 62 65 void getdata ( vec &dt ) { 63 it_assert_debug ( dt.length() == Data.rows(), "" );64 66 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 72 74 //! returns number of data in the file; 73 75 int ndat() { … … 151 153 public: 152 154 void getdata ( vec &dt ) { 153 //it_assert_debug ( dt.length() ==Drv.count(),"ArxDS" );154 155 dt = H; 155 }; 156 } 157 156 158 void getdata ( vec &dt, const ivec &indices ) { 157 it_assert_debug ( dt.length() == indices.length(), "ArxDS" );158 159 dt = H ( indices ); 159 }; 160 } 161 160 162 void write ( vec &ut ) { 161 //it_assert_debug ( ut.length() ==Urv.count(),"ArxDS" );162 163 U = ut; 163 }; 164 } 165 164 166 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" ); 166 168 set_subvector ( U, indices, ut ); 167 }; 169 } 170 168 171 void step(); 172 169 173 //!Default constructor 170 174 ArxDS ( ) {}; … … 288 292 dt0 = dt; 289 293 } 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 ); 292 297 } 293 298 -
library/bdm/base/loggers.cpp
r554 r565 127 127 char filename[200]; 128 128 129 it_assert_debug ( Len <= maxlen, "diffilelog" );129 bdm_assert_debug ( Len <= maxlen, "diffilelog::write_buffers: Len too large" ); 130 130 131 131 ii = 0; -
library/bdm/base/loggers.h
r551 r565 45 45 void step() { 46 46 if ( ind < maxlen ) ind++; 47 else it_error ( "memlog::ind is too high;" );47 else bdm_error ( "memlog::ind is too high;" ); 48 48 } 49 49 50 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()." ); 51 52 if ( id >= 0 ) { 52 53 vectors ( id ).set_row ( ind, v ); … … 54 55 } 55 56 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" ); 58 59 if ( id >= 0 ) { 59 60 vectors ( id ) ( ind ) = d; -
library/bdm/base/user_info.cpp
r540 r565 33 33 setAutoConvert ( true ); 34 34 } 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 ); 36 39 } catch ( ParseException& P ) { 37 40 stringstream msg; 38 41 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() ); 40 43 } 41 44 } … … 46 49 writeFile ( file_name.c_str() ); 47 50 } 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 ); 49 55 } 50 56 } … … 94 100 msg << "There is not any registered class yet!" << endl; 95 101 96 it_error ( msg.str() );102 bdm_error ( msg.str() ); 97 103 } 98 104 -
library/bdm/base/user_info.h
r544 r565 321 321 322 322 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" ); 324 324 325 325 instance = dynamic_cast<T*> ( typeless_instance ); … … 351 351 T *tmp_inst = 0; 352 352 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" ); 354 354 instance = tmp_inst; 355 355 }