It use to run perfectly but when I put the toolbox into a function and the function returns the pop it won't work
creator.create("FitnessMax", base.Fitness, weights=(1.0,))
creator.create("Individual", list, fitness=creator.FitnessMax)
creator.create("Strategy", numpy.ndarray, typecode="d")
def initES(icls,scls,number_of_modules,number_of_MPPT,pop_len):
s=icls(Rand(1,number_of_MPPT,number_of_modules))
return s
toolbox = base.Toolbox()
toolbox.register("individual", initES,creator.Individual, creator.Strategy,number_of_modules,all_Number_of_MPPT_dc_inputs,pop_len)
toolbox.register("population", tools.initRepeat, list, toolbox.individual)
toolbox.register("evaluate", evaluate)
toolbox.register("mate", cxTwoPointCopy)
toolbox.register("select", tools.selTournament, tournsize=10)
toolbox.register("mutate", tools.mutShuffleIndexes, indpb=0.5)
pop = toolbox.population(n=100)
hof = tools.HallOfFame(3)
stats = tools.Statistics(key=lambda ind: ind.fitness.values)
stats.register("avg", numpy.mean, axis=0)
stats.register("std", numpy.std, axis=0)
stats.register("min", numpy.min, axis=0)
stats.register("max", numpy.max, axis=0)
pop=algorithms.eaSimple(pop, toolbox, cxpb=0.5, mutpb=0.2, ngen=40,
halloffame=hof, stats=stats, verbose=True)
best_solution = tools.selBest(pop, 1)[0]
print(best_solution)
return pop