Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting the current population after calling step()? #19

Open
Bauxitedev opened this issue Jun 11, 2021 · 1 comment
Open

Getting the current population after calling step()? #19

Bauxitedev opened this issue Jun 11, 2021 · 1 comment

Comments

@Bauxitedev
Copy link

Bauxitedev commented Jun 11, 2021

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)

@haraldmaida
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants