Skip to content

Commit 29fb1a4

Browse files
author
Emmanuel Benazera
committed
added TPA support to BBOB exe, ref #88
1 parent 9f00e29 commit 29fb1a4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tests/bbobexperiment.cc

+4-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void tokenize(const std::string &str,
6060

6161
std::mutex fmtx; // WARNING: bbob function calls are NOT thread-safe (learnt the hard way...).
6262

63-
void MY_OPTIMIZER(double(*fitnessfunction)(double*), unsigned int dim, double ftarget, double maxfunevals, int alg, bool noisy, bool withnumgradient)
63+
void MY_OPTIMIZER(double(*fitnessfunction)(double*), unsigned int dim, double ftarget, double maxfunevals, int alg, bool noisy, bool withnumgradient, bool withtpa)
6464
{
6565
// map fct to libcmaes FitFunc.
6666
FitFunc ff = [&](const double *x, const int N)
@@ -88,6 +88,7 @@ void MY_OPTIMIZER(double(*fitnessfunction)(double*), unsigned int dim, double ft
8888
cmaparams.set_algo(alg);
8989
cmaparams.set_quiet(true);
9090
cmaparams.set_gradient(withnumgradient);
91+
cmaparams.set_tpa(withtpa);
9192
cmaparams.set_mt_feval(true);
9293
if (noisy)
9394
cmaparams.set_noisy();
@@ -103,6 +104,7 @@ DEFINE_string(comment,"","comment for the experiment. If using multiple algorith
103104
DEFINE_double(maxfunevals,1e6,"maximum number of function evaluations");
104105
DEFINE_double(minfunevals,-1,"minimum number of function evaluations, -1 for automatic definition based on dimension");
105106
DEFINE_bool(with_num_gradient,false,"whether to use numerical gradient injection");
107+
DEFINE_bool(tpa,false,"whether to use two-point adapation for step-size update");
106108

107109
int main(int argc, char *argv[])
108110
{
@@ -220,7 +222,7 @@ int main(int argc, char *argv[])
220222
if (++independent_restarts > 0)
221223
fgeneric_restart("independent restart"); /* additional info */
222224
MY_OPTIMIZER(&fgeneric_evaluate, dim[idx_dim], fgeneric_ftarget(),
223-
maxfunevals - fgeneric_evaluations(), (*mit).first, FLAGS_noisy, FLAGS_with_num_gradient);
225+
maxfunevals - fgeneric_evaluations(), (*mit).first, FLAGS_noisy, FLAGS_with_num_gradient, FLAGS_tpa);
224226
if (fgeneric_best() < fgeneric_ftarget())
225227
break;
226228
}

0 commit comments

Comments
 (0)