shared
Brett 2024-08-27 21:34:31 -04:00
parent d30ba51820
commit 144b3a4ceb
3 changed files with 10 additions and 3 deletions

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.25)
project(blt-gp VERSION 0.1.29)
project(blt-gp VERSION 0.1.30)
include(CTest)

View File

@ -113,7 +113,7 @@ constexpr auto fitness_function = [](blt::gp::tree_t& current_tree, blt::gp::fit
break;
}
}
fitness.raw_fitness = static_cast<double>(fitness.hits) / static_cast<double>(training_cases.size());
fitness.raw_fitness = static_cast<double>(fitness.hits);
fitness.standardized_fitness = fitness.raw_fitness;
fitness.adjusted_fitness = 1.0 - (1.0 / (1.0 + fitness.standardized_fitness));
return static_cast<blt::size_t>(fitness.hits) == training_cases.size();
@ -187,7 +187,7 @@ int main(int argc, const char** argv)
op_minor_axis_length, op_eccentricity, op_convex_area, op_extent));
BLT_DEBUG("Generate Initial Population");
auto sel = blt::gp::select_fitness_proportionate_t{};
auto sel = blt::gp::select_tournament_t{};
program.generate_population(type_system.get_type<float>().id(), fitness_function, sel, sel, sel);
BLT_DEBUG("Begin Generation Loop");
@ -217,6 +217,12 @@ int main(int argc, const char** argv)
BLT_TRACE("Evaluate Fitness");
program.evaluate_fitness();
BLT_END_INTERVAL("Rice Classification", "Fitness");
auto& stats = program.get_population_stats();
BLT_TRACE("Stats:");
BLT_TRACE("Average fitness: %lf", stats.average_fitness.load());
BLT_TRACE("Best fitness: %lf", stats.best_fitness.load());
BLT_TRACE("Worst fitness: %lf", stats.worst_fitness.load());
BLT_TRACE("Overall fitness: %lf", stats.overall_fitness.load());
#ifdef BLT_TRACK_ALLOCATIONS
blt::gp::tracker.stop_measurement(fitness_alloc);

View File

@ -67,6 +67,7 @@ namespace blt::gp
for (blt::size_t i = 0; i < selection_size - 1; i++)
{
auto& sel = pop.get_individuals()[program.get_random().get_size_t(0ul, pop.get_individuals().size())];
BLT_TRACE("Selection %ld (of %ld) = %lf, ind %p, first: %p", i, selection_size, sel.fitness.adjusted_fitness, &sel, &first);
if (sel.fitness.adjusted_fitness > best_guy)
{
best_guy = sel.fitness.adjusted_fitness;