esa / pagmo2

A C++ platform to perform parallel computations of optimisation tasks (global and local) via the asynchronous generalized island model.
https://esa.github.io/pagmo2/
GNU General Public License v3.0
808 stars 160 forks source link

[BUG] Calling evolve iteratvely with NSGA-II to obtain new non-dominated solutions #462

Closed mitkof6 closed 3 years ago

mitkof6 commented 3 years ago

Describe the bug

It is possible that this is not a bug in pagmo2, but an issue in my implementation.

I am using NSGA-II. I have a population of a specific size (e.g., 40). I am evolving the population using max generations (e.g., 30) multiple times. Each time I call the evolve function I pass the population obtained from the previous step.

pagmo::thread_bfe thread_bfe;
pagmo::nsga2 method ( max_generations );
method.set_bfe ( pagmo::bfe { thread_bfe } );
pagmo::algorithm algorithm = pagmo::algorithm { method };
pagmo::population population { problem, thread_bfe, population_size };
initialize_population ( population );
for ( auto evolution = 0; evolution < max_evolutions; evolution++ ) {
    population = algorithm.evolve ( population );
    save_population ( evolution, population );
}

The problem is: if I plot the population assuming I have only two objective functions, I observe that the new population might contain solutions that are dominated. For example, a solution obtained in iteration 10 might be worse than a solution obtained in 8 (see screenshots below). Do I have to merge the previous and the new population and extract the non-dominated solutions manually?

Expected behavior

I would expect that the new population would be better or at least the same as the previous. For some reason, solutions that were better were discarded and substituted for solutions that are worse.

Screenshots

I am attaching two figures where you can observe this issue:

slow_gait.pdf fast_gait.pdf

Environment (please complete the following information):

Thank you for your time!

mitkof6 commented 3 years ago

I think it might be my fault. I have more than 2 objective functions. Plotting a 2D representation does not necessarily mean that the non-dominant solution is displayed properly if we ignore the third dimension.