Dear Marc-Andre,
Thanks for the suggestions, Since I am new to DEAP framework so m facing lots of difficulties. Below i am giving my code in which i have defined Individual type as set and also giving the input file.
CODE:
array=[]
creator.create("FitnessMin",base.Fitness,weights=(-1.0,))
creator.create("Individual",set,fitness=creator.FitnessMin)
def initPopulation(pcls, ind_init, filename):
for line in open(filename).xreadlines():
#print line
if not line:
sys.exit()
else:
array.append(line)
return pcls(ind_init(c) for c in array)
toolbox = base.Toolbox()
toolbox.register("population_guess", initPopulation, list, creator.Individual, "my_guess.json")
population = toolbox.population_guess()
print population
INPUT FILE:-
{"0":[0,1],"1":[2],"2":[3],"3":[4]}
{"0":[0,2],"1":[3],"2":[],"3":[2,4]}
{"0":[0,2],"1":[],"2":[3],"3":[2,4]}
{"0":[0,1],"1":[2],"2":[],"3":[3,4]}
{"0":[0,1],"1":[],"2":[2],"3":[3,4]}
The above code read the input file line by line and then initialize each individual of population.In this code i have used set as individual type and i am getting error in this if i use dict type.
Please help.
Thanks for the help.