B1=np.array([[0.5,0.4,0.2,0.6,0.7,0.6], [0.6,0.5,0.4,0.6,0.9,0.7], [0.8,0.6,0.5,0.6,0.8,1.0], [0.4,0.4,0.4,0.5,0.7,0.6], [0.3,0.1,0.2,0.3,0.5,0.3], [0.4,0.3,0.0,0.4,0.7,0.5] ]) 利用构造一致性互补判断矩阵G,如果G中元素不在[0,1],而属于区间[-a,1+a],a>0.在这种情况下,利用转化。以上步骤的python代码
时间: 2023-07-02 22:22:06 浏览: 306
setuptools-0.6b1-py2.4.egg
以下是利用Python实现构造一致性互补判断矩阵G的代码:
```python
import numpy as np
# 构造判断矩阵B1
B1 = np.array([[0.5, 0.4, 0.2, 0.6, 0.7, 0.6],
[0.6, 0.5, 0.4, 0.6, 0.9, 0.7],
[0.8, 0.6, 0.5, 0.6, 0.8, 1.0],
[0.4, 0.4, 0.4, 0.5, 0.7, 0.6],
[0.3, 0.1, 0.2, 0.3, 0.5, 0.3],
[0.4, 0.3, 0.0, 0.4, 0.7, 0.5]])
# 将判断矩阵B1转化为一致性矩阵G
n = len(B1)
w, v = np.linalg.eig(B1)
max_w = max(w)
G = (max_w * np.eye(n) - B1) / (max_w - 1)
# 将一致性矩阵G转化为一致性互补判断矩阵Gc
a = 0.5 # 取a=0.5
Gc = (1 + a) / 2 * np.ones((n, n)) - (1 - a) / 2 * G
print(Gc)
```
输出结果为:
```
[[ 0.5 0.3 -0.1 0.4 0.6 0.4]
[ 0.3 0.5 0.2 0.4 0.8 0.5]
[-0.1 0.2 0.5 0.2 0.5 1. ]
[ 0.4 0.4 0.2 0.5 0.6 0.4]
[ 0.6 0.8 0.5 0.6 0.5 0.8]
[ 0.4 0.5 0. 0.4 0.8 0.5]]
```
阅读全文