From 27ecb2b46d93a965289ccaaf765e754be84a913e Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Sat, 19 Apr 2025 17:58:12 -0400 Subject: [PATCH] idk what changed but it's still broken --- CMakeLists.txt | 2 +- include/blt/gp/transformers.h | 9 ++++++ lib/blt | 2 +- src/program.cpp | 2 +- src/transformers.cpp | 3 -- tests/serialization_test.cpp | 55 +++++++++++++++++++++++++++++++++++ 6 files changed, 67 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bc1212e..4b03772 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,7 @@ macro(compile_options target_name) sanitizers(${target_name}) endmacro() -project(blt-gp VERSION 0.5.14) +project(blt-gp VERSION 0.5.15) include(CTest) diff --git a/include/blt/gp/transformers.h b/include/blt/gp/transformers.h index 36109df..94fbaf1 100644 --- a/include/blt/gp/transformers.h +++ b/include/blt/gp/transformers.h @@ -82,12 +82,21 @@ namespace blt::gp f32 terminal_chance = 0.1; // use traversal to select point instead of random selection bool traverse = false; + + BLT_MAKE_SETTER_LVALUE(u32, max_crossover_tries); + BLT_MAKE_SETTER_LVALUE(u32, max_crossover_iterations); + BLT_MAKE_SETTER_LVALUE(u32, min_tree_size); + BLT_MAKE_SETTER_LVALUE(f32, depth_multiplier); + BLT_MAKE_SETTER_LVALUE(f32, terminal_chance); + BLT_MAKE_SETTER_LVALUE(bool, traverse); }; explicit crossover_t(const config_t& config): config(config) { } + virtual bool apply(gp_program& program, const tree_t& p1, const tree_t& p2, tree_t& c1, tree_t& c2) = 0; + [[nodiscard]] const config_t& get_config() const { return config; diff --git a/lib/blt b/lib/blt index a1bc8cf..2bac310 160000 --- a/lib/blt +++ b/lib/blt @@ -1 +1 @@ -Subproject commit a1bc8cf1c2390e507be6482dde0960daf9f662d8 +Subproject commit 2bac310e55df06a3e378c932afa2a4c2bc2123e7 diff --git a/src/program.cpp b/src/program.cpp index 197f0e6..48b6db1 100644 --- a/src/program.cpp +++ b/src/program.cpp @@ -40,7 +40,7 @@ namespace blt::gp // this is largely to not break the tests :3 // it's also to allow for quick setup of a gp program if you don't care how crossover or mutation is handled static advanced_mutation_t s_mutator; - static crossover_t s_crossover; + static subtree_crossover_t s_crossover; static ramped_half_initializer_t s_init; prog_config_t::prog_config_t(): mutator(s_mutator), crossover(s_crossover), pop_initializer(s_init) diff --git a/src/transformers.cpp b/src/transformers.cpp index 98c5a1e..d713478 100644 --- a/src/transformers.cpp +++ b/src/transformers.cpp @@ -139,9 +139,6 @@ namespace blt::gp // Mating crossover analogs to same species breeding. Only works if tree is mostly similar case 1: { - // if fails got to case0 - if (false) - goto case0; } // Subtree crossover, select random points inside trees and swap their subtrees case 2: diff --git a/tests/serialization_test.cpp b/tests/serialization_test.cpp index a531730..09fa1cd 100644 --- a/tests/serialization_test.cpp +++ b/tests/serialization_test.cpp @@ -15,6 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ +#include #include #include "../examples/symbolic_regression.h" @@ -25,6 +26,60 @@ #include #include + +struct no_default +{ + no_default() = delete; + + no_default(int) + { + } +}; + +struct not_copyable +{ + not_copyable() = default; + not_copyable(const not_copyable&) = delete; +}; + +struct copyable +{ + copyable() = default; + copyable(const copyable&) = default; +}; + +struct copyable_nothrow +{ + copyable_nothrow() = default; + copyable_nothrow(const copyable_nothrow&) noexcept = default; +}; + +struct not_movable +{ + not_movable() = default; + not_movable(not_movable&&) = delete; +}; + +struct movable +{ + movable() = default; + movable(movable&&) = delete; +}; + +struct movable_nothrow +{ + movable_nothrow() = default; + movable_nothrow(movable_nothrow&&) noexcept = delete; +}; + +blt::variant_t no_default_variant; +blt::variant_t not_copyable_variant; +blt::variant_t copyable_variant; +blt::variant_t copyable_nothrow_variant; +blt::variant_t not_movable_variant; +blt::variant_t movable_variant; +blt::variant_t movable_nothrow_variant; + using namespace blt::gp; struct context