Reputation: 41
As the title says, i want to use fitness scalling methods, such as sigma scalling, for i'm having problems with premature genetic conversion in non-optimal solutions.
I know that PyGAD has a on_fitness
method that is called after the fitness values for all my individuals are calculated, and think i could use to solve my problem with it, but could not verify. Can i use it for this purpose?
Thanks for your input.
Upvotes: 1
Views: 274
Reputation: 41
Well I don't know if this is the best way, but here is how I solved my problem.
With the release of PyGAD 2.19, a new constructor option was added, the fitness_batch_size
. As it's name sujests, you can now pass a batch of individuals at once to one execution of your fitness function, like so:
# with fitness_batch_size = None(or 1)
Solution = [2.184, 0,...,3.2819]
# with 1 < fitness_batch_size <= sol_per_pop
Solution = [[2.184, 0,...,3.2819], [1.234, 2.345,..., 5],...,[...]]
With this in mind, now to scale my fitness, I have to adjust fitness_batch_size = sol_per_pop
and generate all fitness values at once. Afterwards, it's matter of passing all values through some kind of scaling and returning this result as my fitness values.
If you know a better way, please post it here. Thanks in advance.
Upvotes: 1