利用矩阵作为鸭嘴兽MOEA的输入

2024-06-16 13:07:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我是新的面向对象编程和优化,由于缺乏适当的文件鸭嘴兽,我不得不问这个问题。我试图使用NSGAII对鸭嘴兽的最大化问题翼型优化。我的初始总体是一个数组(比如说[100x13])。我需要用求值函数求值数组的每一行。
任何寻找有用的文件或解决方案的线索,这是赞赏的。 提前谢谢。你知道吗


Tags: 文件函数数组解决方案总体线索鸭嘴兽nsgaii
1条回答
网友
1楼 · 发布于 2024-06-16 13:07:15
from platypus import Problem, Real, NSGAII

def objectiveFunction()
  ....

  return result

problem = Problem(2, 1) # 2 is number of inputs 1 is number of objectives
problem.types[:] = Real(0, 10) # min and max initial guses
problem.function = objectiveFunction
problem.directions[:] = Problem.Maximize

algorithm = NSGAII(problem, 250) # 250 is the pupulation size
algorithm.run(500) # 500 is the number of function evaluation
result = algorithm.result

#to print the result
for ind, solution in enumerate(algorithm1.result):
    print(ind+1, solution.objectives[0])

希望这有帮助

相关问题 更多 >