innoave/genevo

Getting the current population after calling step()?

Bauxitedev opened this issue · 1 comments

Quick question, is it possible to get the current population after calling Simulator::step()?

It seems step() returns an EvaluatedPopulation, which you can query using EvaluatedPopulation::individuals(), but this is the population before applying selection. I want to get the population after applying selection (so after selecting the best parents and cross-breeding them). Is this possible at all?

(Basically I'm looking for a way to access GeneticAlgorithm.population directly, which is not possible at the moment since it's private)

Isn't that a question of where the loop starts? The EvaluatedPopulation is the one where the fitness score has been determined. The population in GeneticAlgorithm.population is the "next generation", which has not been evaluated yet. When calling step() the next time the GeneticAlgorithm.population from the previous loop is returned as EvaluatedPopulation with its fitness score. I could also change the order of the steps in the algorithm so that the last step is the evaluation of the fitness, but then the initial population never gets evaluated.