Merge remote-tracking branch 'refs/remotes/origin/main'

thread
Brett 2024-08-12 22:02:40 -04:00
commit 6e45ea3d6d
4 changed files with 16 additions and 13 deletions

View File

@ -399,6 +399,7 @@ namespace blt::gp
void next_generation()
{
current_pop.drop(*this);
current_pop = std::move(next_pop);
current_generation++;
}
@ -543,12 +544,7 @@ namespace blt::gp
~gp_program()
{
std::cout << ("Destroying Program!") << std::endl;
for (auto& pop : current_pop.get_individuals())
{
pop.tree.drop(*this);
pop = {};
}
current_pop.drop(*this);
thread_helper.lifetime_over = true;
thread_helper.barrier.notify_all();
thread_helper.thread_function_condition.notify_all();

View File

@ -337,6 +337,7 @@ namespace blt::gp
population_t& operator=(population_t&&) = default;
void drop(gp_program& program);
private:
std::vector<individual> individuals;
};

View File

@ -291,7 +291,7 @@ namespace blt::gp
return;
if (values.empty())
return;
std::cout << "---- NEW TREE ---- References " << *reference_counter << " ----" << std::endl;
//std::cout << "---- NEW TREE ---- References " << *reference_counter << " ----" << std::endl;
if (reference_counter->load() > 1)
return;
static blt::hashset_t<blt::size_t> sets;
@ -305,18 +305,24 @@ namespace blt::gp
float* f;
blt::size_t i;
};
auto h = values.from<hello>(0);
if (sets.find(h.i) != sets.end())
//auto h = values.from<hello>(0);
/*if (sets.find(h.i) != sets.end())
std::cout << "HEY ASSHOLE Duplicate Value " << h.i << std::endl;
else
{
std::cout << "Destroying Value " << h.i << std::endl;
sets.insert(h.i);
}
}*/
program.get_destroy_func(operation.id)(detail::destroy_t::RETURN, nullptr, values);
values.pop_bytes(static_cast<blt::ptrdiff_t>(stack_allocator::aligned_size(operation.type_size)));
}
operations.pop_back();
}
}
void population_t::drop(gp_program& program)
{
for (auto& pop : get_individuals())
pop.tree.drop(program);
}
}

View File

@ -113,9 +113,9 @@ 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(0)
.set_crossover_chance(0.9)
.set_mutation_chance(0.1)
.set_reproduction_chance(0)
.set_crossover_chance(0)
.set_mutation_chance(0)
.set_reproduction_chance(1.0)
.set_max_generations(5)
.set_pop_size(500)
.set_thread_count(0);