DEAP / deap

Distributed Evolutionary Algorithms in Python
http://deap.readthedocs.org/
GNU Lesser General Public License v3.0
5.75k stars 1.12k forks source link

Poor optimization results #165

Closed devinInOttawa closed 7 years ago

devinInOttawa commented 7 years ago

Hi developers, I am a newbie of DEAP and seek for help.

My problem: I use DEAP NSGA2 for multiobjective optimization. It works by parallelism and fast on cluster than optimization program I made. But when I use it on one of my program, DEAP cannot get a clear and continuous Pareto front which I got before. What I got is some gathered but discontinuous points group. Only a small part of these points overlap with Pareto front. I think the possible reason is variety loss owing to bad parameter settings, improper mutation, crossover methods, or compact algorithm. Expect developers can give me some suggestion on how to use deap more effectively!

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.popsize, 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 !

fmder commented 7 years ago

I don't think is properly speaking an issue.