diff --git a/src/apex/apex_kokkos_tuning.cpp b/src/apex/apex_kokkos_tuning.cpp index da19aad0..ca6fd29c 100644 --- a/src/apex/apex_kokkos_tuning.cpp +++ b/src/apex/apex_kokkos_tuning.cpp @@ -227,6 +227,9 @@ class KokkosSession { } else if (strncmp(apex::apex_options::kokkos_tuning_policy(), "simulated_annealing", strlen("simulated_annealing")) == 0) { strategy = apex_ah_tuning_strategy::SIMULATED_ANNEALING; + } else if (strncmp(apex::apex_options::kokkos_tuning_policy(), + "genetic_search", strlen("genetic_search")) == 0) { + strategy = apex_ah_tuning_strategy::GENETIC_SEARCH; } else { strategy = apex_ah_tuning_strategy::NELDER_MEAD; } diff --git a/src/apex/apex_policies.cpp b/src/apex/apex_policies.cpp index 55cad66f..290cd373 100644 --- a/src/apex/apex_policies.cpp +++ b/src/apex/apex_policies.cpp @@ -1817,7 +1817,7 @@ inline int __common_setup_custom_tuning(shared_ptr } ); } - } else if (request.strategy == apex_ah_tuning_strategy::APEX_GENETIC) { + } else if (request.strategy == apex_ah_tuning_strategy::GENETIC_SEARCH) { status = __genetic_setup(tuning_session, request); if(status == APEX_NOERROR) { apex::register_policy( diff --git a/src/apex/apex_policies.hpp b/src/apex/apex_policies.hpp index 5b866d58..da5eb63a 100644 --- a/src/apex/apex_policies.hpp +++ b/src/apex/apex_policies.hpp @@ -41,7 +41,7 @@ enum class apex_ah_tuning_strategy : int { EXHAUSTIVE, RANDOM, NELDER_MEAD, PARALLEL_RANK_ORDER, SIMULATED_ANNEALING, APEX_EXHAUSTIVE, APEX_RANDOM, - APEX_GENETIC}; + GENETIC_SEARCH}; struct apex_tuning_session; class apex_tuning_request; diff --git a/src/apex/genetic_search.cpp b/src/apex/genetic_search.cpp index cbf8ad58..4057e7e8 100644 --- a/src/apex/genetic_search.cpp +++ b/src/apex/genetic_search.cpp @@ -87,10 +87,15 @@ auto get_random_number(const std::size_t min, const std::size_t max) void GeneticSearch::getNewSettings() { static bool bootstrapping{true}; if (bootstrapping) { - // we are still bootstrapping, so just get a random selection. - for (auto& v : vars) { v.second.get_next_neighbor(); } - return; + if (population.size() >= population_size) { + bootstrapping = false; + } else { + // we are still bootstrapping, so just get a random selection. + for (auto& v : vars) { v.second.get_next_neighbor(); } + return; + } } + std::cout << "Have population of " << population.size() << " to evaluate!" << std::endl; // time to cull the herd? if (population.size() >= population_size) { std::cout << "Have population of " << population.size() << " to evaluate!" << std::endl; @@ -102,13 +107,12 @@ void GeneticSearch::getNewSettings() { // ...then drop half of them - the "weakest" ones. population.erase(population.cbegin() + crossover, population.cend()); std::cout << "Now have population of " << population.size() << std::endl; - bootstrapping = false; } // We want to generate a new individual using two "high quality" parents. // choose parent A - individual& A = population[get_random_number(0,crossover)]; + individual& A = population[get_random_number(0,crossover-1)]; // choose parent B - individual& B = population[get_random_number(0,crossover)]; + individual& B = population[get_random_number(0,crossover-1)]; // blend their variables into a new individual and maybe mutate? size_t i = 0; for (auto& v : vars) {