diff --git a/CMakeLists.txt b/CMakeLists.txt index d59eb3e..0b4d0fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(blt-gp VERSION 0.0.68) +project(blt-gp VERSION 0.0.69) include(CTest) diff --git a/examples/pg_symbolic_regression.cpp b/examples/pg_symbolic_regression.cpp index df5424c..5ecf031 100644 --- a/examples/pg_symbolic_regression.cpp +++ b/examples/pg_symbolic_regression.cpp @@ -36,8 +36,8 @@ blt::gp::prog_config_t config = blt::gp::prog_config_t() .set_initial_max_tree_size(6) .set_elite_count(0) .set_max_generations(50) - .set_pop_size(5000) - .set_thread_count(0); + .set_pop_size(500) + .set_thread_count(1); blt::gp::type_provider type_system; blt::gp::gp_program program{type_system, SEED, config}; diff --git a/include/blt/gp/program.h b/include/blt/gp/program.h index b34b8d2..ac788fb 100644 --- a/include/blt/gp/program.h +++ b/include/blt/gp/program.h @@ -286,9 +286,16 @@ namespace blt::gp if (config.threads == 1) { thread_execution_service = new std::function([this, &fitness_function]() { - if (thread_helper.evaluation_left > 0) + for (const auto& ind : blt::enumerate(current_pop.get_individuals())) { - + fitness_function(ind.second.tree, ind.second.fitness, ind.first); + if (ind.second.fitness.adjusted_fitness > current_stats.best_fitness) + current_stats.best_fitness = ind.second.fitness.adjusted_fitness; + + if (ind.second.fitness.adjusted_fitness < current_stats.worst_fitness) + current_stats.worst_fitness = ind.second.fitness.adjusted_fitness; + + current_stats.overall_fitness = current_stats.overall_fitness + ind.second.fitness.adjusted_fitness; } }); } else diff --git a/include/blt/gp/stack.h b/include/blt/gp/stack.h index 297f859..d119694 100644 --- a/include/blt/gp/stack.h +++ b/include/blt/gp/stack.h @@ -401,11 +401,12 @@ namespace blt::gp auto old = head; head = head->metadata.prev; if (head == nullptr) - free_chain(old); + head = old; + //free_chain(old); // required to prevent silly memory :3 - //if (head != nullptr) - // head->metadata.next = nullptr; - //std::free(old); +// if (head != nullptr) +// head->metadata.next = nullptr; +// std::free(old); } private: diff --git a/test_perf.sh b/test_perf.sh index 075b123..7ace957 100755 --- a/test_perf.sh +++ b/test_perf.sh @@ -1 +1 @@ -perf stat -d -d -d -r 30 -e branches,branch-misses,cache-misses,cache-references,cycles,instructions,alignment-faults,cgroup-switches,faults,duration_time,user_time,system_time,L1-dcache-loads,L1-dcache-load-misses,L1-dcache-prefetches,L1-icache-loads,L1-icache-load-misses,dTLB-loads,dTLB-load-misses,iTLB-loads,iTLB-load-misses,l2_request_g1.all_no_prefetch ./cmake-build-release/blt-SR-playground-example +perf stat -d -d -d -r 30 -e branches,branch-misses,cache-misses,cache-references,cycles,instructions,alignment-faults,cgroup-switches,faults,duration_time,user_time,system_time,L1-dcache-loads,L1-dcache-load-misses,L1-dcache-prefetches,L1-icache-loads,L1-icache-load-misses,dTLB-loads,dTLB-load-misses,iTLB-loads,iTLB-load-misses,l2_request_g1.all_no_prefetch,page-faults,page-faults:u,page-faults:k ./cmake-build-release/blt-SR-playground-example