diff --git a/examples/sample-code-ask-tell-uh.cc b/examples/sample-code-ask-tell-uh.cc index 481e885d..f0af0d5f 100644 --- a/examples/sample-code-ask-tell-uh.cc +++ b/examples/sample-code-ask-tell-uh.cc @@ -81,7 +81,7 @@ class customCMAStrategy : public CMAStrategy }; -int main(int argc, char *argv[]) +int main() { int dim = 10; // problem dimensions. std::vector x0(dim,10.0); diff --git a/examples/sample-code-ask-tell.cc b/examples/sample-code-ask-tell.cc index 1f96a4fa..082c0f4f 100644 --- a/examples/sample-code-ask-tell.cc +++ b/examples/sample-code-ask-tell.cc @@ -76,7 +76,7 @@ class customCMAStrategy : public CMAStrategy }; -int main(int argc, char *argv[]) +int main() { int dim = 10; // problem dimensions. std::vector x0(dim,10.0); diff --git a/examples/sample-code-gradient.cc b/examples/sample-code-gradient.cc index a5c13cb4..1698c3b2 100644 --- a/examples/sample-code-gradient.cc +++ b/examples/sample-code-gradient.cc @@ -40,7 +40,7 @@ GradFunc grad_fsphere = [](const double *x, const int N) return grad; }; -int main(int argc, char *argv[]) +int main() { int dim = 10; // problem dimensions. std::vector x0(dim,10.0); diff --git a/examples/sample-code-lscaling.cc b/examples/sample-code-lscaling.cc index 76682e77..1537b060 100644 --- a/examples/sample-code-lscaling.cc +++ b/examples/sample-code-lscaling.cc @@ -32,7 +32,7 @@ FitFunc fsphere = [](const double *x, const int N) return val; }; -int main(int argc, char *argv[]) +int main() { const int dim = 10; // problem dimensions. std::vector x0(dim,1.0); diff --git a/examples/sample-code-pfunc.cc b/examples/sample-code-pfunc.cc index 467147fa..37d967aa 100644 --- a/examples/sample-code-pfunc.cc +++ b/examples/sample-code-pfunc.cc @@ -36,12 +36,13 @@ FitFunc rosenbrock = [](const double *x, const int N) ProgressFunc,CMASolutions> select_time = [](const CMAParameters<> &cmaparams, const CMASolutions &cmasols) { + (void)cmaparams; if (cmasols.niter() % 100 == 0) std::cerr << cmasols.elapsed_last_iter() << std::endl; return 0; }; -int main(int argc, char *argv[]) +int main() { int dim = 100; // problem dimensions. std::vector x0(dim,10.0); diff --git a/examples/sample-code.cc b/examples/sample-code.cc index 9b2f3943..8afae872 100644 --- a/examples/sample-code.cc +++ b/examples/sample-code.cc @@ -32,7 +32,7 @@ FitFunc fsphere = [](const double *x, const int N) return val; }; -int main(int argc, char *argv[]) +int main() { int dim = 10; // problem dimensions. std::vector x0(dim,10.0); diff --git a/tests/test-functions.cc b/tests/test-functions.cc index 21bfe060..d4144c48 100644 --- a/tests/test-functions.cc +++ b/tests/test-functions.cc @@ -108,12 +108,15 @@ myrng rng; std::uniform_real_distribution<> uint_dist(0,1); FitFunc frand = [](const double *x, const int N) { + (void)N; + (void)x; return uint_dist(rng); }; // classical test functions for single-objective optimization problems. FitFunc ackleys = [](const double *x, const int N) { + (void)N; return -20.0*exp(-0.2*sqrt(0.5*(x[0]*x[0]+x[1]*x[1]))) - exp(0.5*(cos(2.0*M_PI*x[0]) + cos(2.0*M_PI*x[1]))) + 20.0 + exp(1.0); }; @@ -165,71 +168,85 @@ GradFunc grad_rosenbrock = [](const double *x, const int N) FitFunc beale = [](const double *x, const int N) { + (void)N; return pow(1.5-x[0]+x[0]*x[1],2) + pow(2.25 - x[0] + x[0]*x[1]*x[1],2) + pow(2.625-x[0]+x[0]*pow(x[1],3),2); }; FitFunc goldstein_price = [](const double *x, const int N) { + (void)N; return (1.0 + pow(x[0] + x[1] + 1.0,2)*(19.0-14.0*x[0]+3*x[0]*x[0]-14.0*x[1]+6*x[0]*x[1]+3*x[1]*x[1]))*(30.0+pow(2.0*x[0]-3.0*x[1],2)*(18.0-32.0*x[0]+12.0*x[0]*x[0]+48.0*x[1]-36.0*x[0]*x[1]+27.0*x[1]*x[1])); }; FitFunc booth = [](const double *x, const int N) { + (void)N; return pow(x[0]+2.0*x[1]-7,2) + pow(2*x[0]+x[1]-5,2); }; FitFunc bukin = [](const double *x, const int N) { + (void)N; return 100.0 * sqrt(fabs(x[1]-0.01*x[0]*x[0])) + 0.01*fabs(x[0]+10.0); }; FitFunc matyas = [](const double *x, const int N) { + (void)N; return 0.26*(x[0]*x[0]+x[1]*x[1])-0.48*x[0]*x[1]; }; FitFunc levi = [](const double *x, const int N) { + (void)N; return pow(sin(3*M_PI*x[0]),2) + pow(x[0]-1,2) * (1.0+pow(sin(3*M_PI*x[1]),2)) + pow(x[1]-1,2)*(1.0+pow(sin(2.0*M_PI*x[1]),2)); }; FitFunc camel = [](const double *x, const int N) { + (void)N; return 2.0*x[0]*x[0] - 1.05*pow(x[0],4) + pow(x[0],6)/6.0 + x[0]*x[1] + x[1]*x[1]; }; FitFunc easom = [](const double *x, const int N) { + (void)N; return -cos(x[0])*cos(x[1])*exp(-(pow((x[0]-M_PI),2)+pow((x[1]-M_PI),2))); }; FitFunc crossintray = [](const double *x, const int N) { + (void)N; return -0.0001*pow(fabs(sin(x[0])*sin(x[1])*exp(fabs(100.0-sqrt(x[0]*x[0]+x[1]*x[1])/M_PI)))+1.0,0.1); }; FitFunc eggholder = [](const double *x, const int N) { + (void)N; return -(x[1]+47)*sin(sqrt(fabs(x[1]+0.5*x[0]+47.0))) - x[0]*sin(sqrt(fabs(x[0]-(x[1] + 47.0)))); }; FitFunc holdertable = [](const double *x, const int N) { + (void)N; return -fabs(sin(x[0])*cos(x[1])*exp(fabs(1.0-sqrt(x[0]*x[0]+x[1]*x[1])/M_PI))); }; FitFunc mccormick = [](const double *x, const int N) { + (void)N; return sin(x[0]+x[1])+pow(x[0]-x[1],2) - 1.5*x[0] + 2.5*x[1] + 1.0; }; FitFunc schaffer2 = [](const double *x, const int N) { + (void)N; return 0.5 + (pow(sin(x[0]*x[0]-x[1]*x[1]),2)-0.5) / pow(1.0+0.001*(x[0]*x[0]+x[1]*x[1]),2); }; FitFunc schaffer4 = [](const double *x, const int N) { + (void)N; return 0.5 + (cos(sin(fabs(x[0]*x[0]-x[1]*x[1])))-0.5) / pow(1.0+0.001*(x[0]*x[0]+x[1]*x[1]),2); }; @@ -593,6 +610,7 @@ CMASolutions cmaes_opt() { pffunc = [](const CMAParameters &cmaparams, const CMASolutions &cmasols, std::ofstream &fplotstream) { + (void)cmaparams; std::string sep = " "; fplotstream << fabs(cmasols.best_candidate().get_fvalue()) << sep << cmasols.fevals() << sep << cmasols.sigma() << sep << sqrt(cmasols.max_eigenv()/cmasols.min_eigenv()) << sep << cmasols.elapsed_last_iter() << std::endl; return 0;