Compare commits

...

2 Commits

Author SHA1 Message Date
Brett 99b784835b remove broken state from test 2025-01-13 18:05:29 -05:00
Brett 0cf5450eb7 does this work? 2025-01-13 17:53:28 -05:00
4 changed files with 17 additions and 1 deletions

View File

@ -27,7 +27,7 @@ macro(compile_options target_name)
sanitizers(${target_name})
endmacro()
project(blt-gp VERSION 0.3.4)
project(blt-gp VERSION 0.3.6)
include(CTest)
@ -46,6 +46,10 @@ find_package(Threads REQUIRED)
SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -g")
if (NOT ${CMAKE_BUILD_TYPE})
set(CMAKE_BUILD_TYPE Release)
endif ()
if (NOT TARGET BLT)
add_subdirectory(lib/blt)
endif ()

View File

@ -106,6 +106,7 @@ namespace blt::gp
const tree_t* p1;
const tree_t* p2;
size_t runs = 0;
// double parent_val = 0;
do
{
@ -122,6 +123,8 @@ namespace blt::gp
c1.copy_fast(*p1);
c2->copy_fast(*p2);
if (++runs >= config.crossover.get().get_config().max_crossover_iterations)
return 0;
#ifdef BLT_TRACK_ALLOCATIONS
crossover_calls.value(1);
#endif

View File

@ -72,6 +72,8 @@ namespace blt::gp
{
// number of times crossover will try to pick a valid point in the tree. this is purely based on the return type of the operators
u32 max_crossover_tries = 5;
// how many times the crossover function can fail before we will skip this operation.
u32 max_crossover_iterations = 10;
// if tree have fewer nodes than this number, they will not be considered for crossover
// should be at least 5 as crossover will not select the root node.
u32 min_tree_size = 5;
@ -90,6 +92,11 @@ namespace blt::gp
explicit crossover_t(const config_t& config): config(config)
{}
[[nodiscard]] const config_t& get_config() const
{
return config;
}
std::optional<crossover_point_t> get_crossover_point(gp_program& program, const tree_t& c1, const tree_t& c2) const;

View File

@ -106,6 +106,8 @@ void do_run()
{
for (const auto reproduction_chance : reproduction_chances)
{
if (crossover_chance == 0 && mutation_chance == 0 && reproduction_chance == 0)
continue;
for (const auto elite_amount : elite_amounts)
{
for (const auto population_sizes : population_sizes)