Changeset 956
- Timestamp:
- 05/19/10 03:56:03 (15 years ago)
- Location:
- library/bdm
- Files:
-
- 9 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/base/bdmbase.cpp
r953 r956 460 460 } 461 461 462 void epdf::from_setting ( const Setting &set ) { 463 root::from_setting( set ); 464 UI::get(rv, set, "rv", UI::optional ); 465 } 466 467 void epdf::to_setting ( Setting &set ) const { 468 // we do not want to store rvc, therfore, pdf::to_setting( set ) is omitted 469 root::to_setting(set); 470 471 UI::save( &rv, set, "rv" ); 472 } 462 473 463 474 -
library/bdm/base/bdmbase.h
r953 r956 761 761 //! \endcode 762 762 //!@} 763 void from_setting ( const Setting &set ) { 764 root::from_setting( set ); 765 UI::get(rv, set, "rv", UI::optional ); 766 } 767 768 void to_setting ( Setting &set ) const { 769 // we do not want to store rvc, therfore, pdf::to_setting( set ) is omitted 770 root::to_setting(set); 771 772 UI::save( &rv, set, "rv" ); 773 } 763 void from_setting ( const Setting &set ); 764 void to_setting ( Setting &set ) const; 774 765 775 766 vec samplecond ( const vec &cond ) { … … 814 805 815 806 void validate() { 807 pdf::validate(); 816 808 iepdf.validate(); 817 809 if ( rv._dsize() < iepdf._rv()._dsize() ) { -
library/bdm/base/itpp/base/itfile.h
r813 r956 367 367 //! Remove slack space from the file 368 368 void pack(); 369 370 std::string get_fname(){ 371 return fname; 372 } 369 373 370 374 protected: -
library/bdm/stat/emix.cpp
r900 r956 4 4 5 5 void emix_base::validate (){ 6 epdf::validate(); 6 7 bdm_assert ( no_coms() > 0, "There has to be at least one component." ); 7 8 … … 116 117 117 118 void emix::from_setting ( const Setting &set ) { 119 emix_base::from_setting(set); 118 120 UI::get ( Coms, set, "pdfs", UI::compulsory ); 119 121 UI::get ( w, set, "weights", UI::compulsory ); 120 122 } 123 void emix::to_setting (Setting &set) const { 124 emix_base::to_setting(set); 125 UI::save(Coms, set, "pdfs"); 126 UI::save( w, set, "weights"); 127 } 128 121 129 122 130 void emix::validate (){ … … 179 187 } 180 188 189 void mprod::from_setting ( const Setting &set ) { 190 pdf::from_setting(set); 191 Array<shared_ptr<pdf> > temp_array; 192 UI::get ( temp_array, set, "pdfs", UI::compulsory ); 193 set_elements ( temp_array ); 194 } 195 void mprod::to_setting (Setting &set) const { 196 pdf::to_setting(set); 197 UI::save( pdfs, set, "pdfs"); 198 } 199 181 200 void mmix::validate() 182 { 201 { pdf::validate(); 183 202 bdm_assert ( Coms.length() > 0, "There has to be at least one component." ); 184 203 … … 208 227 209 228 void mmix::from_setting ( const Setting &set ) { 229 230 pdf::from_setting(set); 210 231 UI::get ( Coms, set, "pdfs", UI::compulsory ); 211 232 … … 215 236 w = 1.0 / len; 216 237 } 238 } 239 240 void mmix::to_setting (Setting &set) const { 241 pdf::to_setting(set); 242 UI::save( Coms, set, "pdfs"); 243 UI::save( w, set, "weights"); 217 244 } 218 245 -
library/bdm/stat/emix.h
r944 r956 191 191 //!@} 192 192 void from_setting ( const Setting &set ); 193 void to_setting (Setting &set) const; 193 194 194 195 void set_rv ( const RV &rv ) { … … 262 263 //! \endcode 263 264 //!@} 264 void from_setting ( const Setting &set ) { 265 Array<shared_ptr<pdf> > temp_array; 266 UI::get ( temp_array, set, "pdfs", UI::compulsory ); 267 set_elements ( temp_array ); 268 } 265 void from_setting ( const Setting &set ) ; 266 void to_setting (Setting &set) const; 267 268 269 269 }; 270 270 UIREGISTER ( mprod ); … … 300 300 } 301 301 void validate() { 302 epdf::validate(); 302 303 dls.set_length ( no_factors() ); 303 304 … … 387 388 //!@} 388 389 void from_setting ( const Setting &set ); 389 390 void to_setting (Setting &set) const; 390 391 virtual void validate(); 391 392 }; -
library/bdm/stat/exp_family.cpp
r910 r956 326 326 } 327 327 328 void egiw::from_setting ( const Setting &set ) { 329 epdf::from_setting ( set ); 330 UI::get ( dimx, set, "dimx", UI::compulsory ); 331 if ( !UI::get ( nu, set, "nu", UI::optional ) ) { 332 nu = -1; 333 } 334 mat V; 335 if ( !UI::get ( V, set, "V", UI::optional ) ) { 336 vec dV; 337 UI::get ( dV, set, "dV", UI::compulsory ); 338 set_parameters ( dimx, ldmat ( dV ), nu ); 339 340 } else { 341 set_parameters ( dimx, V, nu ); 342 } 343 } 344 345 void egiw::to_setting ( Setting& set ) const { 346 epdf::to_setting ( set ); 347 UI::save ( dimx, set, "dimx" ); 348 UI::save ( V.to_mat(), set, "V" ); 349 UI::save ( nu, set, "nu" ); 350 }; 351 352 void egiw::validate() { 353 eEF::validate(); 354 dim = dimx * ( dimx + nPsi ); 355 356 // check sizes, rvs etc. 357 // also check if RV are meaningful!!! 358 // meaningful = rv for theta and rv for r are split! 359 } 328 360 void multiBM::bayes ( const vec &yt, const vec &cond ) { 329 361 if ( frg < 1.0 ) { … … 421 453 } 422 454 455 void egamma::from_setting ( const Setting &set ) { 456 epdf::from_setting ( set ); // reads rv 457 UI::get ( alpha, set, "alpha", UI::compulsory ); 458 UI::get ( beta, set, "beta", UI::compulsory ); 459 } 460 461 void egamma::to_setting ( Setting &set ) const 462 { 463 epdf::to_setting( set ); 464 UI::save( alpha, set, "alpha" ); 465 UI::save( beta, set, "beta" ); 466 } 467 468 469 void egamma::validate() { 470 eEF::validate(); 471 bdm_assert ( alpha.length() == beta.length(), "parameters do not match" ); 472 dim = alpha.length(); 473 } 474 423 475 void mgamma::set_parameters ( double k0, const vec &beta0 ) { 424 476 k = k0; 425 477 iepdf.set_parameters ( k * ones ( beta0.length() ), beta0 ); 426 478 } 479 480 481 void mgamma::from_setting ( const Setting &set ) { 482 pdf::from_setting ( set ); // reads rv and rvc 483 vec betatmp; // ugly but necessary 484 UI::get ( betatmp, set, "beta", UI::compulsory ); 485 UI::get ( k, set, "k", UI::compulsory ); 486 set_parameters ( k, betatmp ); 487 } 488 489 void mgamma::to_setting (Setting &set) const { 490 pdf::to_setting(set); 491 UI::save( _beta, set, "beta"); 492 UI::save( k, set, "k"); 493 494 } 495 496 void mgamma::validate() { 497 pdf_internal<egamma>::validate(); 498 499 dim = _beta.length(); 500 dimc = _beta.length(); 501 } 427 502 428 503 void eEmp::resample ( RESAMPLING_METHOD method ) { … … 536 611 537 612 void migamma_ref::from_setting ( const Setting &set ) { 613 migamma::from_setting(set); 538 614 vec ref; 539 615 UI::get ( ref, set, "ref" , UI::compulsory ); … … 541 617 validate(); 542 618 } 543 619 void migamma_ref::to_setting (Setting &set) const { 620 migamma::to_setting(set); 621 UI::save ( pow ( refl, 1/(1.0 - l) ), set, "ref"); 622 UI::save(l,set,"l"); 623 UI::save(k,set,"k"); 624 } 544 625 void mlognorm::from_setting ( const Setting &set ) { 626 pdf_internal<elognorm>::from_setting(set); 545 627 vec mu0; 546 628 UI::get ( mu0, set, "mu0", UI::compulsory ); 547 629 set_parameters ( mu0.length(), set["k"] ); 548 validate();549 630 condition ( mu0 ); 550 631 } 632 633 634 void mlognorm::to_setting (Setting &set) const { 635 pdf_internal<elognorm>::to_setting(set); 636 UI::save ( exp(mu + sig2), set, "mu0"); 637 } 638 551 639 552 640 void mlstudent::condition ( const vec &cond ) { … … 586 674 } 587 675 676 void eEmp::to_setting ( Setting &set ) const { 677 epdf::to_setting( set ); 678 UI::save ( samples, set, "samples" ); 679 UI::save ( w, set, "w" ); 680 } 681 682 void eEmp::from_setting ( const Setting &set ) { 683 epdf::from_setting( set ); 684 685 UI::get( samples, set, "samples", UI::compulsory ); 686 UI::get ( w, set, "w", UI::compulsory ); 687 } 688 689 void eEmp::validate (){ 690 epdf::validate(); 691 bdm_assert (samples.length()==w.length(),"samples and weigths are of different lengths"); 692 n = w.length(); 693 if (n>0) 694 pdf::dim = samples ( 0 ).length(); 695 } 696 697 void eDirich::from_setting ( const Setting &set ) { 698 epdf::from_setting ( set ); 699 UI::get ( beta, set, "beta", UI::compulsory ); 700 } 701 void eDirich::validate() { 702 //check rv 703 eEF::validate(); 704 dim = beta.length(); 705 } 706 707 void eDirich::to_setting ( Setting &set ) const 708 { 709 eEF::to_setting( set ); 710 UI::save( beta, set, "beta" ); 711 } 712 713 void euni::from_setting ( const Setting &set ) { 714 epdf::from_setting ( set ); // reads rv and rvc 715 716 UI::get ( high, set, "high", UI::compulsory ); 717 UI::get ( low, set, "low", UI::compulsory ); 718 set_parameters ( low, high ); 719 720 } 721 722 void euni::to_setting (Setting &set) const { 723 epdf::to_setting ( set ); 724 UI::save ( high, set, "high" ); 725 UI::save ( low, set, "low" ); 726 } 727 728 void euni::validate() { 729 epdf::validate(); 730 bdm_assert ( high.length() == low.length(), "Incompatible high and low vectors" ); 731 dim = high.length(); 732 bdm_assert ( min ( distance ) > 0.0, "bad support" ); 733 } 734 735 void mgdirac::from_setting(const Setting& set){ 736 pdf::from_setting(set); 737 g=UI::build<fnc>(set,"g",UI::compulsory); 738 validate(); 739 } 740 void mgdirac::to_setting(Setting &set) const{ 741 pdf::to_setting(set); 742 UI::save(g.get(), set, "g"); 743 } 744 void mgdirac::validate() { 745 pdf::validate(); 746 dim = g->dimension(); 747 dimc = g->dimensionc(); 748 } 749 750 void mDirich::from_setting ( const Setting &set ) { 751 pdf::from_setting ( set ); // reads rv and rvc 752 if ( _rv()._dsize() > 0 ) { 753 rvc = _rv().copy_t ( -1 ); 754 } 755 vec beta0; 756 if ( !UI::get ( beta0, set, "beta0", UI::optional ) ) { 757 beta0 = ones ( _rv()._dsize() ); 758 } 759 if ( !UI::get ( betac, set, "betac", UI::optional ) ) { 760 betac = 0.1 * ones ( _rv()._dsize() ); 761 } 762 _beta = beta0; 763 764 UI::get ( k, set, "k", UI::compulsory ); 765 } 766 767 void mDirich::to_setting (Setting &set) const { 768 pdf::to_setting(set); 769 UI::save( _beta, set, "beta0"); 770 UI::save( betac, set, "betac"); 771 UI::save ( k, set, "k" ); 772 } 773 774 775 void mDirich::validate() { 776 pdf_internal<eDirich>::validate(); 777 bdm_assert ( _beta.length() == betac.length(), "beta0 and betac are not compatible" ); 778 if ( _rv()._dsize() > 0 ) { 779 bdm_assert ( ( _rv()._dsize() == dimension() ) , "Size of rv does not match with beta" ); 780 } 781 dimc = _beta.length(); 782 } 588 783 589 784 }; -
library/bdm/stat/exp_family.h
r951 r956 133 133 return std::numeric_limits< double >::max(); 134 134 } 135 void from_setting(const Setting& set){ 136 pdf::from_setting(set); 137 g=UI::build<fnc>(set,"g",UI::compulsory); 138 validate(); 139 } 140 void to_setting(Setting &set) const{ 141 pdf::to_setting(set); 142 UI::save(g.get(), set, "g"); 143 } 144 void validate() { 145 dim = g->dimension(); 146 dimc = g->dimensionc(); 147 } 135 void from_setting(const Setting& set); 136 void to_setting(Setting &set) const; 137 void validate(); 148 138 }; 149 139 UIREGISTER(mgdirac); … … 186 176 void to_setting ( Setting &root ) const ; 187 177 188 void validate() { 189 bdm_assert ( mu.length() == R.rows(), "mu and R parameters do not match" ); 190 dim = mu.length(); 191 } 178 void validate(); 192 179 //!@} 193 180 … … 336 323 } 337 324 void validate() { 325 eEF::validate(); 338 326 dim = H.rows(); 339 327 } … … 460 448 \sa log_level_enums 461 449 */ 462 void from_setting ( const Setting &set ) { 463 epdf::from_setting ( set ); 464 UI::get ( dimx, set, "dimx", UI::compulsory ); 465 if ( !UI::get ( nu, set, "nu", UI::optional ) ) { 466 nu = -1; 467 } 468 mat V; 469 if ( !UI::get ( V, set, "V", UI::optional ) ) { 470 vec dV; 471 UI::get ( dV, set, "dV", UI::compulsory ); 472 set_parameters ( dimx, ldmat ( dV ), nu ); 473 validate(); 474 475 } else { 476 set_parameters ( dimx, V, nu ); 477 validate(); 478 } 479 } 480 481 void to_setting ( Setting& set ) const { 482 epdf::to_setting ( set ); 483 UI::save ( dimx, set, "dimx" ); 484 UI::save ( V.to_mat(), set, "V" ); 485 UI::save ( nu, set, "nu" ); 486 }; 487 488 void validate() { 489 dim = dimx * ( dimx + nPsi ); 490 491 // check sizes, rvs etc. 492 // also check if RV are meaningful!!! 493 // meaningful = rv for theta and rv for r are split! 494 } 450 void from_setting ( const Setting &set ); 451 void to_setting ( Setting& set ) const; 452 void validate(); 495 453 void log_register ( bdm::logger& L, const string& prefix ); 496 454 … … 578 536 \endcode 579 537 */ 580 void from_setting ( const Setting &set ) { 581 epdf::from_setting ( set ); 582 UI::get ( beta, set, "beta", UI::compulsory ); 583 validate(); 584 } 585 void validate() { 586 //check rv 587 dim = beta.length(); 588 } 589 590 void to_setting ( Setting &set ) const 591 { 592 eEF::to_setting( set ); 593 UI::save( beta, set, "beta" ); 594 } 538 void from_setting ( const Setting &set ); 539 void validate(); 540 void to_setting ( Setting &set ) const; 595 541 }; 596 542 UIREGISTER ( eDirich ); … … 632 578 \endcode 633 579 */ 634 void from_setting ( const Setting &set ) { 635 pdf::from_setting ( set ); // reads rv and rvc 636 if ( _rv()._dsize() > 0 ) { 637 rvc = _rv().copy_t ( -1 ); 638 } 639 vec beta0; 640 if ( !UI::get ( beta0, set, "beta0", UI::optional ) ) { 641 beta0 = ones ( _rv()._dsize() ); 642 } 643 if ( !UI::get ( betac, set, "betac", UI::optional ) ) { 644 betac = 0.1 * ones ( _rv()._dsize() ); 645 } 646 _beta = beta0; 647 648 UI::get ( k, set, "k", UI::compulsory ); 649 validate(); 650 } 651 void validate() { 652 pdf_internal<eDirich>::validate(); 653 bdm_assert ( _beta.length() == betac.length(), "beta0 and betac are not compatible" ); 654 if ( _rv()._dsize() > 0 ) { 655 bdm_assert ( ( _rv()._dsize() == dimension() ) , "Size of rv does not match with beta" ); 656 } 657 dimc = _beta.length(); 658 }; 580 void from_setting ( const Setting &set ); 581 void to_setting (Setting &set) const; 582 void validate(); 659 583 }; 660 584 UIREGISTER ( mDirich ); … … 765 689 \endcode 766 690 */ 767 void from_setting ( const Setting &set ) { 768 epdf::from_setting ( set ); // reads rv 769 UI::get ( alpha, set, "alpha", UI::compulsory ); 770 UI::get ( beta, set, "beta", UI::compulsory ); 771 validate(); 772 } 773 void validate() { 774 bdm_assert ( alpha.length() == beta.length(), "parameters do not match" ); 775 dim = alpha.length(); 776 } 691 void from_setting ( const Setting &set ); 692 void to_setting ( Setting &set ) const; 693 void validate(); 777 694 }; 778 695 UIREGISTER ( egamma ); … … 888 805 \endcode 889 806 */ 890 void from_setting ( const Setting &set ) { 891 epdf::from_setting ( set ); // reads rv and rvc 892 893 UI::get ( high, set, "high", UI::compulsory ); 894 UI::get ( low, set, "low", UI::compulsory ); 895 set_parameters ( low, high ); 896 validate(); 897 } 898 void validate() { 899 bdm_assert ( high.length() == low.length(), "Incompatible high and low vectors" ); 900 dim = high.length(); 901 bdm_assert ( min ( distance ) > 0.0, "bad support" ); 902 } 807 void from_setting ( const Setting &set ); 808 void to_setting (Setting &set) const; 809 void validate(); 903 810 }; 904 811 UIREGISTER ( euni ); … … 922 829 iepdf.set_parameters ( -delta, delta ); 923 830 } 924 831 void to_setting (Setting &set) const { 832 pdf::to_setting ( set ); 833 UI::save( iepdf.mean(), set, "delta"); 834 UI::save(mean, set, "mean"); 835 } 925 836 void validate(){ 837 pdf_internal<euni>::validate(); 926 838 dimc = mean->dimensionc(); 927 iepdf.validate();839 928 840 } 929 841 … … 1006 918 UI::get ( R0, set, "R", UI::compulsory ); 1007 919 set_parameters ( A, mu_const, R0 ); 1008 validate();1009 }; 1010 920 } 921 922 void to_setting (Setting &set) const { 1011 923 pdf::to_setting(set); 1012 924 UI::save ( A, set, "A"); … … 1014 926 UI::save ( _R(), set, "R"); 1015 927 } 1016 void validate() { 928 929 void validate() { 1017 930 pdf_internal<TEpdf<sq_T> >::validate(); 1018 931 if (mu_const.length()==0) { // default in from_setting … … 1070 983 */ 1071 984 1072 void from_setting ( const Setting &set ) { 985 986 void from_setting ( const Setting &set ) { 1073 987 pdf::from_setting ( set ); 1074 988 shared_ptr<fnc> g = UI::build<fnc> ( set, "g", UI::compulsory ); … … 1084 998 //validate(); 1085 999 } 1086 void validate() { 1000 1001 1002 void to_setting (Setting &set) const { 1003 UI::save( g,set, "g"); 1004 UI::save(iepdf._R().to_mat(),set, "R"); 1005 1006 } 1007 1008 1009 1010 void validate() { 1087 1011 this->iepdf.validate(); 1088 1012 bdm_assert ( g->dimension() == this->iepdf.dimension(), "incompatible function" ); … … 1091 1015 this->iepdf.validate(); 1092 1016 } 1017 1093 1018 }; 1094 1019 … … 1128 1053 1129 1054 void validate() { 1055 mlnorm<ldmat, enorm>::validate(); 1130 1056 bdm_assert ( A.rows() == mu_const.length(), "mlstudent: A vs. mu mismatch" ); 1131 1057 bdm_assert ( _R.rows() == A.rows(), "mlstudent: A vs. R mismatch" ); … … 1175 1101 \endcode 1176 1102 */ 1177 void from_setting ( const Setting &set ) { 1178 pdf::from_setting ( set ); // reads rv and rvc 1179 vec betatmp; // ugly but necessary 1180 UI::get ( betatmp, set, "beta", UI::compulsory ); 1181 UI::get ( k, set, "k", UI::compulsory ); 1182 set_parameters ( k, betatmp ); 1183 validate(); 1184 } 1185 void validate() { 1186 pdf_internal<egamma>::validate(); 1187 1188 dim = _beta.length(); 1189 dimc = _beta.length(); 1190 } 1103 void from_setting ( const Setting &set ); 1104 void to_setting (Setting &set) const; 1105 void validate(); 1191 1106 }; 1192 1107 UIREGISTER ( mgamma ); … … 1236 1151 1237 1152 void validate (){ 1238 iepdf.validate();1153 pdf_internal<eigamma>::validate(); 1239 1154 dimc = dimension(); 1240 1155 }; … … 1338 1253 */ 1339 1254 void from_setting ( const Setting &set ); 1340 1255 void to_setting (Setting &set) const; 1341 1256 // TODO dodelat void to_setting( Setting &set ) const; 1342 1257 }; … … 1395 1310 1396 1311 void validate(){ 1397 iepdf.validate();1312 pdf_internal<elognorm>::validate(); 1398 1313 dimc = iepdf.dimension(); 1399 1314 } … … 1415 1330 */ 1416 1331 void from_setting ( const Setting &set ); 1332 void to_setting (Setting &set) const; 1417 1333 1418 1334 // TODO dodelat void to_setting( Setting &set ) const; … … 1449 1365 1450 1366 virtual void validate (){ 1367 epdf::validate(); 1451 1368 dim = p * p; 1452 1369 } … … 1519 1436 1520 1437 virtual void validate (){ 1438 epdf::validate(); 1521 1439 W.validate(); 1522 1440 dim = W.dimension(); … … 1594 1512 1595 1513 void validate(){ 1596 iepdf.validate();1514 pdf_internal<eiWishartCh>::validate(); 1597 1515 dimc = iepdf.dimension(); 1598 1516 } … … 1657 1575 samples = Av; 1658 1576 }; 1659 virtual void validate (){ 1660 bdm_assert (samples.length()==w.length(),"samples and weigths are of different lengths"); 1661 n = w.length(); 1662 if (n>0) 1663 pdf::dim = samples ( 0 ).length(); 1664 } 1577 virtual void validate (); 1665 1578 //! Potentially dangerous, use with care. 1666 1579 vec& _w() { … … 1709 1622 void qbounds ( vec &lb, vec &ub, double perc = 0.95 ) const; 1710 1623 1711 void to_setting ( Setting &set ) const { 1712 epdf::to_setting( set ); 1713 UI::save ( samples, set, "samples" ); 1714 UI::save ( w, set, "w" ); 1715 } 1716 1717 void from_setting ( const Setting &set ) { 1718 epdf::from_setting( set ); 1719 1720 UI::get( samples, set, "samples", UI::compulsory ); 1721 UI::get ( w, set, "w", UI::compulsory ); 1722 validate(); 1723 } 1624 void to_setting ( Setting &set ) const; 1625 void from_setting ( const Setting &set ); 1724 1626 1725 1627 }; … … 1745 1647 UI::get ( Rtmp, set, "R", UI::compulsory ); 1746 1648 R = Rtmp; // conversion 1747 validate();1748 1649 } 1650 1651 template<class sq_T> 1652 void enorm<sq_T>::validate() { 1653 eEF::validate(); 1654 bdm_assert ( mu.length() == R.rows(), "mu and R parameters do not match" ); 1655 dim = mu.length(); 1656 } 1749 1657 1750 1658 template<class sq_T> … … 1754 1662 UI::save ( R.to_mat(), set, "R"); 1755 1663 } 1664 1665 1756 1666 1757 1667 template<class sq_T> -
library/bdm/stat/merger.cpp
r787 r956 9 9 set_sources ( S ); 10 10 } 11 11 12 12 13 void merger_base::set_sources ( const Array<shared_ptr<pdf> > &Sources ) { … … 348 349 } 349 350 351 void merger_mix::from_setting ( const Setting& set ) { 352 merger_base::from_setting ( set ); 353 Ncoms=DFLT_Ncoms; 354 UI::get( Ncoms, set, "ncoms", UI::optional ); 355 effss_coef=DFLT_effss_coef; 356 UI::get (effss_coef , set, "effss_coef", UI::optional); 357 stop_niter=10; 358 UI::get ( stop_niter, set,"stop_niter", UI::optional ); 359 360 } 361 362 void merger_mix::to_setting (Setting &set) const { 363 merger_base::to_setting(set); 364 UI::save( Ncoms, set, "ncoms"); 365 UI::save (effss_coef , set, "effss_coef"); 366 UI::save ( stop_niter, set,"stop_niter"); 367 368 } 369 370 void merger_mix::validate() { 371 merger_base::validate(); 372 bdm_assert(Ncoms>0,"Ncoms too small"); 373 } 374 375 void merger_base::from_setting ( const Setting& set ) { 376 // get support 377 // find which method to use 378 epdf::from_setting (set); 379 string meth_str; 380 UI::get<string> ( meth_str, set, "method", UI::compulsory ); 381 if ( !strcmp ( meth_str.c_str(), "arithmetic" ) ) 382 set_method ( ARITHMETIC ); 383 else { 384 if ( !strcmp ( meth_str.c_str(), "geometric" ) ) 385 set_method ( GEOMETRIC ); 386 else if ( !strcmp ( meth_str.c_str(), "lognormal" ) ) { 387 set_method ( LOGNORMAL ); 388 set.lookupValue ( "beta", beta ); 389 } 390 } 391 string dbg_file; 392 if ( UI::get ( dbg_file, set, "dbg_file" ) ) 393 set_debug_file ( dbg_file ); 394 //validate() - not used 395 } 396 397 void merger_base::to_setting (Setting &set) const { 398 epdf::to_setting(set); 399 400 UI::save( METHOD, set, "method"); 401 UI::save ( dbg_file->get_fname(), set, "dbg_file" ); 402 UI::save (beta, set, "beta" ); 403 } 404 405 void merger_base::validate() { 406 // bdm_assert ( eSmp._w().length() > 0, "Empty support, use set_support()." ); 407 // bdm_assert ( dim == eSmp._samples() ( 0 ).length(), "Support points and rv are not compatible!" ); 408 epdf::validate(); 409 bdm_assert ( isnamed(), "mergers must be named" ); 410 } 350 411 // DEFAULTS FOR MERGER_BASE 351 412 const MERGER_METHOD merger_base::DFLT_METHOD = LOGNORMAL; -
library/bdm/stat/merger.h
r799 r956 166 166 167 167 //! load from setting 168 void from_setting ( const Setting& set ) { 169 // get support 170 // find which method to use 171 string meth_str; 172 UI::get<string> ( meth_str, set, "method", UI::compulsory ); 173 if ( !strcmp ( meth_str.c_str(), "arithmetic" ) ) 174 set_method ( ARITHMETIC ); 175 else { 176 if ( !strcmp ( meth_str.c_str(), "geometric" ) ) 177 set_method ( GEOMETRIC ); 178 else if ( !strcmp ( meth_str.c_str(), "lognormal" ) ) { 179 set_method ( LOGNORMAL ); 180 set.lookupValue ( "beta", beta ); 181 } 182 } 183 string dbg_file; 184 if ( UI::get ( dbg_file, set, "dbg_file" ) ) 185 set_debug_file ( dbg_file ); 186 //validate() - not used 187 } 188 189 void validate() { 190 // bdm_assert ( eSmp._w().length() > 0, "Empty support, use set_support()." ); 191 // bdm_assert ( dim == eSmp._samples() ( 0 ).length(), "Support points and rv are not compatible!" ); 192 bdm_assert ( isnamed(), "mergers must be named" ); 193 } 168 void from_setting ( const Setting& set ); 169 170 void to_setting (Setting &set) const ; 171 172 void validate() ; 194 173 //!@} 195 174 }; … … 268 247 } 269 248 //! from_settings 270 void from_setting ( const Setting& set ) { 271 merger_base::from_setting ( set ); 272 Ncoms=DFLT_Ncoms; 273 UI::get( Ncoms, set, "ncoms", UI::optional ); 274 effss_coef=DFLT_effss_coef; 275 UI::get (effss_coef , set, "effss_coef", UI::optional); 276 stop_niter=10; 277 UI::get ( stop_niter, set,"stop_niter", UI::optional ); 278 279 validate(); 280 } 281 void validate() { 282 bdm_assert(Ncoms>0,"Ncoms too small"); 283 } 249 void from_setting ( const Setting& set ); 250 void to_setting (Setting &set) const; 251 void validate(); 284 252 285 253 //! @}