From 35748cd7ea58c7dce30630d22f51d5d95b0c9ae8 Mon Sep 17 00:00:00 2001 From: astrojhgu Date: Sat, 5 Sep 2009 17:32:18 +0000 Subject: git-svn-id: file:///home/svn/opt_utilities@61 ed2142bd-67ad-457f-ba7c-d818d4011675 --- core/fitter.hpp | 87 ++++++++++++++++++++++++++++++++++++++++++++----- core/optimizer.hpp | 4 --- test/makefile | 2 +- test/test_optimizer.cpp | 6 +++- 4 files changed, 85 insertions(+), 14 deletions(-) diff --git a/core/fitter.hpp b/core/fitter.hpp index 398282d..5a2cba4 100644 --- a/core/fitter.hpp +++ b/core/fitter.hpp @@ -555,8 +555,8 @@ namespace opt_utilities /** clear the param modifier - */ - void set_param_modifier() + */ + void clear_param_modifier() { if(p_param_modifier!=0) { @@ -579,6 +579,17 @@ namespace opt_utilities return *p_param_modifier; } + /** + \return the param_modifier + */ + const param_modifier& get_param_modifier()const + { + if(p_param_modifier==0) + { + throw param_modifier_undefined(); + } + return *p_param_modifier; + } /** report the param status @@ -600,9 +611,9 @@ namespace opt_utilities \param pname the name of the param \return the param info */ - const param_info& get_param_info(const Tstr& pname) + const param_info& get_param_info(const Tstr& pname)const { - for(typename std::vector >::iterator i=param_info_list.begin(); + for(typename std::vector >::const_iterator i=param_info_list.begin(); i!=param_info_list.end();++i) { if(i->get_name()==pname) @@ -1081,13 +1092,13 @@ namespace opt_utilities /** clear the param modifier */ - void set_param_modifier() + void clear_param_modifier() { if(p_model==0) { throw model_undefined(); } - p_model->set_param_modifier(); + p_model->clear_param_modifier(); } @@ -1104,6 +1115,19 @@ namespace opt_utilities return p_model->get_param_modifier(); } + /** + Get the inner kept param modifier + \return the reference of param_modifier + */ + const param_modifier& get_param_modifier()const + { + if(p_model==0) + { + throw model_undefined(); + } + return p_model->get_param_modifier(); + } + /** report the status of a parameter \param s the name of a parameter @@ -1136,6 +1160,19 @@ namespace opt_utilities } } + /** + get the data set that have been loaded + \return the const reference of inner data_set + */ + data_set& get_data_set() + { + if(p_data_set==0) + { + throw data_unloaded(); + } + return *(this->p_data_set); + } + /** get the data set that have been loaded @@ -1163,6 +1200,19 @@ namespace opt_utilities return *(this->p_model); } + /** + Get the model used + \return the reference of model used + */ + const model& get_model()const + { + if(p_model==0) + { + throw model_undefined(); + } + return *(this->p_model); + } + /** Get the statistic used \return the reference of the statistic used @@ -1175,16 +1225,37 @@ namespace opt_utilities } return *(this->p_statistic); } + + /** + Get the statistic used + \return the reference of the statistic used + */ + const statistic& get_statistic()const + { + if(p_statistic==0) + { + throw statistic_undefined(); + } + return *(this->p_statistic); + } /** Get the optimization method that used \return the reference of the opt_method */ - opt_method& get_method() + opt_method& get_opt_method() { return optengine.method(); } + /** + Get the optimization method that used + \return the reference of the opt_method + */ + const opt_method& get_opt_method()const + { + return optengine.method(); + } public: /** @@ -1390,7 +1461,7 @@ namespace opt_utilities set the optimization method used to perform the model fitting \param pm the opt_method to be used */ - void set_method(const opt_method& pm) + void set_opt_method(const opt_method& pm) { //assert(p_optimizer!=0); optengine.set_opt_method(pm); diff --git a/core/optimizer.hpp b/core/optimizer.hpp index 6ea5e68..a6e0106 100644 --- a/core/optimizer.hpp +++ b/core/optimizer.hpp @@ -596,10 +596,6 @@ namespace opt_utilities func_obj* ptr_func_obj() { - if(p_func_obj==0) - { - throw object_function_undefined(); - } return p_func_obj; } diff --git a/test/makefile b/test/makefile index a801d7b..e850e82 100644 --- a/test/makefile +++ b/test/makefile @@ -3,7 +3,7 @@ targets=test_optimizer all:$(targets) test_optimizer:test_optimizer.cpp - $(CXX) $< -o $@ -I .. -O3 + $(CXX) $< -o $@ -I .. -O3 -g clean: diff --git a/test/test_optimizer.cpp b/test/test_optimizer.cpp index b6d70a7..8d0b405 100644 --- a/test/test_optimizer.cpp +++ b/test/test_optimizer.cpp @@ -1,3 +1,5 @@ +#define private public +#include #include #include //#include @@ -120,8 +122,10 @@ void test_opt(const func_obj >& fo, { const int problem_size=5; optimizer > opt; - opt.set_opt_method(optm); + opt.set_func_obj(fo); + opt.set_opt_method(optm); + vector p(problem_size); for(int i=0;i