GeneticAlgorithmPython
GeneticAlgorithmPython copied to clipboard
How to create a custom population?
I want to create a custom population with each chromosome/solution will be a pandas DataFrame. How should I create initial_population values and what should be assigned to gene_type attribute?
This is an example.
import pygad
import numpy
def fitness_func(ga_instanse, solution, solution_idx):
return numpy.sum(solution)
ga_instance = pygad.GA(num_generations=5,
num_parents_mating=2,
initial_population=[[1,2],
[5,7]],
gene_type=[int, float],
fitness_func=fitness_func)
ga_instance.run()