Arash-codedev / openGA

A free C++ Genetic Algorithm library
Mozilla Public License 2.0
219 stars 49 forks source link

Optimization Issue in Example_SO1: Convergence Failure and Lack of Retained Optimal Samples in Iterative Process #23

Open 1278741833 opened 7 months ago

1278741833 commented 7 months ago

Hi, thanks for this great tool and contribution. Why hasn't this instance converged? After multiple runs, the optimal samples were not retained. Even when the optimal samples appeared during the iteration, they were not preserved. The program being run is example_so1.cpp, and the last_generation.chromosomes did not update according to the results of the iteration. Is this correct? 微信图片_20240403183919 image image

ababaritECN commented 6 months ago

Hi, I got the same problem. I believe that it is related to the fact that new_generation_fronts.empty() is always true in case of single objective optimization, thus I fixed it by adding || (is_single_objective()) to the test:


if ((!new_generation.fronts.empty()) || (is_single_objective()))
                    last_generation = new_generation; ```