diff options
author | astrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675> | 2009-10-11 16:24:22 +0000 |
---|---|---|
committer | astrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675> | 2009-10-11 16:24:22 +0000 |
commit | 896a67e280d41df613092279f76913f8372faba1 (patch) | |
tree | ef5c2a83f1291d47dd56ee9969d244ceb1b7fc4c /methods/aga | |
parent | 3fcb4f104a8b81937f93ef4b298dd51e3c1eec94 (diff) | |
download | opt-utilities-896a67e280d41df613092279f76913f8372faba1.tar.bz2 |
git-svn-id: file:///home/svn/opt_utilities@79 ed2142bd-67ad-457f-ba7c-d818d4011675
Diffstat (limited to 'methods/aga')
-rw-r--r-- | methods/aga/aga.hpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/methods/aga/aga.hpp b/methods/aga/aga.hpp index cf0b4a6..77c5700 100644 --- a/methods/aga/aga.hpp +++ b/methods/aga/aga.hpp @@ -69,7 +69,7 @@ namespace opt_utilities pT reproduction_box; std::vector<vp_pair<rT,pT> > samples; std::vector<pT> buffer; - + mutable bool bstop; private: typename element_type_trait<pT>::element_type uni_rand (typename element_type_trait<pT>::element_type x1, @@ -216,7 +216,7 @@ namespace opt_utilities } pT lb(get_size(samples[0].p)); pT ub(get_size(samples[0].p)); - for(int i=0;i<n2;++i) + for(int i=0;i<n2&&!bstop;++i) { pT p(samples[i].p); for(size_t j=0;j<get_size(p);++j) @@ -244,9 +244,13 @@ namespace opt_utilities } buffer[i]=p; } - for(int i=0;i<n1;++i) + if(bstop) { - for(int j=0;j<n2;++j) + return false; + } + for(int i=0;i<n1&&!bstop;++i) + { + for(int j=0;j<n2&&!bstop;++j) { pT p(samples[i].p); for(size_t k=0;k<get_size(p);++k) @@ -261,6 +265,10 @@ namespace opt_utilities } } } + if(bstop) + { + return false; + } double n_per_dim=pow((double)n0,1./get_size(lower_bound)); for(size_t i=0;i<get_size(reproduction_box);++i) { @@ -276,6 +284,7 @@ namespace opt_utilities pT do_optimize() { + bstop=false; srand(time(0)); buffer.resize(n2); double n_per_dim=pow((double)n0,1./get_size(lower_bound)); @@ -289,10 +298,15 @@ namespace opt_utilities get_element(lower_bound,i))/n_per_dim); } - while(iter()){} + while(iter()&&!bstop){} return samples.begin()->p; } + + void do_stop() + { + bstop=true; + } }; |