From 04fe36deb8662a5ebcf6eb1151c9ba80624e55ef Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Fri, 6 Sep 2024 14:33:23 -0400 Subject: [PATCH] silly --- CMakeLists.txt | 2 +- include/blt/gp/transformers.h | 4 ++++ lib/blt | 2 +- src/transformers.cpp | 36 +++++++++++++++++++++++++++-------- 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 10e4896..f16c156 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(blt-gp VERSION 0.1.52) +project(blt-gp VERSION 0.1.53) include(CTest) diff --git a/include/blt/gp/transformers.h b/include/blt/gp/transformers.h index 06bb8de..af0b0a8 100644 --- a/include/blt/gp/transformers.h +++ b/include/blt/gp/transformers.h @@ -24,6 +24,7 @@ #include #include #include +#include namespace blt::gp { @@ -84,6 +85,9 @@ namespace blt::gp std::optional get_crossover_point(gp_program& program, const tree_t& c1, const tree_t& c2) const; + std::optional get_point_traverse(gp_program& program, const tree_t& t, std::optional type, + bool scale_per_depth = true) const; + static std::optional find_place_of_type(gp_program& program, const tree_t& t, type_id type); /** diff --git a/lib/blt b/lib/blt index 56a3c2f..cd9ec50 160000 --- a/lib/blt +++ b/lib/blt @@ -1 +1 @@ -Subproject commit 56a3c2f836a37258290c2cc43b52df18249b1c0c +Subproject commit cd9ec507d63d5e45f36dd16665f2033b0b5fe5f2 diff --git a/src/transformers.cpp b/src/transformers.cpp index 5016810..71a1252 100644 --- a/src/transformers.cpp +++ b/src/transformers.cpp @@ -155,7 +155,7 @@ namespace blt::gp } std::optional crossover_t::get_crossover_point(gp_program& program, const tree_t& c1, - const tree_t& c2) const + const tree_t& c2) const { auto& c1_ops = c1.get_operations(); auto& c2_ops = c2.get_operations(); @@ -220,6 +220,26 @@ namespace blt::gp return {}; } + std::optional crossover_t::get_point_traverse(gp_program& program, const tree_t& t, std::optional type, + bool scale_per_depth) const + { + auto& random = program.get_random(); + + blt::ptrdiff_t point = 0; + while (true) + { + // traverse to a child + if (random.choice()) + { + + } + if (type) + { + + } + } + } + bool mutation_t::apply(gp_program& program, const tree_t&, tree_t& c) { mutate_point(program, c, program.get_random().get_size_t(0ul, c.get_operations().size())); @@ -376,7 +396,7 @@ namespace blt::gp // TODO: new config? auto& tree = get_static_tree_tl(program); config.generator.get().generate(tree, - {program, val.id, config.replacement_min_depth, config.replacement_max_depth}); + {program, val.id, config.replacement_min_depth, config.replacement_max_depth}); auto& child = children_data[children_data.size() - 1 - index]; blt::size_t total_bytes_for = c.total_value_bytes(child.start, child.end); @@ -458,8 +478,8 @@ namespace blt::gp { auto& tree = get_static_tree_tl(program); config.generator.get().generate(tree, - {program, replacement_func_info.argument_types[i].id, config.replacement_min_depth, - config.replacement_max_depth}); + {program, replacement_func_info.argument_types[i].id, config.replacement_min_depth, + config.replacement_max_depth}); vals.insert(tree.get_values()); ops.insert(ops.begin() + static_cast(start_index), tree.get_operations().begin(), tree.get_operations().end()); @@ -531,8 +551,8 @@ namespace blt::gp { auto& tree = get_static_tree_tl(program); config.generator.get().generate(tree, - {program, replacement_func_info.argument_types[i].id, config.replacement_min_depth, - config.replacement_max_depth}); + {program, replacement_func_info.argument_types[i].id, config.replacement_min_depth, + config.replacement_max_depth}); blt::size_t total_bytes_for = tree.total_value_bytes(); vals.copy_from(tree.get_values(), total_bytes_for); ops.insert(ops.begin() + static_cast(start_index), tree.get_operations().begin(), @@ -545,8 +565,8 @@ namespace blt::gp { auto& tree = get_static_tree_tl(program); config.generator.get().generate(tree, - {program, replacement_func_info.argument_types[i].id, config.replacement_min_depth, - config.replacement_max_depth}); + {program, replacement_func_info.argument_types[i].id, config.replacement_min_depth, + config.replacement_max_depth}); blt::size_t total_bytes_for = tree.total_value_bytes(); vals.copy_from(tree.get_values(), total_bytes_for); ops.insert(ops.begin() + static_cast(start_index), tree.get_operations().begin(),