简体   繁体   English

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

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

I want to solve a multi-objective optimization problem using DEAP library .我想使用DEAP 库解决多目标优化问题。 Since i am new in DEAP, i used this example of NSGA-II as a template for my own problem.因为我是 DEAP 的新手,所以我使用 这个 NSGA-II 示例作为我自己问题的模板。 In the example, in line 59, tools.selNSGA2 function is registered to toolbox object, after that, is used as toolbox.select :在示例中,在第 59 行中, tools.selNSGA2 function 注册到toolbox object,之后用作工具箱toolbox.select

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

Then in the main function, in line 96, tools.selTournamentDCD function, is used to select offspring, however i couldn't figure out what does it do.然后在主要的 function 中,在第 96 行中, tools.selTournamentDCD function,用于 select 的后代,但它无法弄清楚。 Also i couldn't find anything about it in the paper which NSGA-II is proposed.我在提出 NSGA-II 的论文中也找不到任何关于它的信息。

Following code is the main function of the example:以下代码是示例的主要 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

MY QUESTIONS: Is tools.selTournamentDCD function a part of NSGA-II algorithm?我的问题: tools.selTournamentDCD function 是 NSGA-II 算法的一部分吗? Is it obligatory to use tools.selTournamentDCD to create offspring in DEAP?是否必须使用tools.selTournamentDCD在 DEAP 中创建后代? Can you please tell me when should i use this function and what does it do?你能告诉我什么时候应该使用这个 function,它有什么作用?

Thanks in advance提前致谢

This is the paper where you can check details about NSGA-II (it's the one cited by DEAP) https://link.springer.com/chapter/10.1007/3-540-45356-3_83在这篇论文中,您可以查看有关 NSGA-II 的详细信息(这是 DEAP 引用的一篇) https://link.springer.com/chapter/10.1007/3-540-45356-3_83

I am still new using this library, but I think you are not forced to use tools.selTournamentDCD我仍然是使用这个库的新手,但我认为您不会被迫使用tools.selTournamentDCD

I think you are able to use other selection or pre-selection operators like selRandom or selRoulette我认为您可以使用其他选择或预选运算符,例如selRandomselRoulette

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

相关问题 使用DEAP的具有多个变量的多目标优化 - python - Multi-Objective optimization with multiple variables using DEAP 使用 DEAP 的遗传算法多目标优化 - Multi-objective optimization with Genetic Algorithm using DEAP 使用DEAP最小化多目标函数 - Minimizing multi-objective function using DEAP 在 Python 中使用 Gekko,对于多目标优化问题,是否所有目标函数都必须具有相同的单位? - Using Gekko in Python, for a multi-objective optimization problem, do all objective functions have to be of the same unit? python - 使用 NSGA-II 算法的 pymoo 多目标投资组合优化 - python - pymoo multi-objective portfolio optimisation using NSGA-II algorithm 使用 Platypus (Python) 进行整数、多目标优化 - Integer, multi-objective optimization with Platypus (Python) Pyomo:多目标优化 - Pyomo: Multi-objective optimization pyomo 中的多目标优化 - Multi-objective optimization in pyomo 如何使用神经网络进行多目标优化? - How to do multi-objective optimization using neural networks? 使用逐次二次规划 (SQP) 进行多目标优化的 Python 包 - Python packages for multi-objective optimization using Successive Quadratic Programming (SQP)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM