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])
希望这有帮助
相关问题 更多 >
编程相关推荐