diff options
author | astrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675> | 2009-09-05 16:17:32 +0000 |
---|---|---|
committer | astrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675> | 2009-09-05 16:17:32 +0000 |
commit | 07139e38b8d6baadc30443c7f20551908b3db491 (patch) | |
tree | ec236eee44736f8fa00de30e3de07422bf91b67d | |
parent | f6773e55b1025d13647a84702833cc8dc3f08d88 (diff) | |
download | opt-utilities-07139e38b8d6baadc30443c7f20551908b3db491.tar.bz2 |
git-svn-id: file:///home/svn/opt_utilities@60 ed2142bd-67ad-457f-ba7c-d818d4011675
-rw-r--r-- | core/optimizer.hpp | 156 | ||||
-rw-r--r-- | methods/aga/aga.hpp | 19 | ||||
-rw-r--r-- | methods/gsl_simplex/gsl_simplex.hpp | 10 | ||||
-rw-r--r-- | methods/powell/powell_method.hpp | 10 |
4 files changed, 194 insertions, 1 deletions
diff --git a/core/optimizer.hpp b/core/optimizer.hpp index 871da7b..6ea5e68 100644 --- a/core/optimizer.hpp +++ b/core/optimizer.hpp @@ -122,6 +122,12 @@ namespace opt_utilities \param th threshold */ virtual void do_set_precision(rT th)=0; + + /** + get the precision + \return threshold + */ + virtual rT do_get_precision()const=0; /** perform the optimization \return final optimized parameter. @@ -139,6 +145,25 @@ namespace opt_utilities \param p the upper limit */ virtual void do_set_upper_limit(const pT& p){}; + + /** + \return start point + */ + virtual pT do_get_start_point()const=0; + /** + \return the lower limit + */ + virtual pT do_get_lower_limit()const + { + return pT(); + }; + /** + \return the upper limit + */ + virtual pT do_get_upper_limit()const + { + return pT(); + }; /** \return the clone of current object */ @@ -168,6 +193,15 @@ namespace opt_utilities { do_set_precision(x); } + + /** + \return precision + */ + + rT get_precision()const + { + return do_get_precision(); + } /** Interface function to set start point @@ -177,6 +211,14 @@ namespace opt_utilities { do_set_start_point(p); } + + /** + \return start point + */ + pT get_start_point()const + { + return do_get_start_point(); + } /** Interface function to set lower limit @@ -189,6 +231,15 @@ namespace opt_utilities } /** + \return lower limit + */ + + pT get_lower_limit()const + { + return do_get_lower_limit(); + } + + /** Interface function to set upper limit \param p upper limit */ @@ -199,6 +250,15 @@ namespace opt_utilities } /** + \return upper limit + */ + + pT get_upper_limit()const + { + return do_get_upper_limit(); + } + + /** Interface function for performing the optimization \return the optimized parameter. */ @@ -366,7 +426,7 @@ namespace opt_utilities /** \return a reference of internally kept optimization method */ - opt_method<rT,pT>& method() + opt_method<rT,pT>& get_opt_method() { if(p_opt_method==0) { @@ -375,6 +435,19 @@ namespace opt_utilities return *(this->p_opt_method); } + + /** + \return a const reference of internally kept optimization method + */ + const opt_method<rT,pT>& get_opt_method()const + { + if(p_opt_method=0) + { + throw opt_method_undefined(); + } + return *(this->p_opt_method); + } + /** set precision @@ -389,6 +462,19 @@ namespace opt_utilities p_opt_method->set_precision(x); } + /** + \return precision + */ + + rT get_precision()const + { + if(p_opt_method==0) + { + throw opt_method_undefined(); + } + return p_opt_method->get_precision(); + } + /** set start point @@ -402,6 +488,19 @@ namespace opt_utilities } p_opt_method->set_start_point(x); } + + /** + \return start point + */ + + pT get_start_point()const + { + if(p_opt_method==0) + { + throw opt_method_undefined(); + } + return p_opt_method->get_start_point(); + } /** @@ -419,6 +518,19 @@ namespace opt_utilities /** + \return lower limit + */ + pT get_lower_limit()const + { + if(p_opt_method==0) + { + throw opt_method_undefined(); + } + return p_opt_method->get_lower_limit(); + } + + + /** set upper limit \param x upper limit */ @@ -430,6 +542,19 @@ namespace opt_utilities } p_opt_method->set_upper_limit(x); } + + /** + \return upper limit + */ + + pT get_upper_limit()const + { + if(p_opt_method==0) + { + throw opt_method_undefined(); + } + return p_opt_method->get_upper_limit(); + } /** @@ -468,11 +593,40 @@ namespace opt_utilities /** \return the pointer to the inner object function */ + func_obj<rT,pT>* ptr_func_obj() { + if(p_func_obj==0) + { + throw object_function_undefined(); + } return p_func_obj; } + + + /** + \return the reference of the internal kept func_obj object + */ + func_obj<rT,pT>& get_func_obj() + { + if(p_func_obj==0) + { + throw object_function_undefined(); + } + return *p_func_obj; + } + /** + \return the const reference of the internal kept func_obj object + */ + const func_obj<rT,pT>& get_func_obj()const + { + if(p_func_obj==0) + { + throw object_function_undefined(); + } + return *p_func_obj; + } }; } diff --git a/methods/aga/aga.hpp b/methods/aga/aga.hpp index 0cde38d..8878953 100644 --- a/methods/aga/aga.hpp +++ b/methods/aga/aga.hpp @@ -152,17 +152,31 @@ namespace opt_utilities } } + + array1d_type do_get_start_point()const + { + return array1d_type(); + } void do_set_lower_limit(const array1d_type& p) { opt_eq(lower_bound,p); } + array1d_type do_get_lower_limit()const + { + return lower_bound; + } void do_set_upper_limit(const array1d_type& p) { opt_eq(upper_bound,p); } + + array1d_type do_get_upper_limit()const + { + return upper_bound; + } void do_set_precision(rT t) @@ -170,6 +184,11 @@ namespace opt_utilities threshold=t; } + rT do_get_precision()const + { + return threshold; + } + void do_set_optimizer(optimizer<rT,pT>& o) { p_optimizer=&o; diff --git a/methods/gsl_simplex/gsl_simplex.hpp b/methods/gsl_simplex/gsl_simplex.hpp index cb26ac6..5297e7a 100644 --- a/methods/gsl_simplex/gsl_simplex.hpp +++ b/methods/gsl_simplex/gsl_simplex.hpp @@ -106,11 +106,21 @@ namespace opt_utilities } + array1d_type do_get_start_point()const + { + return start_point; + } + void do_set_precision(rT t) { threshold=t; } + rT do_get_precision()const + { + return threshold; + } + void do_set_optimizer(optimizer<rT,pT>& o) { p_optimizer=&o; diff --git a/methods/powell/powell_method.hpp b/methods/powell/powell_method.hpp index 6256b5b..1562fdf 100644 --- a/methods/powell/powell_method.hpp +++ b/methods/powell/powell_method.hpp @@ -207,6 +207,11 @@ namespace opt_utilities opt_eq(start_point,p); } + array1d_type do_get_start_point()const + { + return start_point; + } + void do_set_lower_limit(const array1d_type& p) {} @@ -218,6 +223,11 @@ namespace opt_utilities threshold=t; } + rT do_get_precision()const + { + return threshold; + } + void do_set_optimizer(optimizer<rT,pT>& o) { p_optimizer=&o; |