silly
parent
82b8c82768
commit
17a2805ef1
|
@ -1,5 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.25)
|
||||
project(blt-gp VERSION 0.1.14)
|
||||
project(blt-gp VERSION 0.1.15)
|
||||
|
||||
include(CTest)
|
||||
|
||||
|
|
|
@ -102,18 +102,6 @@ int main()
|
|||
type_system.register_type<float>();
|
||||
|
||||
blt::gp::operator_builder<context> builder{type_system};
|
||||
// builder.add_operator(add);
|
||||
// builder.add_operator(sub);
|
||||
// builder.add_operator(mul);
|
||||
// builder.add_operator(pro_div);
|
||||
// builder.add_operator(op_sin);
|
||||
// builder.add_operator(op_cos);
|
||||
// builder.add_operator(op_exp);
|
||||
// builder.add_operator(op_log);
|
||||
//
|
||||
// builder.add_operator(lit, true);
|
||||
// builder.add_operator(op_x);
|
||||
|
||||
program.set_operations(builder.build(add, sub, mul, pro_div, op_sin, op_cos, op_exp, op_log, lit, op_x));
|
||||
|
||||
BLT_DEBUG("Generate Initial Population");
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace blt::gp
|
|||
|
||||
class operator_storage_test;
|
||||
// context*, read stack, write stack
|
||||
//using callable_t = std::function<void(void*, stack_allocator&, stack_allocator&, bitmask_t*)>;
|
||||
using operator_func_t = std::function<void(void*, stack_allocator&, stack_allocator&)>;
|
||||
using eval_func_t = std::function<evaluation_context(const tree_t& tree, void* context)>;
|
||||
// debug function,
|
||||
using print_func_t = std::function<void(std::ostream&, stack_allocator&)>;
|
||||
|
|
|
@ -187,21 +187,21 @@ namespace blt::gp
|
|||
}
|
||||
}
|
||||
|
||||
// template<typename Context>
|
||||
// [[nodiscard]] detail::callable_t make_callable() const
|
||||
// {
|
||||
// return [this](void* context, stack_allocator& read_allocator, stack_allocator& write_allocator, detail::bitmask_t* mask) {
|
||||
// if constexpr (detail::is_same_v<Context, detail::remove_cv_ref<typename detail::first_arg<Args...>::type>>)
|
||||
// {
|
||||
// // first arg is context
|
||||
// write_allocator.push(this->operator()(context, read_allocator, mask));
|
||||
// } else
|
||||
// {
|
||||
// // first arg isn't context
|
||||
// write_allocator.push(this->operator()(read_allocator, mask));
|
||||
// }
|
||||
// };
|
||||
// }
|
||||
template<typename Context>
|
||||
[[nodiscard]] detail::operator_func_t make_callable() const
|
||||
{
|
||||
return [this](void* context, stack_allocator& read_allocator, stack_allocator& write_allocator) {
|
||||
if constexpr (detail::is_same_v<Context, detail::remove_cv_ref<typename detail::first_arg<Args...>::type>>)
|
||||
{
|
||||
// first arg is context
|
||||
write_allocator.push(this->operator()(context, read_allocator, nullptr));
|
||||
} else
|
||||
{
|
||||
// first arg isn't context
|
||||
write_allocator.push(this->operator()(read_allocator, nullptr));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[[nodiscard]] inline constexpr std::optional<std::string_view> get_name() const
|
||||
{
|
||||
|
|
|
@ -75,6 +75,8 @@ namespace blt::gp
|
|||
type_id return_type;
|
||||
// number of arguments for this operator
|
||||
argc_t argc;
|
||||
// per operator function callable (slow)
|
||||
detail::operator_func_t func;
|
||||
};
|
||||
|
||||
struct operator_storage
|
||||
|
@ -225,6 +227,7 @@ namespace blt::gp
|
|||
|
||||
info.argc.argc_context = info.argc.argc = sizeof...(Args);
|
||||
info.return_type = return_type_id;
|
||||
info.func = op.template make_callable<Context>();
|
||||
|
||||
((std::is_same_v<detail::remove_cv_ref<Args>, Context> ? info.argc.argc -= 1 : (blt::size_t) nullptr), ...);
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ namespace blt::gp
|
|||
|
||||
if (args.program.is_static(top.id))
|
||||
{
|
||||
//info.function(nullptr, tree.get_values(), tree.get_values(), nullptr);
|
||||
info.func(nullptr, tree.get_values(), tree.get_values());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue