Skip to content
Discussion options

You must be logged in to vote

Hi @TiMo3654,

The reason for doubling the number of calls to the fitness function is calling the best_solution() method in the generation callback function.

defcheck_for_termination(ga_instance): ifga_instance.best_solution()[1] ==np.float64(-0.0):
return"stop"

When this method is called without passing the pop_fitness parameter, then it works as by calculating the fitness of the current population by calling the fitness function.

As you have 50 solutions, then one call to the best_solution() method makes 50 calls to the fitness function. For 20 generations, then it makes 50*20 calls. So, the overall total number of calls is 50*20 + 50*20 + 50 = 2050.

In PyGAD, the fitn…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected byTiMo3654
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
questionFurther information is requested
2 participants
@TiMo3654@ahmedfgad