cleanup tree evaluation
parent
1fb168a8f8
commit
d5dea3b31e
|
@ -1,5 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.25)
|
||||
project(blt-gp VERSION 0.0.122)
|
||||
project(blt-gp VERSION 0.0.123)
|
||||
|
||||
include(CTest)
|
||||
|
||||
|
|
|
@ -108,6 +108,8 @@ namespace blt::gp
|
|||
|
||||
virtual tree_t apply(gp_program& program, const tree_t& p); // NOLINT
|
||||
|
||||
void mutate_point(gp_program& program, tree_t& c, blt::size_t node);
|
||||
|
||||
virtual ~mutation_t() = default;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -34,9 +34,6 @@ namespace blt::gp
|
|||
|
||||
struct op_container_t
|
||||
{
|
||||
// op_container_t(detail::callable_t& func, detail::transfer_t& transfer, operator_id id, bool is_value):
|
||||
// func(func), transfer(transfer), id(id), is_value(is_value)
|
||||
// {}
|
||||
op_container_t(detail::callable_t& func, blt::size_t type_size, operator_id id, bool is_value):
|
||||
func(func), type_size(type_size), id(id), is_value(is_value)
|
||||
{}
|
||||
|
|
2
lib/blt
2
lib/blt
|
@ -1 +1 @@
|
|||
Subproject commit 3e8b616bf9d0513824d4452e3e77fccac910f0fb
|
||||
Subproject commit 42fa3782007e92119f550fcc8c871398ec1310e8
|
|
@ -210,10 +210,17 @@ namespace blt::gp
|
|||
{
|
||||
auto c = p;
|
||||
|
||||
mutate_point(program, c, program.get_random().get_size_t(0ul, c.get_operations().size()));
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
void mutation_t::mutate_point(gp_program& program, tree_t& c, blt::size_t node)
|
||||
{
|
||||
auto& ops_r = c.get_operations();
|
||||
auto& vals_r = c.get_values();
|
||||
|
||||
auto begin_point = static_cast<blt::ptrdiff_t>(program.get_random().get_size_t(0ul, ops_r.size()));
|
||||
auto begin_point = static_cast<blt::ptrdiff_t>(node);
|
||||
auto end_point = find_endpoint(program, ops_r, begin_point);
|
||||
auto begin_operator_id = ops_r[begin_point].id;
|
||||
const auto& type_info = program.get_operator_info(begin_operator_id);
|
||||
|
@ -276,8 +283,8 @@ namespace blt::gp
|
|||
<< "\n";
|
||||
std::cout << "now Named: " << (program.get_name(ops_r[begin_point].id) ? *program.get_name(ops_r[begin_point].id) : "Unnamed") << "\n";
|
||||
std::cout << "Was named: " << (program.get_name(begin_operator_id) ? *program.get_name(begin_operator_id) : "Unnamed") << "\n";
|
||||
std::cout << "Parent:" << std::endl;
|
||||
p.print(program, std::cout, false, true);
|
||||
//std::cout << "Parent:" << std::endl;
|
||||
//p.print(program, std::cout, false, true);
|
||||
std::cout << "Child:" << std::endl;
|
||||
c.print(program, std::cout, false, true);
|
||||
std::cout << std::endl;
|
||||
|
@ -286,8 +293,6 @@ namespace blt::gp
|
|||
throw std::exception();
|
||||
}
|
||||
#endif
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
blt::ptrdiff_t find_endpoint(blt::gp::gp_program& program, const std::vector<blt::gp::op_container_t>& container, blt::ptrdiff_t index)
|
||||
|
|
|
@ -47,20 +47,15 @@ namespace blt::gp
|
|||
|
||||
auto value_stack = values;
|
||||
auto& values_process = results.values;
|
||||
auto operations_stack = operations;
|
||||
|
||||
while (!operations_stack.empty())
|
||||
for (const auto& operation : blt::reverse_iterate(operations.begin(), operations.end()))
|
||||
{
|
||||
auto operation = operations_stack.back();
|
||||
// keep the last value in the stack on the process stack stored in the eval context, this way it can be accessed easily.
|
||||
operations_stack.pop_back();
|
||||
if (operation.is_value)
|
||||
{
|
||||
value_stack.transfer_bytes(values_process, operation.type_size);
|
||||
continue;
|
||||
}
|
||||
operation.func(context, values_process, values_process);
|
||||
//operations_stack.emplace_back(empty_callable, operation.type_size, operation.id, true);
|
||||
}
|
||||
|
||||
return results;
|
||||
|
|
Loading…
Reference in New Issue