Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. registerFunction("Salomon", 10, MAX_DIMENSION, STATIC_BLIMIT(-100.0, 100.0), EVAL {
  2. double m = 0.0;
  3. for (int i = 0; i < n; i++) {
  4. m += square(x[i]);
  5. }
  6. double v = sqrt(m);
  7. return 1 - cos(2 * PI * v) + 0.1 * v;
  8. }, DERIV {
  9. double m = 0.0;
  10. for (int i = 0; i < n; i++) {
  11. m += square(x[i]);
  12. }
  13. double v = sqrt(m);
  14. if (v == 0) {
  15. for (int i = 0; i < n; i++) {
  16. res[i] = NAN;
  17. }
  18. } else {
  19. for(int i = 0; i < n; i++) {
  20. res[i] = sin(2 * PI * v) * 2 * PI / v * 2 * x[i] + 0.1 / v * 2 * x[i];
  21. }
  22. }
  23. })->rootsFunction = [](int n) {
  24. return singletonVector<FP_T *>(filledVector(n, 0.0));
  25. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement