Compare commits
2 Commits
58681803e9
...
914995fc82
Author | SHA1 | Date |
---|---|---|
Brett | 914995fc82 | |
Brett | 3ac18cd1a4 |
|
@ -105,7 +105,7 @@ if (${BUILD_GP_TESTS})
|
|||
blt_add_project(blt-stack tests/stack_tests.cpp test)
|
||||
blt_add_project(blt-eval tests/evaluation_tests.cpp test)
|
||||
blt_add_project(blt-order tests/order_tests.cpp test)
|
||||
blt_add_project(blt-destructor tests/destructor_test.cpp test)
|
||||
#blt_add_project(blt-destructor tests/destructor_test.cpp test)
|
||||
blt_add_project(blt-gp1 tests/gp_test_1.cpp test)
|
||||
blt_add_project(blt-gp2 tests/gp_test_2.cpp test)
|
||||
blt_add_project(blt-gp3 tests/gp_test_3.cpp test)
|
||||
|
|
|
@ -41,7 +41,7 @@ blt::gp::prog_config_t config = blt::gp::prog_config_t()
|
|||
.set_mutation_chance(0.1)
|
||||
.set_reproduction_chance(0)
|
||||
.set_max_generations(50)
|
||||
.set_pop_size(5000)
|
||||
.set_pop_size(500)
|
||||
.set_thread_count(0);
|
||||
|
||||
blt::gp::type_provider type_system;
|
||||
|
|
|
@ -216,8 +216,9 @@ namespace blt::gp
|
|||
BLT_ABORT(("Not enough bytes in stack to transfer " + std::to_string(bytes) + " bytes requested but " + std::to_string(bytes) +
|
||||
" bytes stored!").c_str());
|
||||
#endif
|
||||
to.copy_from(*this, aligned_size(bytes));
|
||||
pop_bytes(bytes);
|
||||
auto alg = aligned_size(bytes);
|
||||
to.copy_from(*this, alg);
|
||||
pop_bytes(alg);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
|
@ -300,7 +301,7 @@ namespace blt::gp
|
|||
auto aligned_ptr = get_aligned_pointer(bytes);
|
||||
if (aligned_ptr == nullptr)
|
||||
{
|
||||
expand(bytes + MAX_ALIGNMENT);
|
||||
expand(size_ + bytes);
|
||||
aligned_ptr = get_aligned_pointer(bytes);
|
||||
}
|
||||
if (aligned_ptr == nullptr)
|
||||
|
|
2
lib/blt
2
lib/blt
|
@ -1 +1 @@
|
|||
Subproject commit 72211e3d7b29cec887257d59578669f198c2d3da
|
||||
Subproject commit 78710a12cca9ecf7f92394ddf66ed5e2c0301484
|
|
@ -198,15 +198,15 @@ int main()
|
|||
program.set_operations(builder.build());
|
||||
|
||||
BLT_DEBUG("Generate Initial Population");
|
||||
program.generate_population(type_system.get_type<float>().id(), fitness_function);
|
||||
auto sel = blt::gp::select_fitness_proportionate_t{};
|
||||
program.generate_population(type_system.get_type<float>().id(), fitness_function, sel, sel, sel);
|
||||
|
||||
BLT_DEBUG("Begin Generation Loop");
|
||||
while (!program.should_terminate())
|
||||
{
|
||||
BLT_TRACE("------------{Begin Generation %ld}------------", program.get_current_generation());
|
||||
BLT_START_INTERVAL("Symbolic Regression", "Gen");
|
||||
auto sel = blt::gp::select_fitness_proportionate_t{};
|
||||
program.create_next_generation(sel, sel, sel);
|
||||
program.create_next_generation();
|
||||
BLT_END_INTERVAL("Symbolic Regression", "Gen");
|
||||
BLT_TRACE("Move to next generation");
|
||||
BLT_START_INTERVAL("Symbolic Regression", "Fitness");
|
||||
|
|
|
@ -37,7 +37,7 @@ struct large_2048
|
|||
// not actually 4096 but will fill the whole page (4096)
|
||||
struct large_4096
|
||||
{
|
||||
blt::u8 data[blt::gp::stack_allocator::page_size_no_block()];
|
||||
blt::u8 data[4096];
|
||||
};
|
||||
|
||||
struct large_6123
|
||||
|
|
|
@ -58,11 +58,11 @@ void print_best()
|
|||
auto& v = program.get_current_pop().get_individuals()[i];
|
||||
auto& tree = v.tree;
|
||||
auto size = tree.get_values().size();
|
||||
BLT_TRACE("%lf [index %ld] (fitness: %lf, raw: %lf) (depth: %ld) (blocks: %ld) (size: t: %ld m: %ld u: %ld r: %ld) filled: %f%%",
|
||||
BLT_TRACE("%lf [index %ld] (fitness: %lf, raw: %lf) (depth: %ld) (size: t: %ld u: %ld r: %ld) filled: %f%%",
|
||||
tree.get_evaluation_value<float>(nullptr), i, v.fitness.adjusted_fitness, v.fitness.raw_fitness,
|
||||
tree.get_depth(program), size.blocks, size.total_size_bytes, size.total_no_meta_bytes, size.total_used_bytes,
|
||||
tree.get_depth(program), size.total_size_bytes, size.total_used_bytes,
|
||||
size.total_remaining_bytes,
|
||||
static_cast<double>(size.total_used_bytes) / static_cast<double>(size.total_no_meta_bytes));
|
||||
static_cast<double>(size.total_used_bytes) / (size.total_size_bytes == 0 ? 1 : static_cast<double>(size.total_size_bytes)));
|
||||
}
|
||||
//std::string small("--------------------------");
|
||||
//for (blt::size_t i = 0; i < std::to_string(program.get_current_generation()).size(); i++)
|
||||
|
@ -109,12 +109,13 @@ int main()
|
|||
|
||||
program.set_operations(builder.build());
|
||||
|
||||
program.generate_population(type_system.get_type<float>().id(), fitness_function);
|
||||
auto sel = blt::gp::select_tournament_t{};
|
||||
program.generate_population(type_system.get_type<float>().id(), fitness_function, sel, sel, sel);
|
||||
|
||||
while (!program.should_terminate())
|
||||
{
|
||||
print_best();
|
||||
program.create_next_generation(blt::gp::select_tournament_t{}, blt::gp::select_tournament_t{}, blt::gp::select_tournament_t{});
|
||||
program.create_next_generation();
|
||||
program.next_generation();
|
||||
program.evaluate_fitness();
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ struct large_2048
|
|||
// not actually 4096 but will fill the whole page (4096)
|
||||
struct large_4096
|
||||
{
|
||||
blt::u8 data[blt::gp::stack_allocator::page_size_no_block()];
|
||||
blt::u8 data[4096];
|
||||
};
|
||||
|
||||
struct large_6123
|
||||
|
|
|
@ -100,7 +100,8 @@ struct large_2048
|
|||
// not actually 4096 but will fill the whole page (4096)
|
||||
struct large_4096
|
||||
{
|
||||
blt::u8 data[blt::gp::stack_allocator::page_size_no_block()];
|
||||
// TODO: this test is now obsolete
|
||||
blt::u8 data[4096];
|
||||
};
|
||||
|
||||
struct large_6123
|
||||
|
@ -311,16 +312,16 @@ void test_basic()
|
|||
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(std::array<blt::u8, 4096 - 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!");
|
||||
//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, nullptr);
|
||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
||||
auto val = stack.pop<float>();
|
||||
stack.pop<std::array<blt::u8, blt::gp::stack_allocator::page_size_no_block() - sizeof(float)>>();
|
||||
stack.pop<std::array<blt::u8, 4096 - 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");
|
||||
|
@ -348,18 +349,18 @@ void test_mixed()
|
|||
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(std::array<blt::u8, 4096 - sizeof(float)>{});
|
||||
stack.push(50.0f);
|
||||
stack.push(10.0f);
|
||||
stack.push(true);
|
||||
stack.push(false);
|
||||
auto size = stack.size();
|
||||
BLT_TRACE_STREAM << size << "\n";
|
||||
BLT_ASSERT(size.blocks > 1 && "Stack doesn't have more than one block!");
|
||||
// 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, nullptr);
|
||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
||||
auto val = stack.pop<float>();
|
||||
stack.pop<std::array<blt::u8, blt::gp::stack_allocator::page_size_no_block() - sizeof(float)>>();
|
||||
stack.pop<std::array<blt::u8, 4096 - sizeof(float)>>();
|
||||
RUN_TEST(val != 50.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 evaluation over stack boundary");
|
||||
|
@ -386,17 +387,17 @@ void test_large_256()
|
|||
BLT_INFO("Testing large 256 with stack over boundary");
|
||||
{
|
||||
blt::gp::stack_allocator stack;
|
||||
stack.push(std::array<blt::u8, blt::gp::stack_allocator::page_size_no_block() - sizeof(large_256)>{});
|
||||
stack.push(std::array<blt::u8, 4096 - sizeof(large_256)>{});
|
||||
stack.push(base_256);
|
||||
stack.push(691.0f);
|
||||
stack.push(69.420f);
|
||||
auto size = stack.size();
|
||||
BLT_TRACE_STREAM << size << "\n";
|
||||
BLT_ASSERT(size.blocks > 1 && "Stack doesn't have more than one block!");
|
||||
// BLT_ASSERT(size.blocks > 1 && "Stack doesn't have more than one block!");
|
||||
large_256_basic_3.make_callable<blt::gp::detail::empty_t>()(nullptr, stack, stack, nullptr);
|
||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
||||
auto val = stack.pop<large_256>();
|
||||
stack.pop<std::array<blt::u8, blt::gp::stack_allocator::page_size_no_block() - sizeof(large_256)>>();
|
||||
stack.pop<std::array<blt::u8, 4096 - sizeof(large_256)>>();
|
||||
RUN_TEST(!compare(val, base_256), stack, "Large 256 3 Boundary Test Passed", "Large 256 3 Test Failed. Unexpected value produced '%lf'", val);
|
||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
||||
BLT_ASSERT(stack.empty() && "Stack was not empty after evaluation over stack boundary");
|
||||
|
@ -427,7 +428,7 @@ void test_large_4096()
|
|||
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!");
|
||||
// BLT_ASSERT(size.blocks > 1 && "Stack doesn't have more than one block!");
|
||||
large_4096_basic_3b.make_callable<blt::gp::detail::empty_t>()(nullptr, stack, stack, nullptr);
|
||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
||||
auto val = stack.pop<large_4096>();
|
||||
|
@ -456,17 +457,17 @@ void test_large_18290()
|
|||
BLT_INFO("Testing large 18290 with stack over boundary");
|
||||
{
|
||||
blt::gp::stack_allocator stack;
|
||||
stack.push(std::array<blt::u8, 20480 - 18290 - blt::gp::stack_allocator::block_size()>());
|
||||
stack.push(std::array<blt::u8, 20480 - 18290 - 32>());
|
||||
stack.push(base_18290);
|
||||
stack.push(-2543.0f);
|
||||
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!");
|
||||
// BLT_ASSERT(size.blocks > 1 && "Stack doesn't have more than one block!");
|
||||
large_18290_basic_3b.make_callable<blt::gp::detail::empty_t>()(nullptr, stack, stack, nullptr);
|
||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
||||
auto val = stack.pop<large_18290>();
|
||||
stack.pop<std::array<blt::u8, 20480 - 18290 - blt::gp::stack_allocator::block_size()>>();
|
||||
stack.pop<std::array<blt::u8, 20480 - 18290 - 32>>();
|
||||
RUN_TEST(!compare(val, base_18290), stack, "Large 18290 3 Boundary Test Passed", "Large 4096 3 Test Failed. Unexpected value produced '%lf'", val);
|
||||
BLT_TRACE_STREAM << stack.size() << "\n";
|
||||
BLT_ASSERT(stack.empty() && "Stack was not empty after evaluation over stack boundary");
|
||||
|
|
Loading…
Reference in New Issue