-
Notifications
You must be signed in to change notification settings - Fork 1
/
weight.py
120 lines (99 loc) · 5.03 KB
/
weight.py
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import math
import numpy as np
# m, n, 및 Aij 값 설정
m = 15# 대안 개수
n = 9# 성능 지표 개수
def calculate_entropy(p_matrix):
entropy = np.zeros_like(p_matrix) # 결과 배열 초기화
for i, p_value in enumerate(p_matrix):
if p_value == 0:
entropy[i] = 0
else:
entropy[i] = (p_value * np.log(p_value))
# return np.sum(entropy)
return entropy
# Aij_values = [
# # [295.76,113488.52,336.63,0.84,2.17,16.20,629.92,2356.33,2360.19],
# # [0.09,1.59,0.76,0.07,0.08,0.13,0.68,0.99,4.50],
# # [0.05,2.65,0.60,0.06,1.22,0.34,0.62,0.99,4.15],
# # [2.47,51.26,9.40,0.55,14*10**15,10.31,8.76,0.13,51.61],
# # [2.47,51.26,9.40,0.55,30*10**13,10.31,8.76,0.13,51.61],
# # [25.29,824.90,35.37,0.17,0.00,8.69,53.84,16.20,201.58],
# # [0.07,1.58,0.75,0.07,0.10,0.14,0.67,0.99,4.52],
# # [0.54,0.93,1.98,0.23,0.60,0.15,1.76,0.96,10.09],
# # [2.47,51.26,9.40,0.55,12*10**5,10.31,8.76,0.13,51.61],
# # [0.47,1.03,1.10,0.03,1.92,4.88,1.31,0.98,6.90],
# # [0.19,2.38,0.91,0.13,2.66,0.08,0.88,0.99,5.50],
# # [2.47,51.26,9.40,0.62,98.84,10.31,8.76,0.13,51.61],
# # [0.17,3.45,0.87,0.12,0.84,0.07,0.82,0.99,5.20],
# # [1.83,3.08,0.97,0.04,7.00,74.45,4.37,0.83,19.92],
# # [0.15,2.57,0.81,0.09,0.00,0.12,0.72,0.99,4.60],
# # [124.51,29504.49,256.19,0.18,0.38,14.05,283.27,611.94,1203.50]
#
# # [69.41, 11047.23, 21.30, 0.53, 2.35, 2.28, 163.13, 0.19, 33.83],
# # [10.11, 493.24, 34.43, 0.12, 3.62, 0.40, 28.93, 0.95, 7.16],
# # [30.02, 10220.44, 120.07, 0.37, 10 * 10 ** 12, 3.49, 116.14, 0.10, 32.54],
# # [30.02, 10220.44, 120.07, 0.37, 26 * 10 ** 15, 3.49, 116.14, 0.10, 32.54],
# # [30.02, 10220.44, 120.07, 0.37, 78 * 10 ** 14, 3.49, 116.14, 0.10, 32.54],
# # [222.01, 33053322.50, 298.60, 0.89, 3.70, 554.15, 5885.98, 3544.59, 1850.31],
# # [3.76, 101.65, 14.32, 0.05, 2.40, 0.07, 12.34, 0.99, 3.28],
# # [16.37, 2040.01, 62.17, 0.27, 1.19, 0.64, 54.50, 0.78, 14.55],
# # [30.02, 10220.44, 120.07, 0.37, 97933.71, 3.49, 116.14, 0.10, 32.54],
# # [18.76, 1578.68, 57.10, 0.20, 7.55, 9.23, 52.46, 0.83, 12.80],
# # [0.46, 37.30, 2.43, 0.01, 1.51, 0.08, 6.53, 1.00, 2.04],
# # [30.02, 10220.44, 120.07, 0.37, 22 * 10 ** 16, 3.49, 116.14, 0.10, 32.54],
# # [3.49, 4558.43, 88.15, 0.32, 0.10, 4.45, 69.27, 0.51, 21.74],
# # [2.58, 128.20, 16.33, 0.07, 2.87, 0.05, 12.64, 0.99, 3.71],
# # [30.02, 10220.44, 120.07, 0.37, 68 * 10 ** 15, 3.49, 116.14, 0.10, 32.54]
#
# [- 13.250, 230.824, 22.084, 13.250, 0.067, - 0.169, 8.310, 0.150, 3.799],
# [- 33.997, 1317.848, 42.496, 33.997, 0.029, - 0.463, 14.233, - 3.855, 9.077],
# [77.384, 6558.147, 128.973, 77.384, 0.245, 0.796, 26.690, - 23.161, 20.249],
# [- 33.997, 1317.848, 42.496, 33.997, 0.029, - 0.463, 14.233, - 3.855, 9.077],
# [- 45.146, 2275.856, 75.244, 45.146, 0.008, - 0.636, 17.236, - 7.384, 11.928],
# [- 28.400, 883.341, 47.333, 28.400, 0.060, - 0.380, 9.798, - 2.254, 7.431],
# [- 13.907, 244.067, 17.384, 13.907, 0.070, - 0.178, 7.957, 0.101, 3.906],
# [59.407, 3858.768, 99.012, 59.407, 0.218, 0.636, 20.296, - 13.216, 15.532],
# [- 69.553, 5108.912, 173.882, 69.553, 0.000, - 1.054, 18.415, - 17.822, 17.872],
# [- 58.983, 3736.428, 73.728, 58.983, 0.004, - 0.866, 17.941, - 12.765, 15.284],
# [- 1.162, 9.163, 4.643, 2.786, 0.101, - 0.014, 3.125, 0.966, 0.757],
# [- 28.841, 956.424, 72.103, 29.841, 0.041, - 0.387, 12.481, - 2.524, 7.733],
# [11.079, 125.741, 27.697, 11.079, 0.121, 0.135, 1.938, 0.537, 2.804],
# [- 9.099, 120.347, 46.359, 9.272, 0.076, - 0.115, 6.852, 0.557, 2.743],
# [- 48.983, 3736.498, 98.305, 58.983, 0.004, - 0.866, 17.941, - 12.765, 15.284],
# [- 28.395, 942.757, 141.975, 28.395, 0.037, - 0.380, 14.061, - 2.473, 7.677]
# ]
np.set_printoptions(formatter={'all': lambda x: f'{x:.9f}'})
# Aij 값을 NumPy 배열로 변환
Aij = np.load("Aij.npy")
# Aij 배열 사용
print(Aij)
print("-------------------------")
# 각 Aij 요소를 정규화
normalized_Aij = Aij / np.sum(Aij, axis=0)
print(normalized_Aij)
print("-------------------------")
k = 1 / math.log(n)
M_ij = np.zeros((m, n))
for i in range(m):
p_matrix = normalized_Aij[i, :]
entropy = calculate_entropy(p_matrix)
for j in range(n):
M_ij[i][j] = entropy[j]
print("-------------------------")
print(M_ij)
E_ij = -k * np.sum(M_ij, axis=0)
abs_E_ij = np.abs(E_ij)
print("-------------------------")
print(abs_E_ij)
E_ij_minus_1 =1 - abs_E_ij
print("-------------------------")
# print(entropies)
print(E_ij_minus_1)
print("-------------------------")
weight = np.zeros(n)
for j in range(n):
weight[j] = (E_ij_minus_1[j]) / sum(E_ij_minus_1 )
print(weight)
w_1 = np.abs(weight)
print("-------------------------")