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] ]) 利用吴志彬群体共识决策算法3.1求互补矩阵
时间: 2023-07-02 12:22:00 浏览: 212
setuptools-0.6b1-py2.4.egg
吴志彬群体共识决策算法的第3.1步是求互补矩阵,具体实现方法如下:
```python
import numpy as np
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]])
n = B1.shape[0] # 获取矩阵的维度
# 求互补矩阵 P
P = np.zeros((n, n))
for i in range(n):
for j in range(n):
if i == j:
P[i][j] = 0
elif i < j:
if np.sum(B1[i, :] < B1[j, :]) == n:
P[i][j] = 1
P[j][i] = -1
print("互补矩阵 P:\n", P)
```
代码中,我们首先定义了矩阵 B1,然后根据算法3.1的定义,求出了互补矩阵 P。具体实现方法是,对于 P 矩阵中的每个元素 P[i][j],当 i < j 时,如果 B1 矩阵第 i 行中所有元素都小于第 j 行中的对应元素,则 P[i][j] = 1,P[j][i] = -1。否则,P[i][j] = P[j][i] = 0。
最后,我们输出求得的互补矩阵 P。
阅读全文