-
-
Notifications
You must be signed in to change notification settings - Fork 489
Open
@AndreyKolomiets
Description
The following is my code for pygad:
num_parents_mating = 4 parent_selection_type = "random" keep_parents = -1 crossover_type = "single_point" mutation_type = "random" mutation_percent_genes = 10 num_edge_pairs_per_edges = 5.0 drop_single_nodes = True ga_instance = pygad.GA(num_generations=num_generations, num_parents_mating=num_parents_mating, fitness_func=problem.fitness_func, parent_selection_type=parent_selection_type, keep_parents=keep_parents, crossover_type=crossover_type, mutation_type=mutation_type, mutation_percent_genes=mutation_percent_genes, random_seed=100500, gene_type=int, keep_elitism=0, initial_population=initial_population, stop_criteria=['saturate_15'], logger=logger, save_solutions=False, on_fitness=on_fitness, )
problem is class instance, it is computing fitness as well as logging and saving some data. Best solution and best fitness are stored in best_solution_cls and best_fitness_cls attributes respectively. There is a strange bug in my code, that best_solution_cls doesn't match to best_fitness_cls. While best_fitness_cls is indeed the best fitness across all tries, best_fitness_cls is some other solution, it is usually not even valid (for invalid solutions, fitness=-1000.0 is expected).
The following is conda_env.yml used to create environment:
channels: - pytorch - anaconda - conda-forge - defaults dependencies: - python=3.7.15=haa1d7c7_0 - pip=22.2.2=py37h06a4308_0 - setuptools=65.5.0=py37h06a4308_0 - pip: - numpy==1.21.6 - pandas==1.3.5 - scipy==1.7.3 - tqdm==4.64.1 - networkx==2.6.3 - numba==0.56.4 - pygad==3.2.0