From 37e885634800331ce68de3ae6dea9ac5d6202d53 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Mon, 15 Jul 2024 18:59:32 -0400 Subject: [PATCH] race condition? --- CMakeLists.txt | 6 ++++-- include/blt/gp/selection.h | 6 ++++-- include/blt/gp/transformers.h | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 63f3b2a..160afd5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(blt-gp VERSION 0.0.81) +project(blt-gp VERSION 0.0.82) include(CTest) @@ -14,7 +14,9 @@ set(CMAKE_CXX_STANDARD 17) set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) -add_subdirectory(lib/blt) +if (NOT TARGET BLT) + add_subdirectory(lib/blt) +endif() include_directories(include/) file(GLOB_RECURSE PROJECT_BUILD_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp") diff --git a/include/blt/gp/selection.h b/include/blt/gp/selection.h index 0107456..0518861 100644 --- a/include/blt/gp/selection.h +++ b/include/blt/gp/selection.h @@ -52,7 +52,8 @@ namespace blt::gp { for (blt::size_t i = 0; i < config.elites; i++) { - //BLT_INFO("%lf >= %lf? // %lf", ind.second.fitness.adjusted_fitness, values[i].second, ind.second.fitness.raw_fitness); + BLT_INFO("%lf >= %lf? // %lf (indexes: %ld %ld)", ind.second.fitness.adjusted_fitness, values[i].second, + ind.second.fitness.raw_fitness, ind.first, values[i].first); if (ind.second.fitness.adjusted_fitness >= values[i].second) { bool doesnt_contain = true; @@ -141,7 +142,8 @@ namespace blt::gp while (next_pop.get_individuals().size() < config.population_size) { int sel = random.get_i32(0, 3); - switch (sel){ + switch (sel) + { case 0: // everyone gets a chance once per loop. if (random.choice(config.crossover_chance)) diff --git a/include/blt/gp/transformers.h b/include/blt/gp/transformers.h index 317e50a..217f8fc 100644 --- a/include/blt/gp/transformers.h +++ b/include/blt/gp/transformers.h @@ -77,8 +77,8 @@ namespace blt::gp public: struct config_t { - blt::size_t replacement_min_depth = 3; - blt::size_t replacement_max_depth = 7; + blt::size_t replacement_min_depth = 2; + blt::size_t replacement_max_depth = 6; std::reference_wrapper generator;