silly
parent
a5238bc798
commit
04fe36deb8
|
@ -1,5 +1,5 @@
|
||||||
cmake_minimum_required(VERSION 3.25)
|
cmake_minimum_required(VERSION 3.25)
|
||||||
project(blt-gp VERSION 0.1.52)
|
project(blt-gp VERSION 0.1.53)
|
||||||
|
|
||||||
include(CTest)
|
include(CTest)
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include <blt/gp/tree.h>
|
#include <blt/gp/tree.h>
|
||||||
#include <blt/gp/generators.h>
|
#include <blt/gp/generators.h>
|
||||||
#include <blt/std/expected.h>
|
#include <blt/std/expected.h>
|
||||||
|
#include <blt/meta/config_generator.h>
|
||||||
|
|
||||||
namespace blt::gp
|
namespace blt::gp
|
||||||
{
|
{
|
||||||
|
@ -84,6 +85,9 @@ namespace blt::gp
|
||||||
|
|
||||||
std::optional<crossover_t::crossover_point_t> get_crossover_point(gp_program& program, const tree_t& c1, const tree_t& c2) const;
|
std::optional<crossover_t::crossover_point_t> get_crossover_point(gp_program& program, const tree_t& c1, const tree_t& c2) const;
|
||||||
|
|
||||||
|
std::optional<point_info_t> get_point_traverse(gp_program& program, const tree_t& t, std::optional<type_id> type,
|
||||||
|
bool scale_per_depth = true) const;
|
||||||
|
|
||||||
static std::optional<point_info_t> find_place_of_type(gp_program& program, const tree_t& t, type_id type);
|
static std::optional<point_info_t> find_place_of_type(gp_program& program, const tree_t& t, type_id type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
2
lib/blt
2
lib/blt
|
@ -1 +1 @@
|
||||||
Subproject commit 56a3c2f836a37258290c2cc43b52df18249b1c0c
|
Subproject commit cd9ec507d63d5e45f36dd16665f2033b0b5fe5f2
|
|
@ -155,7 +155,7 @@ namespace blt::gp
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<crossover_t::crossover_point_t> crossover_t::get_crossover_point(gp_program& program, const tree_t& c1,
|
std::optional<crossover_t::crossover_point_t> 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& c1_ops = c1.get_operations();
|
||||||
auto& c2_ops = c2.get_operations();
|
auto& c2_ops = c2.get_operations();
|
||||||
|
@ -220,6 +220,26 @@ namespace blt::gp
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::optional<crossover_t::point_info_t> crossover_t::get_point_traverse(gp_program& program, const tree_t& t, std::optional<type_id> 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)
|
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()));
|
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?
|
// TODO: new config?
|
||||||
auto& tree = get_static_tree_tl(program);
|
auto& tree = get_static_tree_tl(program);
|
||||||
config.generator.get().generate(tree,
|
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];
|
auto& child = children_data[children_data.size() - 1 - index];
|
||||||
blt::size_t total_bytes_for = c.total_value_bytes(child.start, child.end);
|
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);
|
auto& tree = get_static_tree_tl(program);
|
||||||
config.generator.get().generate(tree,
|
config.generator.get().generate(tree,
|
||||||
{program, replacement_func_info.argument_types[i].id, config.replacement_min_depth,
|
{program, replacement_func_info.argument_types[i].id, config.replacement_min_depth,
|
||||||
config.replacement_max_depth});
|
config.replacement_max_depth});
|
||||||
vals.insert(tree.get_values());
|
vals.insert(tree.get_values());
|
||||||
ops.insert(ops.begin() + static_cast<blt::ptrdiff_t>(start_index), tree.get_operations().begin(),
|
ops.insert(ops.begin() + static_cast<blt::ptrdiff_t>(start_index), tree.get_operations().begin(),
|
||||||
tree.get_operations().end());
|
tree.get_operations().end());
|
||||||
|
@ -531,8 +551,8 @@ namespace blt::gp
|
||||||
{
|
{
|
||||||
auto& tree = get_static_tree_tl(program);
|
auto& tree = get_static_tree_tl(program);
|
||||||
config.generator.get().generate(tree,
|
config.generator.get().generate(tree,
|
||||||
{program, replacement_func_info.argument_types[i].id, config.replacement_min_depth,
|
{program, replacement_func_info.argument_types[i].id, config.replacement_min_depth,
|
||||||
config.replacement_max_depth});
|
config.replacement_max_depth});
|
||||||
blt::size_t total_bytes_for = tree.total_value_bytes();
|
blt::size_t total_bytes_for = tree.total_value_bytes();
|
||||||
vals.copy_from(tree.get_values(), total_bytes_for);
|
vals.copy_from(tree.get_values(), total_bytes_for);
|
||||||
ops.insert(ops.begin() + static_cast<blt::ptrdiff_t>(start_index), tree.get_operations().begin(),
|
ops.insert(ops.begin() + static_cast<blt::ptrdiff_t>(start_index), tree.get_operations().begin(),
|
||||||
|
@ -545,8 +565,8 @@ namespace blt::gp
|
||||||
{
|
{
|
||||||
auto& tree = get_static_tree_tl(program);
|
auto& tree = get_static_tree_tl(program);
|
||||||
config.generator.get().generate(tree,
|
config.generator.get().generate(tree,
|
||||||
{program, replacement_func_info.argument_types[i].id, config.replacement_min_depth,
|
{program, replacement_func_info.argument_types[i].id, config.replacement_min_depth,
|
||||||
config.replacement_max_depth});
|
config.replacement_max_depth});
|
||||||
blt::size_t total_bytes_for = tree.total_value_bytes();
|
blt::size_t total_bytes_for = tree.total_value_bytes();
|
||||||
vals.copy_from(tree.get_values(), total_bytes_for);
|
vals.copy_from(tree.get_values(), total_bytes_for);
|
||||||
ops.insert(ops.begin() + static_cast<blt::ptrdiff_t>(start_index), tree.get_operations().begin(),
|
ops.insert(ops.begin() + static_cast<blt::ptrdiff_t>(start_index), tree.get_operations().begin(),
|
||||||
|
|
Loading…
Reference in New Issue