godatadriven / evol

a python grammar for evolutionary algorithms and heuristics
https://evol.rtfd.io
MIT License
187 stars 12 forks source link

Unevaluated population in callback #132

Closed rogiervandergeer closed 5 years ago

rogiervandergeer commented 5 years ago

The callback function in the callback step gets a copy of the population -- which is not evaluated.

Even though we evaluate beforehand:

    def callback(self, callback_function: Callable[['BasePopulation'], None],
                 **kwargs) -> 'BasePopulation':
        """
        Performs a callback function on the population. Can be used for
        custom logging/checkpointing.
        :param callback_function: Function that accepts the population
        as a first argument.
        :return:
        """
        self.evaluate(lazy=True)
        callback_function(copy(self), **kwargs)
        return self

the copy creates a new population with new individuals, who aren't evaluated.