You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I am using PyGAD for my University project, and I encountered a problem today that I did not find earlier. If anyone can help me figure out the problem, thanks in advance :)
The problem I have is that the number of solutions, in each generation is different. When printing the solutions, I can see I am getting 18 solutions shown one generation, 17 in a different generation etc. Furthermore, it repeats the solutions within the generation.
The parameters I have chosen are based on wanting a convergence for two design variables within a search space, where parents are kept for the next generation and selecting parents based on which ones have the best fitness evaluation results. The code that I have used to decide the parameters of PyGAD:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I am using PyGAD for my University project, and I encountered a problem today that I did not find earlier. If anyone can help me figure out the problem, thanks in advance :)
The problem I have is that the number of solutions, in each generation is different. When printing the solutions, I can see I am getting 18 solutions shown one generation, 17 in a different generation etc. Furthermore, it repeats the solutions within the generation.
The parameters I have chosen are based on wanting a convergence for two design variables within a search space, where parents are kept for the next generation and selecting parents based on which ones have the best fitness evaluation results. The code that I have used to decide the parameters of PyGAD:
num_generations = 100
sol_per_pop = 12
num_parents_mating = 4
mutation_probability = 0.5
keep_parents = 2
num_genes = 2
parent_selection_type = "sss"
crossover_type = "uniform"
mutation_type = "random"
initial_population = np.array([
[10, 1],
[100, 2],
[200, 3],
[300, 4],
[400, 5],
[500, 1],
[570, 2],
[250, 3],
[150, 4],
[350, 5],
[450, 2],
[550, 3],
])
gene_space=[range(10, 571), range(1, 6)]
def fitness_func(ga_instance, solution, solution_idx):
Objective_Function = User_Definition(Inputs)
solution_fitness = Objective_Function
print(ga_instance.generations_completed, solution_idx, solution_fitness, solution)
return solution_fitness
def callback_generation(ga_instance):
solution, solution_fitness, solution_idx = ga_instance.best_solution()
print(' ---> End of generation', ga_instance.generations_completed, ":", solution_fitness)
print(' ---> End of generation', ga_instance.generations_completed, ":", solution)
ga_instance = pygad.GA(num_generations=num_generations,
num_parents_mating=num_parents_mating,
fitness_func=fitness_func,
sol_per_pop=sol_per_pop,
num_genes=num_genes,
parent_selection_type=parent_selection_type,
crossover_type=crossover_type,
mutation_type=mutation_type,
mutation_probability=mutation_probability,
on_generation=callback_generation,
initial_population=initial_population,
gene_space=gene_space)
Beta Was this translation helpful? Give feedback.
All reactions