Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use threads more effectively in differential evolution #1093

Merged
merged 1 commit into from
Feb 14, 2024

Conversation

NAThompson
Copy link
Collaborator

No description provided.

@NAThompson
Copy link
Collaborator Author

NAThompson commented Feb 13, 2024

Using this code:

void test_sphere() {
  std::cout << "Testing differential evolution on the sphere function . . .\n";
  using ArgType = std::vector<float>;
  auto de_params = differential_evolution_parameters<ArgType>();
  de_params.lower_bounds.resize(12, -1);
  de_params.upper_bounds.resize(12, 1);
  de_params.NP *= 150;
  de_params.max_generations *= 10;
  de_params.crossover_probability = 0.9;
  double target_value = 1e-8;
  std::mt19937_64 gen(56789);
  auto local_minima = differential_evolution(sphere, de_params, gen, target_value);
  CHECK_LE(sphere(local_minima), target_value);
}

I obtain:

./a.out  11.57s user 0.30s system 113% cpu 10.430 total

on develop, and

./a.out  14.23s user 0.31s system 564% cpu 2.574 total

on top of this PR. So it appears this is an unambiguous win-though in fairness my laptop has 10 threads so there is much performance left to be extracted.

The PR is clean under -fsanitize=thread as well as -fsanitize=address -fsanitize=undefined.

@NAThompson NAThompson merged commit bd518d9 into develop Feb 14, 2024
67 of 68 checks passed
@NAThompson NAThompson deleted the speedup_de branch February 14, 2024 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant