forked from renansantosmendes/PhD_2020_01
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript-paretos-moead.py
More file actions
73 lines (55 loc) · 2.11 KB
/
Copy pathscript-paretos-moead.py
File metadata and controls
73 lines (55 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import os
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
def get_nondominated_vectors(X):
X = np.array(X)
p_is_dominated = 0
q_is_dominated = 0
X_bool = np.zeros(X.shape[0])
for q in range(X.shape[0]):
q_ = X[q]
for p in X:
if pareto(q_,p):
X_bool[q] = 1
return [list(X[i]) for i,j in enumerate(X_bool) if X_bool[i] == 0]
def pareto(p,q):#p domina q? a resposta é um booleano
y = False
if sum(p >= q) == len(p):
if sum(p == q) != len(p):
y = True
return y
file_path = '/home/renansantos/Área de Trabalho/Doutorado/PhD_2019_01/PhD_2019_01/Results_2020/MOEAD/MOEAD_R3_CA/'
file_name = 'moead-combined_pareto_reduced.csv'
f = open(os.path.join(file_path, file_name), 'r',encoding='utf-8')
data = [i.split(']')[0].replace('[','').replace(',','').split() for i in f.readlines()]
data = [(float(i[0]), float(i[1]), float(i[2])) for i in data]
data = pd.DataFrame(data=data).drop_duplicates()
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
x =data[0].tolist()
y =data[1].tolist()
z =data[2].tolist()
ax.scatter(x, y, z, c='r', marker='o', label='MOEAD+ag')
file_path = '/home/renansantos/Área de Trabalho/Doutorado/PhD_2019_01/PhD_2019_01/Results_2020/MOEAD/MOEAD_R8/'
file_name = 'moead-combined_pareto_reduced.csv'
lst = [0.1, 10.0, 12.0, 600.0, 50.0, 12.0, 1.0, 6000.0]
lambdas = np.array([float(i) for i in lst])
f = open(os.path.join(file_path, file_name), 'r',encoding='utf-8')
data = [i.split(']')[0].replace('[','').replace(',','').split() for i in f.readlines()]
data = [[float(j) for j in line] for line in data]
data = [list(line) for line in np.array(data)*lambdas]
data = [[i[0] + i[3] + i[6] + i[7], i[1] + i[4], i[2] + i[5]] for i in data]
data = get_nondominated_vectors(data)
data = pd.DataFrame(data=data).drop_duplicates()
print(data)
x =data[0].tolist()
y =data[1].tolist()
z =data[2].tolist()
ax.scatter(x, y, z, c='b', marker='v', label='MOEAD')
ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')
plt.legend()
plt.show()