Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- registerFunction("Salomon", 10, MAX_DIMENSION, STATIC_BLIMIT(-100.0, 100.0), EVAL {
- double m = 0.0;
- for (int i = 0; i < n; i++) {
- m += square(x[i]);
- }
- double v = sqrt(m);
- return 1 - cos(2 * PI * v) + 0.1 * v;
- }, DERIV {
- double m = 0.0;
- for (int i = 0; i < n; i++) {
- m += square(x[i]);
- }
- double v = sqrt(m);
- if (v == 0) {
- for (int i = 0; i < n; i++) {
- res[i] = NAN;
- }
- } else {
- for(int i = 0; i < n; i++) {
- res[i] = sin(2 * PI * v) * 2 * PI / v * 2 * x[i] + 0.1 / v * 2 * x[i];
- }
- }
- })->rootsFunction = [](int n) {
- return singletonVector<FP_T *>(filledVector(n, 0.0));
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement