通过26个子指标构建一个指标体系,突变级数法代码
时间: 2024-05-07 14:20:30 浏览: 204
突变级数法是一种多指标决策分析方法,用于解决多个指标的决策问题。下面是通过26个子指标构建一个指标体系,突变级数法的Python代码示例:
```python
import numpy as np
# 定义决策矩阵
decision_matrix = np.array([
[2, 3, 4, 4, 5, 3, 5, 3, 3, 4, 5, 4, 3, 5, 4, 2, 3, 4, 3, 4, 4, 5, 3, 3, 4, 5],
[3, 4, 5, 5, 4, 3, 4, 3, 4, 4, 5, 4, 3, 5, 4, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5],
[4, 5, 4, 3, 4, 4, 4, 3, 3, 4, 5, 4, 3, 5, 4, 4, 3, 4, 3, 5, 4, 5, 3, 3, 4, 5],
[2, 3, 4, 4, 5, 3, 5, 3, 3, 4, 5, 4, 3, 5, 4, 2, 3, 4, 3, 4, 4, 5, 3, 3, 4, 5],
[3, 4, 5, 4, 4, 3, 4, 3, 4, 4, 5, 4, 3, 5, 4, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5],
[4, 5, 4, 3, 4, 4, 4, 3, 3, 4, 5, 4, 3, 5, 4, 4, 3, 4, 3, 5, 4, 5, 3, 3, 4, 5],
[2, 3, 4, 4, 5, 3, 5, 3, 3, 4, 5, 4, 3, 5, 4, 2, 3, 4, 3, 4, 4, 5, 3, 3, 4, 5],
[3, 4, 5, 4, 4, 3, 4, 3, 4, 4, 5, 4, 3, 5, 4, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5],
[4, 5, 4, 3, 4, 4, 4, 3, 3, 4, 5, 4, 3, 5, 4, 4, 3, 4, 3, 5, 4, 5, 3, 3, 4, 5],
[2, 3, 4, 4, 5, 3, 5, 3, 3, 4, 5, 4, 3, 5, 4, 2, 3, 4, 3, 4, 4, 5, 3, 3, 4, 5],
[3, 4, 5, 4, 4, 3, 4, 3, 4, 4, 5, 4, 3, 5, 4, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5],
[4, 5, 4,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权重向量
weight_vector = np.array([
0.03, 0.04, 0.03, 0.03, 0.04, 0.05, 0.04, 0.03, 0.04, 0.05, 0.03, 0.03, 0.04, 0.05, 0.03, 0.04, 0.05, 0.03, 0.03, 0.04, 0.05, 0.03, 0.04, 0.05, 0.04, 0.03
])
# 对决策矩阵进行归一化处理
normalized_matrix = decision_matrix / decision_matrix.max(axis=0)
# 计算加权归一化矩阵
weighted_matrix = normalized_matrix * weight_vector
# 计算加权归一化矩阵的每一行的总和
row_sum = np.sum(weighted_matrix, axis=1)
# 计算正理想解和负理想解
ideal_solution = np.max(weighted_matrix, axis=0)
negative_ideal_solution = np.min(weighted_matrix, axis=0)
# 计算决策矩阵到正理想解和负理想解的距离
distance_to_ideal_solution = np.sqrt(np.sum((weighted_matrix - ideal_solution) ** 2, axis=1))
distance_to_negative_ideal_solution = np.sqrt(np.sum((weighted_matrix - negative_ideal_solution) ** 2, axis=1))
# 计算每个决策方案的综合得分
score = distance_to_negative_ideal_solution / (distance_to_ideal_solution + distance_to_negative_ideal_solution)
# 输出每个决策方案的得分
for i in range(len(score)):
print(f"决策方案{i+1}的得分为:{score[i]}")
```
在上面的代码中,我们定义了一个26x26的决策矩阵,表示26个指标之间的关系。我们还定义了一个权重向量,表示每个指标的重要程度。然后,我们对决策矩阵进行归一化处理,计算加权归一化矩阵,以及每行的总和。接着,我们计算正理想解和负理想解,以及每个决策方案到正理想解和负理想解的距离。最后,我们计算每个决策方案的综合得分,并输出得分结果。
阅读全文