# Untitled

a guest
Oct 23rd, 2019
81
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import numpy as np
2. import math
3.
4. def GMMRanking(matrix):
5. rowMul = list()
6.
7. for row in matrix:
8. mult = 1
9. for item in np.asarray(row[0])[0]:
10. mult *= item
11. rowMul.append(np.power(mult,1/len(matrix)))
12.
13. rowSum = np.asarray(rowMul).sum()
14. rowMul = np.asarray(np.matrix(rowMul).transpose()) / rowSum
15. return rowMul
16.
17. def Satty(matrix):
18. size = len(matrix)
19. lmax = max(np.linalg.eigvals(matrix))
20. return (lmax - size) / (size - 1)
21.
22. def Geom(matrix):
23. matrixSum = 0
24. matrix = GMMRanking(matrix)
25. scalar = 2/((len(matrix)-1)*(len(matrix)-2))
26. for row in matrix:
27. for item in row:
28. matrixSum += np.power(np.log(item),2)
29.
30. return scalar * matrixSum
31.
32. def Koczkodaj(matrix):
33. n = len(matrix)
34. def K(i,j,k):
35. return (matrix[i,j]/(matrix[i,k]*matrix[k,j]))
36.
37. def minimum(i,j,k):
38. return min(math.fabs(1-K(i,j,k)),math.fabs(1-(1/K(i,j,k))))
39.
40. trp = [ minimum(i,j,k) for i in range(0,n-2) for j in range(1,n-1) for k in range(2,n)]
41. return max(trp)
42.
43. A = np.matrix([[1,7,3],[(1/7),1,2],[(1/3),(1/2),1]])
44. B = np.matrix([[1,(1/5),7,1],[5,1,(1/2),2],[(1/7),2,1,3],[1,(1/2),(1/3),1]])
45. C = np.matrix([[1,2,5,1,7],[(1/2),1,3,(1/2),5],[(1/5),(1/3),1,(1/5),2],[1,2,5,1,7],[(1/7),(1/5),(1/2),(1/7),1]])
46.
47. print("Wskazniki macierzy A: ")
48. print("Satty'ego : ", Satty(A))
49. print("Geometryczny : ", Geom(A))
50. print("Koczkodaj : ", Koczkodaj(A))
51.
52. print("Wskazniki macierzy B: ")
53. print("Satty'ego : ", Satty(B))
54. print("Geometryczny : ", Geom(B))
55. print("Koczkodaj : ", Koczkodaj(B))
56.
57. print("Wskazniki macierzy C: ")
58. print("Satty'ego : ", Satty(C))
59. print("Geometryczny : ", Geom(C))
60. print("Koczkodaj : ", Koczkodaj(C))
RAW Paste Data