I'm using DEAP for a multiobjective problem, using NSGA2. I have a maximization (coverage) objective, where fitness function result are between 0 and 1and the minimization (price) fitness function return values from 0 to 50000.These are the values I used:
POP_SIZE = 50
MAX_GEN = 80
MUT_PROB = 0.2
CX_PROB = 0.8
creator.create("FitnessMulti", base.Fitness, weights=(-1.0,1.0))
creator.create("Individual", list, fitness=creator.FitnessMulti)
toolbox = base.Toolbox()
toolbox.register("attr_bool", random.randint, 0, 1)
size_cromossome = len(dataset) #dataset has 1042 items
toolbox.register('individual', genFunkyInd, creator.Individual, size_cromossome, max_ones)
toolbox.register("population", tools.initRepeat, list, toolbox.individual)
toolbox.register("evaluate", eval_func)
toolbox.register("select", tools.selNSGA2)
toolbox.register("mate", tools.cxTwoPoint)
toolbox.register("mutate", tools.mutFlipBit, indpb=0.01)
pop = toolbox.population(n=POP_SIZE)
hof = tools.ParetoFront()
stats_fit = tools.Statistics(lambda ind: ind.fitness.values)
stats = tools.MultiStatistics(fitness=stats_fit)
stats.register("min", np.min, axis=0)
stats.register("max", np.max, axis=0)
pop, log = algorithms.eaMuPlusLambda(pop, toolbox, mu=int(POP_SIZE), lambda_= POP_SIZE, cxpb= CX_PROB, mutpb= MUT_PROB, stats= stats, ngen= MAX_GEN, halloffame=hof, verbose= True)
However the paretoFront results shows many equal results. I print all values:
i = 0
for ind in hof:
i += 1
print(i, ind.fitness.values)
1 (11878.0, 0.7306999999999999)
2 (11878.0, 0.7306999999999999)
3 (11878.0, 0.7306999999999999)
...320 equal results...
320 (11878.0, 0.7306999999999999)
321 (12449.0, 0.7436)
322 (12449.0, 0.7436)
...many... equal results
501 (14916.0, 0.7793)
502 (14916.0, 0.7793)
503 (14916.0, 0.7793)
Why it happen? I have reviewed two equal individuals and all characteristics are the same.
How could be possible to maintain only unique values on ParetoFront?