diff --git a/README.md b/README.md index 937c1c5..121e8fb 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,10 @@ x tripod x trefethen4 x three_hump_camel_back x dixon_price +x beale +x branin +x colville +x styblinski_tang ``` ## Contributions diff --git a/bss.cc b/bss.cc index ea2e64d..4e655a0 100644 --- a/bss.cc +++ b/bss.cc @@ -643,6 +643,62 @@ dixon_price(const std::vector& xs) return ret; } +// Other functions +double +beale(const std::vector& xs) +{ + double x1 = xs.at(0); + double x2 = xs.at(1); + double ret = SQ(1.5 - x1 + x1*x2) + + SQ(2.25 - x1 + x1 * SQ(x2)) + + SQ(2.625 - x1 + x1 * x2 * SQ(x2)); + return ret; +} + +double +branin(const std::vector& xs) +{ + const double + a = 1., + b = 5.1 / (4 * SQ(pi)), + c = 5. / pi, + r = 6., + s = 10., + t = 1. / 8 / pi; + + double x1 = xs.at(0); + double x2 = xs.at(1); + double ret = s + + a * SQ(x2 - b*SQ(x1) + c*x1 - r) + + s * (1. - t) * std::cos(x1); + return ret; +} + +double +colville(const std::vector& xs) +{ + // 4 dimensional + double ret = + 100. * SQ(SQ(xs.at(0)) - xs.at(1)) + + SQ(xs.at(0) - 1.) + + SQ(xs.at(2) - 1.) + + 90. * SQ(SQ(xs.at(2)) - xs.at(3)) + + 10.1 * (SQ(xs.at(1) - 1.) + SQ(xs.at(3) - 1.)) + + 19.8 * (xs.at(1) - 1.) * (xs.at(3) - 1.); + return ret; +} + +double +styblinski_tang(const std::vector& xs) +{ + double ret = 0.; + for (auto &&x: xs) { + ret += SQ(x) * SQ(x) - 16.*SQ(x) + 5.*x; + } + ret /= 2.; + return ret; +} + // int // main (int argc, char** argv) // { diff --git a/bss.h b/bss.h index 83af40d..d1e7b1b 100644 --- a/bss.h +++ b/bss.h @@ -45,6 +45,10 @@ double tripod(const std::vector& xs); double trefethen4(const std::vector& xs); double three_hump_camel_back(const std::vector& xs); double dixon_price(const std::vector& xs); +double beale(const std::vector& xs); +double branin(const std::vector& xs); +double colville(const std::vector& xs); +double styblinski_tang(const std::vector& xs); #endif // _BSS_H diff --git a/cbench.cc b/cbench.cc index 922a97c..6102437 100644 --- a/cbench.cc +++ b/cbench.cc @@ -79,6 +79,10 @@ PYWRAP(tripod); PYWRAP(trefethen4); PYWRAP(three_hump_camel_back); PYWRAP(dixon_price); +PYWRAP(beale); +PYWRAP(branin); +PYWRAP(colville); +PYWRAP(styblinski_tang); static PyMethodDef @@ -128,6 +132,10 @@ CBenchMethods[] = { {"trefethen4", py_trefethen4, METH_VARARGS, "trefethen4 function"}, {"three_hump_camel_back", py_three_hump_camel_back, METH_VARARGS, "three hump camel function"}, {"dixon_price", py_dixon_price, METH_VARARGS, "dixon price function"}, + {"beale", py_beale, METH_VARARGS, "beale function"}, + {"branin", py_branin, METH_VARARGS, "branin function"}, + {"colville", py_colville, METH_VARARGS, "colville function"}, + {"styblinski_tang", py_styblinski_tang, METH_VARARGS, "styblinski_tang function"}, {NULL, NULL, 0, NULL} }; diff --git a/sanity-test-golden.log b/sanity-test-golden.log index 2e182f1..ef29d7b 100644 --- a/sanity-test-golden.log +++ b/sanity-test-golden.log @@ -1,10 +1,13 @@ -> ackley: 3.194178743769641 -> alpine: 0.6941110026558399 -> axis_parallel_hyperellipsoid: 2.3005 +-> beale: 13.03578164 -> bohachevsky1: 0.937271222062237 -> bohachevsky2: 0.5326584774442731 -> bohachevsky3: 0.675316954888546 +-> branin: 51.38785089543272 -> bukin_f6: 44.811177812216314 +-> colville: 33.163000000000004 -> cross_in_tray: -1.4777274811045142 -> deceptive3: -0.0009897909414337454 -> dejong5: 12.670567474629571 @@ -36,6 +39,7 @@ -> six_hump_camel_back: -0.09380966666666667 -> sphere: 0.5601 -> step: 1.25 +-> styblinski_tang: -0.6542739950000005 -> sum_powers: 0.053936287801 -> sum_squares: 2.3005 -> three_hump_camel_back: 0.07989516666666668