diff options
author | astrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675> | 2008-12-15 07:51:14 +0000 |
---|---|---|
committer | astrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675> | 2008-12-15 07:51:14 +0000 |
commit | 160345bdde08c88d860104c1741576f91b7e8f64 (patch) | |
tree | 961b786b8dd27fb7e4f88a2471b8d73b0a5ef849 | |
parent | 1f4a944064bc42284c33e6b755353d191cf288e8 (diff) | |
download | opt-utilities-160345bdde08c88d860104c1741576f91b7e8f64.tar.bz2 |
git-svn-id: file:///home/svn/opt_utilities@2 ed2142bd-67ad-457f-ba7c-d818d4011675
-rw-r--r-- | history.log | 239 | ||||
-rw-r--r-- | test.cc | 142 | ||||
-rw-r--r-- | test1.cc | 149 |
3 files changed, 0 insertions, 530 deletions
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 <cassert> 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 <cmath> 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 <cstddef> 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 <blitz/array.h> - -using namespace blitz; - -#include <core/opt_traits.hpp> - -namespace opt_utilities -{ - template <typename TX> - void set_element(blitz::Array<double,1>& x,size_t i,TX v) - { - x(i)=v; - } - - - inline const double& get_element(const blitz::Array<double,1>& x,size_t i) - { - return x(i); - } - - inline size_t get_size(const Array<double,1>& x) - { - return x.extent(0); - } - - inline void resize(Array<double,1>& x,size_t s) - { - x.resize(s); - } - - inline Array<double,1>& opt_eq(Array<double,1>& lhs, const Array<double,1>& rhs) - { - lhs.resize(rhs.extent(0)); - lhs=rhs.copy(); - return lhs; - } - - template <> - class value_type_trait<Array<double,1> > - { - public: - typedef double value_type; - }; - - template <> - class value_type_trait<const Array<double,1> > - { - public: - typedef double value_type; - }; -} - -#include <statistics/chisq.hpp> -#include <core/optimizer.hpp> -#include <core/default_data_set.hpp> -#include <methods/powell/powell_method.hpp> -#include <methods/gsl_simplex/gsl_simplex.hpp> -#include <core/fitter.hpp> -using namespace std; -#include <fstream> -#include <vector> -#include <blitz/array.h> -//#include "gmpxx.h" -using namespace std; -//using namespace opt_utilities; -using namespace blitz; - -class foo - :public opt_utilities::func_obj<double,blitz::Array<double,1> > -{ - typedef blitz::Array<double,1> 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<double,double,blitz::Array<double,1> > -{ -private: - opt_utilities::model<double,double,Array<double,1> >* do_clone()const - { - return new lin1d(*this); - } -public: - lin1d() - { - this->push_param_info(opt_utilities::param_info<Array<double,1> >("k",1)); - this->push_param_info(opt_utilities::param_info<Array<double,1> >("b",0)); - } - -public: - double do_eval(const double& x,const Array<double,1>& 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,double,Array<double,1>,double> f; - //opt_utilities::optimizer<double,Array<double,1> > opt; - opt_utilities::powell_method<double,Array<double,1> > pm; - f.set_method(pm); - - Array<double,1> a(2); - a=2,4; - - opt_utilities::default_data_set<double,double> ds; - - for(double x=0;x<10;x+=.1) - { - opt_utilities::data<double,double> 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,double,blitz::Array<double,1>,double>()); - cout<<f.fit(); -} - diff --git a/test1.cc b/test1.cc deleted file mode 100644 index 0e456fd..0000000 --- a/test1.cc +++ /dev/null @@ -1,149 +0,0 @@ -#include "optimizer.hpp" -#include "powell_method.hpp" -#include "add_model.hpp" -#include "lin1d.hpp" -#include "poly1d.hpp" -#include "data_loaders.hpp" -#include "chisq.hpp" -#include "freeze_param.hpp" -#include "add_model.hpp" -#include "mul_model.hpp" -#include "pow_model.hpp" -#include "gsl_simplex.hpp" -#include "pl1d.hpp" -using namespace std; -#include "dl_model.hpp" -#include <fstream> -#include <vector> -//#include "gmpxx.h" -#include "strmodel1d.hpp" -using namespace std; -using namespace opt_utilities; - -class foo - :public func_obj<double,vector<double> > -{ -public: - double do_eval(const vector<double>& p) - { - // cout<<"p0="<<p[0]<<endl; - return p[0]*p[0]+p[1]*p[1]; - } - - foo* do_clone()const - { - return new foo(*this); - } -}; - - -double my_f (const gsl_vector *v, void *params) -{ - double x, y; - double *p = (double *)params; - // cout<<p[1]<<endl; - x = gsl_vector_get(v, 0); - y = gsl_vector_get(v, 1); - - return x*x+y*y; -} - - - - - -int main() -{ - - optimizer<double,vector<double> > op; - powell_method<double,vector<double> > pw; - gsl_simplex<double,vector<double> > gs; - - op.set_func_obj(foo()); - op.set_opt_method(gs); - vector<double> p1(2); - p1[0]=1; - p1[1]=1; - op.set_start_point(p1); - - vector<double> p=op.optimize(); - cout<<p[0]<<"\t"<<p[1]<<endl; - - return 0; - - - - const gsl_multimin_fminimizer_type *T = - gsl_multimin_fminimizer_nmsimplex; - gsl_multimin_fminimizer *s = NULL; - gsl_vector *ss, *x; - gsl_multimin_function minex_func; - - size_t iter = 0; - int status; - double size; - - /* Starting point */ - x = gsl_vector_alloc (2); - gsl_vector_set (x, 0, 5.0); - gsl_vector_set (x, 1, 7.0); - - /* Set initial step sizes to 1 */ - ss = gsl_vector_alloc (2); - gsl_vector_set_all (ss, 1.0); - foo f; - /* Initialize method and iterate */ - minex_func.n = 2; - minex_func.f = &gsl_func_adapter<double,vector<double> >; - 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<<gsl_func_adapter<double,vector<double> >(x,(void*)&f)<<endl;; - - */ - - gsl_vector_free(x); - gsl_vector_free(ss); - gsl_multimin_fminimizer_free (s); - - - - - - return status; - - - -} - |