CodeReclaimers / neat-python

Python implementation of the NEAT neuroevolution algorithm
BSD 3-Clause "New" or "Revised" License
1.41k stars 490 forks source link

Population assumes fitness_criterion to be max while reporting #187

Open thiagobell opened 4 years ago

thiagobell commented 4 years ago

on Population.run(), while compiling statistics for reporting, the methods looks for the genome with the highest fitness value irrespective of what was set under fitness_criterion.

        best = None
        for g in itervalues(self.population):
            if best is None or g.fitness > best.fitness:
                best = g
        self.reporters.post_evaluate(self.config, self.population, self.species, best)

        #Track the best genome ever seen.
        if self.best_genome is None or best.fitness > self.best_genome.fitness:
            self.best_genome = best
regtm commented 3 years ago

Seems consistent with what is checked in the population class for the termination:

if not self.config.no_fitness_termination:
                # End if the fitness threshold is reached.
                fv = self.fitness_criterion(g.fitness for g in itervalues(self.population))
                if fv >= self.config.fitness_threshold:
                    self.reporters.found_solution(self.config, self.generation, best)
                    break