Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- A = [[1, 2 / 3, 2, 5 / 2, 5 / 3, 5],
- [3 / 2, 1, 3, 10 / 3, 3, 9],
- [1 / 2, 1 / 3, 1, 4 / 3, 7 / 8, 5 / 2],
- [2 / 5, 3 / 10, 3 / 4, 1, 5 / 6, 12 / 5],
- [3 / 5, 1 / 3, 8 / 7, 6 / 5, 1, 3],
- [1 / 5, 1 / 9, 2 / 5, 5 / 12, 1 / 3, 1]]
- B = [[1, 2 / 5, 3, 7 / 3, 1 / 2, 1],
- [5 / 2, 1, 4 / 7, 5 / 8, 1 / 3, 3],
- [1 / 3, 7 / 4, 1, 1 / 2, 2, 1 / 2],
- [3 / 7, 8 / 5, 2, 1, 4, 2],
- [2, 3, 1 / 2, 1 / 4, 1, 1 / 2],
- [1, 1 / 3, 2, 1 / 2, 2, 1]]
- C = [[1, 17 / 4, 17 / 20, 8 / 5, 23 / 6, 8 / 3],
- [4 / 17, 1, 1 / 5, 2 / 5, 9 / 10, 2 / 3],
- [20 / 17, 5, 1, 21 / 10, 51 / 10, 10 / 3],
- [5 / 8, 5 / 2, 10 / 21, 1, 5 / 2, 11 / 6],
- [6 / 23, 10 / 9, 10 / 51, 2 / 5, 1, 19 / 30],
- [3 / 8, 3 / 2, 3 / 10, 6 / 11, 30 / 19, 1]]
- def koczkodaj(mtx):
- maxOfVal = 0
- for x in range(len(mtx)):
- for y in range(len(mtx)):
- if x == y:
- continue
- for z in range(len(mtx)):
- if y == z:
- continue
- inKocz = min(abs(1 - (mtx[x][z] * mtx[z][y]) / mtx[x][y]), abs(1 - mtx[x][y] / (mtx[x][z] * mtx[z][y])))
- if inKocz > maxOfVal:
- maxOfVal = inKocz
- return maxOfVal
- def checkValInKocz(n, k):
- return 1 - ((1 + pow(4 * (n - 1) * (n - k - 2), 1 / 2)) / (2 * (n - 1)))
- # ########### A
- print("Matrix A:")
- print("Koczkodaj Index: ", koczkodaj(A))
- print("Checked Value(max index value): ", checkValInKocz(6, 2))
- n = 6
- k = 2
- A1 = [[1, 2 / 3, 2, 5 / 2],
- [3 / 2, 1, 3, 10 / 3],
- [1 / 2, 1 / 3, 1, 4 / 3],
- [2 / 5, 3 / 10, 3 / 4, 1]]
- B1 = [[5 / 3, 5],
- [3, 9],
- [7 / 8, 5 / 2],
- [5 / 6, 12 / 5]]
- for i in range(n - k):
- for j in range(n - k):
- if i != j:
- A1[i][j] *= -1 / (n - 1)
- Wk = [3, 1]
- B1 = np.matmul(B1, Wk)
- b = B1 * 1 / (n - 1)
- W = np.matmul(np.linalg.inv(A1), b)
- res = np.concatenate((W, Wk), axis=None)
- print("Final ranking: ", res)
- # ########### B
- print("\nMatrix B:")
- print("Koczkodaj Index: ", koczkodaj(B))
- print("Checked Value(max index value): ", checkValInKocz(6, 3))
- n = 6
- k = 3
- A1 = [[1, 2 / 5, 3],
- [5 / 2, 1, 4 / 7],
- [1 / 3, 7 / 4, 1]]
- B1 = [[7 / 3, 1 /2, 1],
- [5 / 8, 1 / 3, 3],
- [1 / 2, 2, 1 / 2]]
- for i in range(n - k):
- for j in range(n - k):
- if i != j:
- A1[i][j] *= -1 / (n - 1)
- Wk = [2, 1 / 2, 1]
- B1 = np.matmul(B1, Wk)
- b = B1 * 1 / (n - 1)
- W = np.matmul(np.linalg.inv(A1), b)
- res = np.concatenate((W, Wk), axis=None)
- print("Final ranking: ", res)
- # ########### C
- print("\nMatrix C:")
- print("Koczkodaj Index: ", koczkodaj(C))
- print("Checked Value(max index value): ", checkValInKocz(6, 2))
- n = 6
- k = 2
- reshapedC = [[1, 23 / 6, 17 / 20, 8 / 3, 17 / 4, 8 / 5],
- [6 / 23, 1, 10 / 51, 19 / 30, 10 / 9, 2 / 5],
- [20 / 17, 51 / 10, 1, 10 / 3, 5, 21 / 10],
- [3 / 8, 30 / 19, 3 / 10, 1, 3 / 2, 6 / 11],
- [4 / 17, 9 / 10, 1 / 5, 2 / 3, 1, 2 / 5],
- [5 / 8, 5 / 2, 10 / 21, 11 / 6, 5 / 2, 1]]
- A1 = [[1, 23 / 6, 17 / 20, 8 / 3],
- [6 / 23, 1, 10 / 51, 19 / 30],
- [20 / 17, 51 / 10, 1, 10 / 3],
- [3 / 8, 30 / 19, 3 / 10, 1]]
- B1 = [[17 / 4, 8 / 5],
- [10 / 9, 2 / 5],
- [5, 21 / 10],
- [3 / 2, 6 / 11]]
- for i in range(n - k):
- for j in range(n - k):
- if i != j:
- A1[i][j] *= -1 / (n - 1)
- Wk = [2, 5]
- B1 = np.matmul(B1, Wk)
- b = B1 * 1 / (n - 1)
- W = np.matmul(np.linalg.inv(A1), b)
- res = np.concatenate((W, Wk), axis=None)
- print("Final ranking: ", res)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement