diff --git a/CMakeLists.txt b/CMakeLists.txt index 524a9df..ba3639b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/examples/rice_classification.cpp b/examples/rice_classification.cpp index 57723ee..47100d8 100644 --- a/examples/rice_classification.cpp +++ b/examples/rice_classification.cpp @@ -113,7 +113,7 @@ constexpr auto fitness_function = [](blt::gp::tree_t& current_tree, blt::gp::fit break; } } - fitness.raw_fitness = static_cast(fitness.hits) / static_cast(training_cases.size()); + fitness.raw_fitness = static_cast(fitness.hits); fitness.standardized_fitness = fitness.raw_fitness; fitness.adjusted_fitness = 1.0 - (1.0 / (1.0 + fitness.standardized_fitness)); return static_cast(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().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); diff --git a/src/selection.cpp b/src/selection.cpp index 34343ed..d54c824 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -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;