diff options
-rw-r--r-- | methods/bfgs/bfgs.hpp | 10 | ||||
-rw-r--r-- | test/many_dims.cpp | 10 |
2 files changed, 9 insertions, 11 deletions
diff --git a/methods/bfgs/bfgs.hpp b/methods/bfgs/bfgs.hpp index c9aecea..9a97730 100644 --- a/methods/bfgs/bfgs.hpp +++ b/methods/bfgs/bfgs.hpp @@ -35,7 +35,6 @@ namespace opt_utilities typedef typename element_type_trait<pT>::element_type element_type; element_type* mem_pool; element_type** invBk; - element_type** invBk1; bool bstop; private: const char* do_get_type_name()const @@ -52,7 +51,7 @@ namespace opt_utilities public: bfgs_method() :threshold(1e-5),p_fo(0),p_optimizer(0), - mem_pool(0),invBk(0),invBk1(0) + mem_pool(0),invBk(0) { } @@ -64,7 +63,7 @@ namespace opt_utilities bfgs_method(const bfgs_method<rT,pT>& rhs) :p_fo(rhs.p_fo),p_optimizer(rhs.p_optimizer), - threshold(rhs.threshold) + threshold(rhs.threshold),mem_pool(0),invBk(0) { } @@ -83,14 +82,12 @@ namespace opt_utilities void init_workspace(int n) { destroy_workspace(); - mem_pool=new element_type[n*n*2]; + mem_pool=new element_type[n*n]; invBk=new element_type*[n]; - invBk1=new element_type*[n]; for(size_t i=0;i!=n;++i) { invBk[i]=mem_pool+i*n; - invBk1[i]=invBk[i]+n*n; } for(size_t i=0;i!=n;++i) { @@ -105,7 +102,6 @@ namespace opt_utilities { delete[] mem_pool; delete[] invBk; - delete[] invBk1; } public: diff --git a/test/many_dims.cpp b/test/many_dims.cpp index 9afe4a7..f7a1ebc 100644 --- a/test/many_dims.cpp +++ b/test/many_dims.cpp @@ -3,6 +3,7 @@ #include <core/optimizer.hpp> #include <methods/powell/powell_method.hpp> //#include <methods/gsl_simplex/gsl_simplex.hpp> +#include <methods/bfgs/bfgs.hpp> #include <methods/aga/aga.hpp> #include <vector> #include <iostream> @@ -121,7 +122,7 @@ class foo5 void test_opt(const func_obj<double,vector<double> >& fo, const opt_method<double,vector<double> >& optm) { - const int problem_size=50; + const int problem_size=500; optimizer<double,vector<double> > opt; opt.set_func_obj(fo); @@ -163,9 +164,10 @@ void test_opt(const func_obj<double,vector<double> >& fo, int main() { - // gsl_simplex<double,vector<double> > pm_simplex; - - aga_method<double,vector<double> > agam(100,50); + //gsl_simplex<double,vector<double> > agam; + bfgs_method<double,vector<double> > agam; + //powell_method<double,vector<double> > agam; + //aga_method<double,vector<double> > agam(100,50); test_opt(foo1(),agam); test_opt(foo2(),agam); test_opt(foo3(),agam); |