aboutsummaryrefslogtreecommitdiffstats
path: root/methods
diff options
context:
space:
mode:
authorastrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675>2009-08-29 11:29:20 +0000
committerastrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675>2009-08-29 11:29:20 +0000
commit0b63947fbfabd84ff383bbae9da46f985b225eab (patch)
treebecfd67efccbc45afdf91d9c12e709d4fb89914e /methods
parente1be7dc1247d604ea8c914ee1ec01b0b009cdb98 (diff)
downloadopt-utilities-0b63947fbfabd84ff383bbae9da46f985b225eab.tar.bz2
git-svn-id: file:///home/svn/opt_utilities@57 ed2142bd-67ad-457f-ba7c-d818d4011675
Diffstat (limited to 'methods')
-rw-r--r--methods/aga/aga.hpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/methods/aga/aga.hpp b/methods/aga/aga.hpp
index eda6e07..5dba423 100644
--- a/methods/aga/aga.hpp
+++ b/methods/aga/aga.hpp
@@ -191,12 +191,21 @@ namespace opt_utilities
{
return false;
}
-
+ pT lb(get_size(samples[0].p));
+ pT ub(get_size(samples[0].p));
for(int i=0;i<n2;++i)
{
pT p(samples[i].p);
for(int j=0;j<get_size(p);++j)
{
+ if(i==0)
+ {
+ ub[j]=p[j];
+ lb[j]=p[j];
+ }
+ ub[j]=std::max(ub[j],p[j]);
+ lb[j]=std::min(lb[j],p[j]);
+
set_element(p,j,
get_element(p,j)+
uni_rand(-get_element(reproduction_box,j),
@@ -209,7 +218,6 @@ namespace opt_utilities
{
set_element(p,j,get_element(lower_bound,j));
}
-
}
buffer[i]=p;
}
@@ -223,17 +231,26 @@ namespace opt_utilities
set_element(samples[i*n2+j+n1].p,k,
(get_element(samples[i].p,k)+
get_element(buffer[j],k))/2.);
+
+
+ ub[k]=std::max(ub[k],samples[i*n2+j+n1].p[k]);
+ lb[k]=std::min(lb[k],samples[i*n2+j+n1].p[k]);
}
}
}
+ double n_per_dim=pow((double)n0,1./get_size(lower_bound));
for(int i=0;i<get_size(reproduction_box);++i)
{
+ // set_element(reproduction_box,i,
+ //get_element(reproduction_box,i)*decay_factor);
set_element(reproduction_box,i,
- get_element(reproduction_box,i)*decay_factor);
+ (get_element(ub,i)-
+ get_element(ub,i))/n_per_dim);
+
}
return true;
}
-
+
pT do_optimize()
{
srand(time(0));
@@ -243,10 +260,10 @@ namespace opt_utilities
for(int i=0;i<get_size(lower_bound);++i)
{
-
+
set_element(reproduction_box,i,
(get_element(upper_bound,i)-
- get_element(lower_bound,i))/n_per_dim);
+ get_element(lower_bound,i))/n_per_dim);
}
while(iter()){}