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

Features suggestion. Option to force recalculating fitness for every solution and some questions about entire pop fitness calculation #303

Open
KorrawitMick opened this issue Nov 18, 2024 · 1 comment
Labels
question Further information is requested

Comments

@KorrawitMick
Copy link

Referring to "Why the Fitness Function is not Called for Solution at Index 0?"

To force calling the fitness function for each solution in every generation, consider setting keep_elitism and keep_parents to 0. Moreover, keep the 2 parameters save_solutions and save_best_solutions to their default value False.

  1. My project is to find best weights of neural net but subject to input change. So the fitness of the best elite is different in some generations. However, I want to have the feature of keep_elitism to maintain good candidate. How can I get with that?

  2. The phrase Moreover, keep save_solutions = False and save_best_solutions = False. is ambiguous. I'm not sure that this is a must or a suggestion.?

  3. I have created my own function to calculate entire population fitness is more efficient than calling fitness_func separately or in batch. Questions are.

  • When should I call my own function? (On_generation callback I guess)
  • Where should I store my returned fitness value? (I can only think of storing them in a global variable and retrieve from it when fitness_func is called
  • Keeping elitism means that latest fitness value of the elite will not be updated. How to solve this issue?
@ahmedfgad
Copy link
Owner

The fitness of a solution/chromosome is forced to be calculated if the solution is not a parent, elitism, and does not exist in the solutions and best_solutions instance attributes. To not keep any parent, set keep_parents=0. Set keep_elitism=0 to avoid keeping any elitism. To not save the solutions or best solutions, you have to set save_solutions=False and save_best_solutions=False.

You can set fitness_batch_size to the number of solutions. Then call your own function from inside fitness_func(). The fitness are expected to be saved into the last_generation_fitness instance attribute. As long as you update the fitness of the elisitm in last_generation_fitness, then their fitness will change.

@ahmedfgad ahmedfgad added the question Further information is requested label Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants