I am trying to solve a multi-objective optimization problem using platypus and NSGA2 algorithm. Following is a example code of an implementation:
minimaize ( x^2 , (x-1)^2 ) for x in [-10,10]
from platypus import NSGAII, Problem, Real
def schaffer(x):
return [x[0]**2, (x[0]-2)**2]
problem = Problem(1, 2)
problem.types[:] = Real(-10, 10)
problem.function = schaffer
algorithm = NSGAII(problem)
algorithm.run(10000)
But my problems is that, If I want to maximize x^2 and minimize (x-1)^2, how i should define problems and what is the correct way to do it.
In these examples, we have assumed that the objectives are being minimized. Platypus is flexible and allows the optimization direction to be changed per objective by setting the directions attribute. For example:
So the correct way is in following: