race condition?

thread
Brett 2024-07-15 18:59:32 -04:00
parent 34a3343a89
commit 37e8856348
3 changed files with 10 additions and 6 deletions

View File

@ -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")

View File

@ -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))

View File

@ -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<tree_generator_t> generator;