From 07139e38b8d6baadc30443c7f20551908b3db491 Mon Sep 17 00:00:00 2001 From: astrojhgu Date: Sat, 5 Sep 2009 16:17:32 +0000 Subject: git-svn-id: file:///home/svn/opt_utilities@60 ed2142bd-67ad-457f-ba7c-d818d4011675 --- core/optimizer.hpp | 156 +++++++++++++++++++++++++++++++++++- methods/aga/aga.hpp | 19 +++++ methods/gsl_simplex/gsl_simplex.hpp | 10 +++ methods/powell/powell_method.hpp | 10 +++ 4 files changed, 194 insertions(+), 1 deletion(-) 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 @@ -188,6 +230,15 @@ namespace opt_utilities do_set_lower_limit(p); } + /** + \return lower limit + */ + + pT get_lower_limit()const + { + return do_get_lower_limit(); + } + /** Interface function to set upper limit \param p upper limit @@ -198,6 +249,15 @@ namespace opt_utilities do_set_upper_limit(p); } + /** + \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& method() + opt_method& 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& 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(); + } /** @@ -418,6 +517,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* 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& 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& 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& 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& 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& o) { p_optimizer=&o; -- cgit v1.2.2