forked from Project-Platypus/Platypus
-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.py
21 lines (16 loc) · 608 Bytes
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from platypus import NSGAIII, DTLZ2
# define the problem definition
problem = DTLZ2(3)
# instantiate the optimization algorithm
algorithm = NSGAIII(problem, divisions_outer=12)
# optimize the problem using 10,000 function evaluations
algorithm.run(10000)
# plot the results using matplotlib
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter([s.objectives[0] for s in algorithm.result],
[s.objectives[1] for s in algorithm.result],
[s.objectives[2] for s in algorithm.result])
plt.show()