From 998693b0bbbaae72beefb5f0fb6351ca839b06da Mon Sep 17 00:00:00 2001 From: astrojhgu Date: Thu, 24 Sep 2009 15:26:00 +0000 Subject: git-svn-id: file:///home/svn/opt_utilities@73 ed2142bd-67ad-457f-ba7c-d818d4011675 --- test/makefile | 5 +- test/many_dims.cpp | 174 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 178 insertions(+), 1 deletion(-) create mode 100644 test/many_dims.cpp (limited to 'test') diff --git a/test/makefile b/test/makefile index e850e82..94d223d 100644 --- a/test/makefile +++ b/test/makefile @@ -1,10 +1,13 @@ -targets=test_optimizer +targets=test_optimizer many_dims all:$(targets) test_optimizer:test_optimizer.cpp $(CXX) $< -o $@ -I .. -O3 -g +many_dims:many_dims.cpp + $(CXX) $< -o $@ -I .. -O3 -g + clean: rm -f $(targets) *.o *~ diff --git a/test/many_dims.cpp b/test/many_dims.cpp new file mode 100644 index 0000000..9afe4a7 --- /dev/null +++ b/test/many_dims.cpp @@ -0,0 +1,174 @@ +#define private public +#include +#include +#include +//#include +#include +#include +#include +using namespace opt_utilities; +using namespace std; + + +class foo1 + :public func_obj > +{ + foo1* do_clone()const + { + return new foo1(*this); + } + + double do_eval(const vector& p) + { + double result=0; + for(int i=0;i!=p.size();++i) + { + result+=p[i]*p[i]; + } + return result; + } +}; + +class foo2 + :public func_obj > +{ + foo2* do_clone()const + { + return new foo2(*this); + } + + double do_eval(const vector& p) + { + double result=0; + for(int i=0;i!=p.size();++i) + { + result+=(i+1)*p[i]*p[i]; + } + return result; + } +}; + +class foo3 + :public func_obj > +{ + foo3* do_clone()const + { + return new foo3(*this); + } + + double do_eval(const vector& p) + { + double result=0; + for(int i=0;i > +{ + foo4* do_clone()const + { + return new foo4(*this); + } + + double do_eval(const vector& p) + { + double result=0; + for(int i=0;i > +{ + foo5* do_clone()const + { + return new foo5(*this); + } + + double do_eval(const vector& p) + { + const double pi=3.14159265358979323846; + double result=0; + result+=10*p.size(); + for(int i=0;i >& fo, + const opt_method >& optm) +{ + const int problem_size=50; + optimizer > opt; + + opt.set_func_obj(fo); + opt.set_opt_method(optm); + + vector lim(problem_size); + for(int i=0;i lim(problem_size); + for(int i=0;i p(problem_size); + for(int i=0;i > pm_simplex; + + aga_method > agam(100,50); + test_opt(foo1(),agam); + test_opt(foo2(),agam); + test_opt(foo3(),agam); + test_opt(foo4(),agam); + test_opt(foo5(),agam); +} -- cgit v1.2.2