esa / pygmo2

A Python platform to perform parallel computations of optimisation tasks (global and local) via the asynchronous generalized island model.
https://esa.github.io/pygmo2/
Mozilla Public License 2.0
422 stars 57 forks source link

[FEATURE] Track or Record each generation's champion_x during evolve? #64

Closed leeuack closed 3 years ago

leeuack commented 3 years ago

Is your feature request related to a problem? Please describe. While using SGA or other evolutionary algorithms, users may not access each generation's champion_x now. So now it is hard to visualize the process of evolution. Even users set verbosity and extract some logs, they only store the best fitness values of each generation.

Describe the solution you'd like Can users have an optional function to record each gen's champion_x? Is there any way to extract each generation's champion_x?

Best,

bluescarni commented 3 years ago

There are no hooks currently to customise this sort of behaviour in the algorithms.

What you can do is to add some sort of logging to the objective function of your problem. For instance, you can keep a list/dictionary in your problem state that tracks the fitnesses of the decision vectors that are being evaluated.

You can recover your original problem instance from the general pygmo.problem interface using the extract methods:

https://esa.github.io/pygmo2/problem.html#pygmo.problem.extract

leeuack commented 3 years ago

Thank you for your swift reply. I understand to add logging and extract it! It was very helpful!