ELECTRE Ⅲ方法步骤及python实现
时间: 2023-07-29 16:10:41 浏览: 149
ELECTRE III 是一种决策支持系统方法,用于多标准决策分析。其步骤如下:
1. 确定决策问题的准则和级别
2. 确定评价对象和其在每个准则上的得分
3. 计算每个评价对象之间的差异度,包括正和负差异度
4. 根据差异度和权重计算对象之间的相对偏好度
5. 根据相对偏好度进行排名
以下是 Python 实现 ELECTRE III 方法的示例代码:
```python
import numpy as np
# 输入数据
criteria = ['Price', 'Performance', 'Reliability', 'Safety']
weights = np.array([0.3, 0.2, 0.25, 0.25])
alternatives = np.array([
[20000, 8, 9, 4],
[25000, 9, 9, 5],
[18000, 7, 8, 3],
[22000, 8, 7, 5],
[19000, 7, 9, 4]
])
# 步骤 1:确定准则和级别
n_criteria = len(criteria)
n_levels = 5
# 步骤 2:计算准则得分矩阵
criteria_scores = np.zeros((n_criteria, n_levels))
for i in range(n_criteria):
# 根据准则 i 对所有备选对象进行排序
sorted_indices = np.argsort(alternatives[:, i])
# 将排序后的对象分成 n_levels 个组,并计算每组的得分
group_size = len(alternatives) // n_levels
for j in range(n_levels):
group_indices = sorted_indices[j*group_size:(j+1)*group_size]
criteria_scores[i, j] = np.mean(alternatives[group_indices, i])
# 步骤 3:计算差异度矩阵
positive_differences = np.zeros((len(alternatives), len(alternatives), n_criteria))
negative_differences = np.zeros((len(alternatives), len(alternatives), n_criteria))
for i in range(len(alternatives)):
for j in range(len(alternatives)):
if i == j:
continue
for k in range(n_criteria):
if alternatives[i, k] >= alternatives[j, k]:
positive_differences[i, j, k] = criteria_scores[k, alternatives[i, k]-1] - criteria_scores[k, alternatives[j, k]-1]
else:
negative_differences[i, j, k] = criteria_scores[k, alternatives[j, k]-1] - criteria_scores[k, alternatives[i, k]-1]
# 步骤 4:计算相对偏好度矩阵
positive_flows = np.zeros((len(alternatives), len(alternatives)))
negative_flows = np.zeros((len(alternatives), len(alternatives)))
for i in range(len(alternatives)):
for j in range(len(alternatives)):
if i == j:
continue
positive_flows[i, j] = np.sum(weights * (positive_differences[i, j, :] >= 0) * positive_differences[i, j, :])
negative_flows[i, j] = np.sum(weights * (negative_differences[i, j, :] >= 0) * negative_differences[i, j, :])
# 步骤 5:计算排名
net_flows = np.sum(positive_flows - negative_flows, axis=1)
rankings = np.argsort(net_flows)[::-1]
# 输出结果
for i, rank in enumerate(rankings):
print(f"{i+1}. Alternative {rank+1} (net flow: {net_flows[rank]:.2f})")
```
输出结果将显示按照相对偏好度排名的备选对象列表。
阅读全文