Skip to content

neat.Population.run() does not return the best genome #271

@jongdetim

Description

@jongdetim

Describe the bug
After training, the fittest genome is often not the one that was returned. Instead it seems to return the strongest genome from the final generation. I noticed that the top fitness during training can be higher than the genome returned by neat.Population.run().

To Reproduce
Steps to reproduce the behavior:

  1. Configure any model with a neat.StdOutReporter reporter
  2. Train the model, such as with:
    pe = neat.ParallelEvaluator(multiprocessing.cpu_count(), evaluate_genome)
    winner = population.run(pe.evaluate, 20)
  3. Observe the reported species MAX fitness genomes during training, and notice that the highest fitness if often not the one that population.run() returned.

Expected behavior
The genome returned by Population.run() should be the fittest genome it has seen at any point during training.

Stdout example

In the following output snippet, we can see that the max fitness of both species 2 and 3 is 22.0, however, the training function returns a genome with fitness: 17.0:

...
****** Running generation 18 ******

Population's average fitness: 2.98333 stdev: 4.80101
Best fitness: 22.00000 - size: (8, 19) - species 2 - id 956
Average adjusted fitness: 0.131
Mean genetic distance 2.401, standard deviation 0.954
Population of 59 members in 3 species:
ID age size fitness adj fit stag
==== === ==== ======= ======= ====
1 18 14 5.0 0.091 5
2 18 23 22.0 0.146 0
3 14 22 22.0 0.156 1
Total extinctions: 0
Generation time: 0.744 sec (0.499 average)

****** Running generation 19 ******

Population's average fitness: 2.79661 stdev: 3.76325
Best fitness: 17.00000 - size: (8, 19) - species 2 - id 956
Average adjusted fitness: 0.163
Mean genetic distance 2.369, standard deviation 1.078
Population of 61 members in 3 species:
ID age size fitness adj fit stag
==== === ==== ======= ======= ====
1 19 17 7.0 0.155 6
2 19 24 17.0 0.189 1
3 15 20 15.0 0.144 2
Total extinctions: 0
Generation time: 0.757 sec (0.531 average)
winner fitness: 17
Key: 956

Desktop (please complete the following information):

  • OS: Windows 10 64-bit
  • Python 3.9.6 64-bit
  • neat-python 0.92

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy