[英]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
我认为您可以使用其他选择或预选运算符,例如
selRandom
或selRoulette
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.