I have figured out how to use it on Linux system. But I meet a new problem.
My problem:
I use DEAP NSGA2 for multiobjective optimization. It works by parallelism and fast on cluster! O(∩_∩)O
But when I use it on one of my programs, DEAP cannot get a clear and continuous Pareto front which I got before. What I got is some gathered point group distributed on several regions, instead of a clear Pareto front curve. Small part of these point group overlap with Pareto front I got before and other distribute on wrong regions.
I think the possible reason is variety loss owing to bad parameter settings, improper mutation, crossover methods, or compact algorithm I used. Expect developers can give me some suggestions on how to use deap more effectively and properly!
My Program:
def nsga_ii(toolbox, stats=None, verbose=False):
pop = toolbox.population(n=toolbox.pop_size)
pop = toolbox.select(pop, len(pop))
return algorithms.eaMuPlusLambda(pop, toolbox, mu=toolbox.pop_size,
lambda_=toolbox.pop_size,
cxpb=0.5,
mutpb=0.5,
stats=stats,
ngen=10000,
verbose=verbose)
def uniform(low, up, size=None):
return [np.random.uniform(a, b) for a, b in zip(low, up)]
creator.create("FitnessMin", base.Fitness, weights=(-1.0,-1.0, -1.0))
creator.create("Individual", list, fitness=creator.FitnessMin)
NDIM=5
BOUND_LOW=[0.001, 0.001, 0.001, 0.001, 0.001]
BOUND_UP=[10.0, 25.0 ,10.0, 5.0, 5.0]
toolbox = base.Toolbox()
toolbox.register("attr_float", uniform, BOUND_LOW, BOUND_UP, NDIM)
toolbox.register("individual", tools.initIterate, creator.Individual, toolbox.attr_float)
toolbox.register("evaluate",fPID)
toolbox.register("population", tools.initRepeat, list, toolbox.individual)
toolbox.register("mate", tools.cxSimulatedBinaryBounded, low=BOUND_LOW, up=BOUND_UP, eta=20.0)
toolbox.register("mutate", tools.mutPolynomialBounded, low=BOUND_LOW, up=BOUND_UP, eta=20.0, indpb=1.0/NDIM)
toolbox.register("select", tools.selNSGA2)
toolbox.pop_size = 1000
toolbox.register("map", futures.map)
def main():
ddddd=time.time()
res, logbook = nsga_ii(toolbox)
fronts = tools.emo.sortLogNondominated(res, len(res))
with open('population.txt','a') as pfile:
for row in res:
a=fPID(row)
pfile.write(str(row[0])+','+str(row[1])+','+str(row[2])+','+str(row[3])+','+str(row[4])+','+str(a[0])+','+str(a[1])+','+str(a[2])+'\n')
pfile.close()
if name == "main":
main()
Thank you very much !