Compare commits
2 Commits
58b68b70bb
...
6972a30696
Author | SHA1 | Date |
---|---|---|
Brett | 6972a30696 | |
Brett | 9a43cd7e81 |
|
@ -1,5 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.25)
|
||||
project(blt-gp VERSION 0.0.100)
|
||||
project(blt-gp VERSION 0.0.103)
|
||||
|
||||
include(CTest)
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ std::array<context, 200> fitness_cases;
|
|||
blt::gp::prog_config_t config = blt::gp::prog_config_t()
|
||||
.set_initial_min_tree_size(2)
|
||||
.set_initial_max_tree_size(6)
|
||||
.set_elite_count(10)
|
||||
.set_elite_count(2)
|
||||
.set_crossover_chance(0.9)
|
||||
.set_mutation_chance(0.1)
|
||||
.set_reproduction_chance(0.1)
|
||||
|
@ -106,10 +106,10 @@ int main()
|
|||
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(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);
|
||||
|
@ -124,7 +124,8 @@ int main()
|
|||
{
|
||||
BLT_TRACE("------------{Begin Generation %ld}------------", program.get_current_generation());
|
||||
BLT_START_INTERVAL("Symbolic Regression", "Gen");
|
||||
program.create_next_generation(blt::gp::select_fitness_proportionate_t{}, blt::gp::select_fitness_proportionate_t{}, blt::gp::select_fitness_proportionate_t{});
|
||||
auto sel = blt::gp::select_fitness_proportionate_t{};
|
||||
program.create_next_generation(sel, sel, sel);
|
||||
BLT_END_INTERVAL("Symbolic Regression", "Gen");
|
||||
BLT_TRACE("Move to next generation");
|
||||
BLT_START_INTERVAL("Symbolic Regression", "Fitness");
|
||||
|
|
|
@ -64,7 +64,8 @@ namespace blt::gp
|
|||
stream << (static_cast<double>(data.total_used_bytes) / static_cast<double>(data.total_size_bytes) * 100) << "%), ";
|
||||
stream << data.total_used_bytes << "/";
|
||||
stream << data.total_no_meta_bytes << "(";
|
||||
stream << (static_cast<double>(data.total_used_bytes) / static_cast<double>(data.total_no_meta_bytes) * 100) << "%), (empty space: ";
|
||||
stream << (static_cast<double>(data.total_used_bytes) / static_cast<double>(data.total_no_meta_bytes) * 100)
|
||||
<< "%), (empty space: ";
|
||||
stream << data.total_remaining_bytes << ") blocks: " << data.blocks << " || unallocated space: ";
|
||||
stream << data.total_dealloc_used << "/";
|
||||
stream << data.total_dealloc;
|
||||
|
@ -74,7 +75,8 @@ namespace blt::gp
|
|||
stream << data.total_dealloc_used << "/";
|
||||
stream << data.total_dealloc_no_meta;
|
||||
if (data.total_dealloc_no_meta > 0)
|
||||
stream << "(" << (static_cast<double>(data.total_dealloc_used) / static_cast<double>(data.total_dealloc_no_meta * 100)) << "%)";
|
||||
stream << "(" << (static_cast<double>(data.total_dealloc_used) / static_cast<double>(data.total_dealloc_no_meta * 100))
|
||||
<< "%)";
|
||||
stream << ", (empty space: " << data.total_dealloc_remaining << ")]";
|
||||
return stream;
|
||||
}
|
||||
|
@ -176,7 +178,6 @@ namespace blt::gp
|
|||
#endif
|
||||
#endif
|
||||
auto diff = head->used_bytes_in_block() - bytes;
|
||||
BLT_TRACE(diff);
|
||||
// if there is not enough room left to pop completely off the block, then move to the next previous block
|
||||
// and pop from it, update the amount of bytes to reflect the amount removed from the current block
|
||||
if (diff < 0)
|
||||
|
@ -347,6 +348,31 @@ namespace blt::gp
|
|||
return (size + (MAX_ALIGNMENT - 1)) & ~(MAX_ALIGNMENT - 1);
|
||||
}
|
||||
|
||||
inline static constexpr auto metadata_size()
|
||||
{
|
||||
return sizeof(typename block::block_metadata_t);
|
||||
}
|
||||
|
||||
inline static constexpr auto block_size()
|
||||
{
|
||||
return sizeof(block);
|
||||
}
|
||||
|
||||
inline static constexpr auto page_size()
|
||||
{
|
||||
return PAGE_SIZE;
|
||||
}
|
||||
|
||||
inline static constexpr auto page_size_no_meta()
|
||||
{
|
||||
return page_size() - metadata_size();
|
||||
}
|
||||
|
||||
inline static constexpr auto page_size_no_block()
|
||||
{
|
||||
return page_size() - block_size();
|
||||
}
|
||||
|
||||
private:
|
||||
struct block
|
||||
{
|
||||
|
|
|
@ -1 +1 @@
|
|||
perf stat -d -d -d -r 30 -e branches,branch-misses,cache-misses,cache-references,cycles,instructions,alignment-faults,cgroup-switches,faults,duration_time,user_time,system_time,L1-dcache-loads,L1-dcache-load-misses,L1-dcache-prefetches,L1-icache-loads,L1-icache-load-misses,dTLB-loads,dTLB-load-misses,iTLB-loads,iTLB-load-misses,l2_request_g1.all_no_prefetch,page-faults,page-faults:u,page-faults:k ./cmake-build-release/blt-SR-playground-example
|
||||
perf stat -d -d -d -r 30 -e branches,branch-misses,cache-misses,cache-references,cycles,instructions,alignment-faults,cgroup-switches,faults,duration_time,user_time,system_time,L1-dcache-loads,L1-dcache-load-misses,L1-dcache-prefetches,L1-icache-loads,L1-icache-load-misses,dTLB-loads,dTLB-load-misses,iTLB-loads,iTLB-load-misses,l2_request_g1.all_no_prefetch,page-faults,page-faults:u,page-faults:k ./cmake-build-release/blt-symbolic-regression-example
|
||||
|
|
|
@ -280,6 +280,59 @@ void test_basic()
|
|||
auto val = stack.pop<float>();
|
||||
RUN_TEST(val != 60.000000f, stack, "Basic 2 Test Passed", "Basic 2 Test Failed. Unexpected value produced '%lf'", val);
|
||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
||||
BLT_ASSERT(stack.empty() && "Stack was not empty after basic evaluation.");
|
||||
}
|
||||
BLT_INFO("Testing basic with stack over boundary");
|
||||
{
|
||||
blt::gp::stack_allocator stack;
|
||||
stack.push(std::array<blt::u8, blt::gp::stack_allocator::page_size_no_block() - sizeof(float)>{});
|
||||
stack.push(50.0f);
|
||||
stack.push(10.0f);
|
||||
auto size = stack.size();
|
||||
BLT_TRACE_STREAM << size << "\n";
|
||||
BLT_ASSERT(size.blocks > 1 && "Stack doesn't have more than one block!");
|
||||
basic_2.make_callable<blt::gp::detail::empty_t>()(nullptr, stack, stack);
|
||||
auto val = stack.pop<float>();
|
||||
stack.pop<std::array<blt::u8, blt::gp::stack_allocator::page_size_no_block() - sizeof(float)>>();
|
||||
RUN_TEST(val != 60.000000f, stack, "Basic 2 Boundary Test Passed", "Basic 2 Test Failed. Unexpected value produced '%lf'", val);
|
||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
||||
BLT_ASSERT(stack.empty() && "Stack was not empty after basic evaluation over stack boundary");
|
||||
}
|
||||
}
|
||||
|
||||
void test_mixed()
|
||||
{
|
||||
BLT_INFO("Testing mixed with stack");
|
||||
{
|
||||
blt::gp::stack_allocator stack;
|
||||
stack.push(50.0f);
|
||||
stack.push(10.0f);
|
||||
stack.push(true);
|
||||
stack.push(false);
|
||||
basic_mixed_4.make_callable<blt::gp::detail::empty_t>()(nullptr, stack, stack);
|
||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
||||
auto val = stack.pop<float>();
|
||||
RUN_TEST(val != 50.000000f, stack, "Mixed 4 Test Passed", "Mixed 4 Test Failed. Unexpected value produced '%lf'", val);
|
||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
||||
BLT_ASSERT(stack.empty() && "Stack was not empty after basic evaluation.");
|
||||
}
|
||||
BLT_INFO("Testing mixed with stack over boundary");
|
||||
{
|
||||
blt::gp::stack_allocator stack;
|
||||
stack.push(std::array<blt::u8, blt::gp::stack_allocator::page_size_no_block() - sizeof(float)>{});
|
||||
stack.push(50.0f);
|
||||
stack.push(10.0f);
|
||||
stack.push(false);
|
||||
stack.push(true);
|
||||
auto size = stack.size();
|
||||
BLT_TRACE_STREAM << size << "\n";
|
||||
BLT_ASSERT(size.blocks > 1 && "Stack doesn't have more than one block!");
|
||||
basic_mixed_4.make_callable<blt::gp::detail::empty_t>()(nullptr, stack, stack);
|
||||
auto val = stack.pop<float>();
|
||||
stack.pop<std::array<blt::u8, blt::gp::stack_allocator::page_size_no_block() - sizeof(float)>>();
|
||||
RUN_TEST(val != 10.000000f, stack, "Mixed 4 Boundary Test Passed", "Mixed 4 Test Failed. Unexpected value produced '%lf'", val);
|
||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
||||
BLT_ASSERT(stack.empty() && "Stack was not empty after basic evaluation over stack boundary");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -287,6 +340,8 @@ void test_operators()
|
|||
{
|
||||
log_box box("-----------------------{Operator Testing}-----------------------", BLT_INFO_STREAM);
|
||||
test_basic();
|
||||
BLT_NEWLINE();
|
||||
test_mixed();
|
||||
}
|
||||
|
||||
int main()
|
||||
|
|
Loading…
Reference in New Issue