diff --git a/CMakeLists.txt b/CMakeLists.txt index a53aaa3..abbfd4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(blt-gp VERSION 0.0.87) +project(blt-gp VERSION 0.0.88) include(CTest) diff --git a/examples/pg_symbolic_regression.cpp b/examples/pg_symbolic_regression.cpp index 0dbcf00..de19f13 100644 --- a/examples/pg_symbolic_regression.cpp +++ b/examples/pg_symbolic_regression.cpp @@ -34,7 +34,10 @@ std::array fitness_cases; blt::gp::prog_config_t config = blt::gp::prog_config_t() .set_initial_min_tree_size(2) .set_initial_max_tree_size(6) - .set_elite_count(0) + .set_elite_count(10) + .set_crossover_chance(0.9) + .set_mutation_chance(0.1) + .set_reproduction_chance(0.1) .set_max_generations(50) .set_pop_size(500) .set_thread_count(0); @@ -103,10 +106,10 @@ int main() builder.add_operator(sub); builder.add_operator(mul); builder.add_operator(pro_div); - builder.add_operator(op_sin); - builder.add_operator(op_cos); - builder.add_operator(op_exp); - builder.add_operator(op_log); + //builder.add_operator(op_sin); + //builder.add_operator(op_cos); + //builder.add_operator(op_exp); + //builder.add_operator(op_log); builder.add_operator(lit, true); builder.add_operator(op_x); @@ -121,7 +124,7 @@ int main() { BLT_TRACE("------------{Begin Generation %ld}------------", program.get_current_generation()); BLT_START_INTERVAL("Symbolic Regression", "Gen"); - program.create_next_generation(blt::gp::select_tournament_t{}, blt::gp::select_tournament_t{}, blt::gp::select_tournament_t{}); + program.create_next_generation(blt::gp::select_fitness_proportionate_t{}, blt::gp::select_fitness_proportionate_t{}, blt::gp::select_fitness_proportionate_t{}); BLT_END_INTERVAL("Symbolic Regression", "Gen"); BLT_TRACE("Move to next generation"); BLT_START_INTERVAL("Symbolic Regression", "Fitness"); diff --git a/include/blt/gp/config.h b/include/blt/gp/config.h index a1682a3..fb91439 100644 --- a/include/blt/gp/config.h +++ b/include/blt/gp/config.h @@ -39,7 +39,7 @@ namespace blt::gp // percent chance that we will do mutation double mutation_chance = 0.1; // percent chance we will do reproduction (copy individual) - double reproduction_chance = 0; + double reproduction_chance = 0.1; // everything else will just be selected blt::size_t elites = 0; diff --git a/include/blt/gp/stack.h b/include/blt/gp/stack.h index 88acd32..e4896d0 100644 --- a/include/blt/gp/stack.h +++ b/include/blt/gp/stack.h @@ -418,7 +418,6 @@ namespace blt::gp ~stack_allocator() { - free_chain(head); if (head != nullptr) { auto blk = head->metadata.next; @@ -429,6 +428,7 @@ namespace blt::gp std::free(ptr); } } + free_chain(head); } template