繁体   English   中英

使用带有 NSGA2 的 python DEAP 库解决多目标优化问题

[英]Solving a multi-objective optimization problem using python DEAP library with NSGA2

我想使用DEAP 库解决多目标优化问题。 因为我是 DEAP 的新手,所以我使用 这个 NSGA-II 示例作为我自己问题的模板。 在示例中,在第 59 行中, tools.selNSGA2 function 注册到toolbox object,之后用作工具箱toolbox.select

toolbox.register("select", tools.selNSGA2)

然后在主要的 function 中,在第 96 行中, tools.selTournamentDCD function,用于 select 的后代,但它无法弄清楚。 我在提出 NSGA-II 的论文中也找不到任何关于它的信息。

以下代码是示例的主要 function:

def main(seed=None):
    random.seed(seed)

    NGEN = 250
    MU = 100
    CXPB = 0.9

    pop = toolbox.population(n=MU)

    # Evaluate the individuals with an invalid fitness
    invalid_ind = [ind for ind in pop if not ind.fitness.valid]
    fitnesses = toolbox.map(toolbox.evaluate, invalid_ind)
    for ind, fit in zip(invalid_ind, fitnesses):
        ind.fitness.values = fit

    # This is just to assign the crowding distance to the individuals
    # no actual selection is done
    pop = toolbox.select(pop, len(pop))

    # Begin the generational process
    for gen in range(1, NGEN):
        # Vary the population
        offspring = tools.selTournamentDCD(pop, len(pop))
        offspring = [toolbox.clone(ind) for ind in offspring]

        for ind1, ind2 in zip(offspring[::2], offspring[1::2]):
            if random.random() <= CXPB:
                toolbox.mate(ind1, ind2)

            toolbox.mutate(ind1)
            toolbox.mutate(ind2)
            del ind1.fitness.values, ind2.fitness.values

        # Evaluate the individuals with an invalid fitness
        invalid_ind = [ind for ind in offspring if not ind.fitness.valid]
        fitnesses = toolbox.map(toolbox.evaluate, invalid_ind)
        for ind, fit in zip(invalid_ind, fitnesses):
            ind.fitness.values = fit

        # Select the next generation population
        pop = toolbox.select(pop + offspring, MU)

    return pop, logbook

我的问题: tools.selTournamentDCD function 是 NSGA-II 算法的一部分吗? 是否必须使用tools.selTournamentDCD在 DEAP 中创建后代? 你能告诉我什么时候应该使用这个 function,它有什么作用?

提前致谢

在这篇论文中,您可以查看有关 NSGA-II 的详细信息(这是 DEAP 引用的一篇) https://link.springer.com/chapter/10.1007/3-540-45356-3_83

我仍然是使用这个库的新手,但我认为您不会被迫使用tools.selTournamentDCD

我认为您可以使用其他选择或预选运算符,例如selRandomselRoulette

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM