From 160345bdde08c88d860104c1741576f91b7e8f64 Mon Sep 17 00:00:00 2001 From: astrojhgu Date: Mon, 15 Dec 2008 07:51:14 +0000 Subject: git-svn-id: file:///home/svn/opt_utilities@2 ed2142bd-67ad-457f-ba7c-d818d4011675 --- history.log | 239 ------------------------------------------------------------ test.cc | 142 ------------------------------------ test1.cc | 149 ------------------------------------- 3 files changed, 530 deletions(-) delete mode 100644 history.log delete mode 100644 test.cc delete mode 100644 test1.cc diff --git a/history.log b/history.log deleted file mode 100644 index 7adefdd..0000000 --- a/history.log +++ /dev/null @@ -1,239 +0,0 @@ -2008 Jan 21 - changed all std::string in parameter table to const std::string& - version 2.9.12 -2008 Jan 22 - changed optimizer::eval(pT& x) -> optimizer::eval(const pT& x) - version 2.9 13 -2008 Jan 22 - changed data::set_x(Tx x)->data::set_x(const Tx& x) - version 2.9.14 -2008 Jan 22 - changed the parameter set_param_value to a const reference. - version 2.10.1 - -2008 Jan 23 - removed the declaration of init_model_map etc. in models.hpp - version 2.10.2 - -2008 Jan 24 - added get_strm1d() interface to models.hpp and models.cc - version 2.10.3 - -2008 Feb 11 - modified some mistakes in models/ modified the nr_util, add T() in '?' expressions - version 2.11.1 -2008 Feb 12 - modified powell_method.hpp to enable the lib work around apfloat - version 2.11.2 - -2008 Feb 19 - modified the design of the data_loaders, add members:load_from, deleted the friend template declear in the class. - modified the fitter class, corrected a bug which happens when all parameters are frozen, the fitter will crash. - version 2.11.3 - - -2008 March 14 - Added a condition compiling to the dynamical load model - - -2008 March 21 - Modified a contition compiling to the dynamical load model, changed the marco from LINUX__ to __linux__ - -2008 March 27 - Made std::unary_function the base class of func_obj - version 2.12.1 - -2008 April 18 - Added nbeta1d into the model list - version 2.12.2 - -2008 May 10 - Added a bremss model - Added an opt_type.hpp - version 2.12.3 - -2008 May 12 - Added the declearation of virtual dstr function to some class - version 2.12.4 - - -2008 May 13 - Modified the makefile, to generate liboptutil.a - version 2.12.5 - -2008 May 14 - Updated the c/fortran callable interface - version 2.12.6 - -2008 May 22 - Modified the symbol definition of interface - version 2.12.7 - -2008 June 1 - Added the in the file fitter.hpp - version 2.12.8 - -2008 June 12 - Added NFW1D model - Cleaned some warnings - version 2.12.9 - -2008 Jun 19 - Modified fit2d task. Enables it to write fits file. - version 2.12.10 - -2008 Jun 23 - Modified the LINUX marco in models.cc - version 2.12.11 - -2008 Jun 25 - Added a pow_model, to enable power computation on models. - version 2.12.12 - -2008 Jun 27 - Added the function to query the number of build-in 1d and 2d models. - version 2.12.13 - - -2008 Jul 1 - Added a to_string and corresponding do_to_string method to class model. - version 2.13.0 - - -2008 Jul 1 - Implemented the do_to_string method in most 1d models - version 2.13.1 - - -2008 Jul 7 - Added another gsl_simplex method to perform the optimization. - version 2.14.0 - -2008 Jul 8 - Modified one bug caused by the head inclusion. The should be included. - version 2.14.1 - - -2008 Jul 8 - Enables the optcli program to display model infomation - version 2.14.2 - -2008 Jul 8 - Changed the methods include of head files. - Version 2.14.3 - -2008 Jul 10 - Corrected the include of optimizer.hpp in gsl_methods/gsl_simplex.hpp - version 2.14.4 - -2008 Jul 12 - Corrected the ``comparison between signed and unsigned integer'' warning - version 2.14.5 - -2008 Jul 14 - Modified the interface get_data in data_set class. - Changed the return value from data to const data& - version 2.15.0 - -2008 Jul 19 - Corrected a bug in gsl_simplex.hpp - version 2.15.1 - -2008 Jul 21 - Corrected the makefile in interface/ - version 2.15.2 - -2008 Jul 22 - Moved some files from core/ to separated folder. - version 2.15.3 - -2008 Jul 22 - version 2.15.4 - -2008 Jul 24 - Modified the makefile - version 2.15.5 - -2008 Jul 24 - Changed the project name from optimizer to opt_utilities - version 2.15.6 - -2008 Jul 25 - Enable the 'ls' command to display with color - version 2.15.7 - -2008 Aug 15 - Changed the x[i] into get_element(x,i), - Changed the x.size() into get_size(x). - version 2.16.0 - -2008 Aug 15 - Some further modification, added opt_eq function to represent '=' operation. - version 2.16.1 - -2008 Aug 15 - Modified some bugs - version 2.16.2 - -2008 Aug 16 - Added a set_element function - version 2.16.3 - -2008 Aug 17 - Changed the argument type of opt_get from single 'T' to 'Tl' and 'Tr' - version 2.16.4 - -2008 Aug 18 - Make the makefile more standard. - version 2.16.5 - -2008 Aug 22 - Added the inclusion of in array_operation.h - version 2.16.6 - -2008 Aug 24 - Added ./termcap to the inclusion of CFLAG - version 2.16.7 - -2008 Aug 25 - Modified the return type of param_info::get_default_value from T to const T& - version 2.16.8 -2008 Aug 25 - modifier a return type, added a const - version 2.16.9 - -2008 Aug 26 - Enabled the chisq statistic to take account of the x error - version 2.16.10 - -2008 Sep 2 - added a virtual function to some classes to enable them to destroy themselves. - version 2.16.11 - -2008 Sep 5 - changed the name value_type_trait to element_type_trait, added a return_type_trait - version 2.16.12 - -2008 Sep 27 - Corrected two bugs in the add_model.hpp and mul_model.hpp - version 2.16.13 - -2008 Oct 3 - Stripped the subpackages that uses GPL from it - version 2.17.0 - -2008 Nov 24 - Replaced all std::string with an extra template parameter Tstr, enables the ability of treating Unicode strings - version 2.18.0 - -2008 Nov 25 - Completed the exception tree - version 2.19.0 - -2008 Nov 25 - modified some string type related codes - version 2.19.1 - -2008 Nov 27 - corrected const correction in freeze_param.hpp - version 2.19.2 diff --git a/test.cc b/test.cc deleted file mode 100644 index a69186c..0000000 --- a/test.cc +++ /dev/null @@ -1,142 +0,0 @@ -#include - -using namespace blitz; - -#include - -namespace opt_utilities -{ - template - void set_element(blitz::Array& x,size_t i,TX v) - { - x(i)=v; - } - - - inline const double& get_element(const blitz::Array& x,size_t i) - { - return x(i); - } - - inline size_t get_size(const Array& x) - { - return x.extent(0); - } - - inline void resize(Array& x,size_t s) - { - x.resize(s); - } - - inline Array& opt_eq(Array& lhs, const Array& rhs) - { - lhs.resize(rhs.extent(0)); - lhs=rhs.copy(); - return lhs; - } - - template <> - class value_type_trait > - { - public: - typedef double value_type; - }; - - template <> - class value_type_trait > - { - public: - typedef double value_type; - }; -} - -#include -#include -#include -#include -#include -#include -using namespace std; -#include -#include -#include -//#include "gmpxx.h" -using namespace std; -//using namespace opt_utilities; -using namespace blitz; - -class foo - :public opt_utilities::func_obj > -{ - typedef blitz::Array pT; - double do_eval(const pT& x) - { - return x(0)*x(0)+x(1)*x(1); - } - - foo* do_clone()const - { - return new foo(*this); - } -}; - -class lin1d - :public opt_utilities::model > -{ -private: - opt_utilities::model >* do_clone()const - { - return new lin1d(*this); - } -public: - lin1d() - { - this->push_param_info(opt_utilities::param_info >("k",1)); - this->push_param_info(opt_utilities::param_info >("b",0)); - } - -public: - double do_eval(const double& x,const Array& param) - { - return x*opt_utilities::get_element(param,(size_t)0)+opt_utilities::get_element(param,(size_t)1); - } - -private: - std::string do_to_string()const - { - return "linear model\n" - "y=k*x+b\n"; - } -}; - - - -int main() -{ - opt_utilities::fitter,double> f; - //opt_utilities::optimizer > opt; - opt_utilities::powell_method > pm; - f.set_method(pm); - - Array a(2); - a=2,4; - - opt_utilities::default_data_set ds; - - for(double x=0;x<10;x+=.1) - { - opt_utilities::data d; - d.set_x(x); - d.set_x_lower_err(0); - d.set_x_upper_err(0); - d.set_y(x*3+4); - d.set_y_lower_err(.1); - d.set_y_upper_err(.1); - ds.push_back(d); - } - f.load_data(ds); - f.set_model(lin1d()); - f.set_statistic(opt_utilities::chisq,double>()); - cout< -#include -//#include "gmpxx.h" -#include "strmodel1d.hpp" -using namespace std; -using namespace opt_utilities; - -class foo - :public func_obj > -{ -public: - double do_eval(const vector& p) - { - // cout<<"p0="< > op; - powell_method > pw; - gsl_simplex > gs; - - op.set_func_obj(foo()); - op.set_opt_method(gs); - vector p1(2); - p1[0]=1; - p1[1]=1; - op.set_start_point(p1); - - vector p=op.optimize(); - cout< >; - minex_func.params = (void *)&f; - - s = gsl_multimin_fminimizer_alloc (T, 2); - gsl_multimin_fminimizer_set (s, &minex_func, x, ss); - - do - { - iter++; - status = gsl_multimin_fminimizer_iterate(s); - - if (status) - break; - - size = gsl_multimin_fminimizer_size (s); - status = gsl_multimin_test_size (size, 1e-2); - - if (status == GSL_SUCCESS) - { - printf ("converged to minimum at\n"); - } - - printf ("%5d %10.3e %10.3ef f() = %7.3f size = %.3f\n", - iter, - gsl_vector_get (s->x, 0), - gsl_vector_get (s->x, 1), - s->fval, size); - } - while (status == GSL_CONTINUE && iter < 100); - - /* - foo f; - gsl_vector_set (x, 0, 0.0); - gsl_vector_set (x, 1, 0.0); - cout<<"fdsa "; - cout< >(x,(void*)&f)<