Compare commits

..

No commits in common. "914995fc8222e34cc36916aa444be498792ec1bc" and "58681803e9fe6b1f4711f609e441f3e3168775fd" have entirely different histories.

9 changed files with 30 additions and 33 deletions

View File

@ -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)

View File

@ -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(500)
.set_pop_size(5000)
.set_thread_count(0);
blt::gp::type_provider type_system;

View File

@ -216,9 +216,8 @@ 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
auto alg = aligned_size(bytes);
to.copy_from(*this, alg);
pop_bytes(alg);
to.copy_from(*this, aligned_size(bytes));
pop_bytes(bytes);
}
template<typename... Args>
@ -301,7 +300,7 @@ namespace blt::gp
auto aligned_ptr = get_aligned_pointer(bytes);
if (aligned_ptr == nullptr)
{
expand(size_ + bytes);
expand(bytes + MAX_ALIGNMENT);
aligned_ptr = get_aligned_pointer(bytes);
}
if (aligned_ptr == nullptr)

@ -1 +1 @@
Subproject commit 78710a12cca9ecf7f92394ddf66ed5e2c0301484
Subproject commit 72211e3d7b29cec887257d59578669f198c2d3da

View File

@ -198,15 +198,15 @@ int main()
program.set_operations(builder.build());
BLT_DEBUG("Generate Initial Population");
auto sel = blt::gp::select_fitness_proportionate_t{};
program.generate_population(type_system.get_type<float>().id(), fitness_function, sel, sel, sel);
program.generate_population(type_system.get_type<float>().id(), fitness_function);
BLT_DEBUG("Begin Generation Loop");
while (!program.should_terminate())
{
BLT_TRACE("------------{Begin Generation %ld}------------", program.get_current_generation());
BLT_START_INTERVAL("Symbolic Regression", "Gen");
program.create_next_generation();
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");

View File

@ -37,7 +37,7 @@ struct large_2048
// not actually 4096 but will fill the whole page (4096)
struct large_4096
{
blt::u8 data[4096];
blt::u8 data[blt::gp::stack_allocator::page_size_no_block()];
};
struct large_6123

View File

@ -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) (size: t: %ld u: %ld r: %ld) filled: %f%%",
BLT_TRACE("%lf [index %ld] (fitness: %lf, raw: %lf) (depth: %ld) (blocks: %ld) (size: t: %ld m: %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.total_size_bytes, size.total_used_bytes,
tree.get_depth(program), size.blocks, size.total_size_bytes, size.total_no_meta_bytes, size.total_used_bytes,
size.total_remaining_bytes,
static_cast<double>(size.total_used_bytes) / (size.total_size_bytes == 0 ? 1 : static_cast<double>(size.total_size_bytes)));
static_cast<double>(size.total_used_bytes) / static_cast<double>(size.total_no_meta_bytes));
}
//std::string small("--------------------------");
//for (blt::size_t i = 0; i < std::to_string(program.get_current_generation()).size(); i++)
@ -109,13 +109,12 @@ int main()
program.set_operations(builder.build());
auto sel = blt::gp::select_tournament_t{};
program.generate_population(type_system.get_type<float>().id(), fitness_function, sel, sel, sel);
program.generate_population(type_system.get_type<float>().id(), fitness_function);
while (!program.should_terminate())
{
print_best();
program.create_next_generation();
program.create_next_generation(blt::gp::select_tournament_t{}, blt::gp::select_tournament_t{}, blt::gp::select_tournament_t{});
program.next_generation();
program.evaluate_fitness();
}

View File

@ -47,7 +47,7 @@ struct large_2048
// not actually 4096 but will fill the whole page (4096)
struct large_4096
{
blt::u8 data[4096];
blt::u8 data[blt::gp::stack_allocator::page_size_no_block()];
};
struct large_6123

View File

@ -100,8 +100,7 @@ struct large_2048
// not actually 4096 but will fill the whole page (4096)
struct large_4096
{
// TODO: this test is now obsolete
blt::u8 data[4096];
blt::u8 data[blt::gp::stack_allocator::page_size_no_block()];
};
struct large_6123
@ -312,16 +311,16 @@ void test_basic()
BLT_INFO("Testing basic with stack over boundary");
{
blt::gp::stack_allocator stack;
stack.push(std::array<blt::u8, 4096 - sizeof(float)>{});
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!");
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, 4096 - sizeof(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");
@ -349,18 +348,18 @@ void test_mixed()
BLT_INFO("Testing mixed with stack over boundary");
{
blt::gp::stack_allocator stack;
stack.push(std::array<blt::u8, 4096 - sizeof(float)>{});
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(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, 4096 - sizeof(float)>>();
stack.pop<std::array<blt::u8, blt::gp::stack_allocator::page_size_no_block() - 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");
@ -387,17 +386,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, 4096 - sizeof(large_256)>{});
stack.push(std::array<blt::u8, blt::gp::stack_allocator::page_size_no_block() - 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, 4096 - sizeof(large_256)>>();
stack.pop<std::array<blt::u8, blt::gp::stack_allocator::page_size_no_block() - 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");
@ -428,7 +427,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>();
@ -457,17 +456,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 - 32>());
stack.push(std::array<blt::u8, 20480 - 18290 - blt::gp::stack_allocator::block_size()>());
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 - 32>>();
stack.pop<std::array<blt::u8, 20480 - 18290 - blt::gp::stack_allocator::block_size()>>();
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");