如何可视化多目标多输入优化问题的输出?

时间:2019-07-07 20:44:00

标签: python optimization genetic-algorithm

对于multi-objective optimization problem,一种可视化输出的可能性是在二维图中绘制两个目标函数输出(请参见下面的参考代码):

plotting the output of the objective functions in a scatter plot

如何还可以整合图中输入参数的参考值,以直观了解输入参数对目标输出的影响?

代码:

from platypus import NSGAII, Problem, Real

import matplotlib
matplotlib.use('QT5Agg')
import matplotlib.pyplot as plt

def schaffer(x):
    return [x[0]**2 + x[1]**2, (x[0]-2)**2 + (x[1]-2)**2]

problem = Problem(2, 2)    # two decision variables, two objective functions
problem.types[:] = Real(-100, 100)
problem.function = schaffer

algorithm = NSGAII(problem)
algorithm.run(10_000)

plt.figure(1)
plt.scatter([s.objectives[0] for s in algorithm.result],
            [s.objectives[1] for s in algorithm.result])
plt.xlabel("$f_1(x)$")
plt.ylabel("$f_2(x)$")
plt.grid()
plt.show()

0 个答案:

没有答案