模糊层次分析法(FAHP)Python实现

文章目录

  • 理论基础
    • 三角模糊数概念
    • 参考
  • Python源码
  • 测试

理论基础

\quad 模糊层次分析法( F A H P FAHP FAHP)将模糊理论( F u z z y S e t Fuzzy Set FuzzySet)嵌入到基本层次分析法( A H P AHP AHP)中。 A H P AHP AHP是一种广泛应用于各种多准则决策问题的决策工具,它将不同的备选方案与不同的标准进行成对比较,并为多标准决策问题提供了决策支持工具。在一般的AHP模型中,目标在第一层,标准和子标准分别在第二层和第三层,第四个层次为备选方案。由于基本AHP不包括个人判断的模糊性,它通过受益于模糊逻辑方法得到了改进。在FAHP中,通过语言变量对标准和备选方案进行成对比较,语言变量由三角模糊数等表示。

三角模糊数概念

\quad 定义:三角模糊数 A ~ = ( a l , a m , a u ) \tilde{A}=(a_l,a_m,a_u) A~=(al,am,au) a l 、 a m 和 a u a_l、a_m和a_u alamau分别为下届、中值和上届,其隶属函数表示如下:
μ A ~ = { x − a l a m − a l , a l ≤ x ≤ a m a − a u a m − a u , a m ≤ x ≤ a u 0 , 其他 \mu_{\tilde{A}}=\begin{cases} \frac{x-a_l}{a_m-a_l},a_l\le x\le a_m\\ \frac{a-a_u}{a_m-a_u},a_m\le x\le a_u\\ 0,其他\\ \end{cases} μA~= amalxal,alxamamauaau,amxau0,其他

\quad 运算方法: M 1 = ( l 1 , m 1 , u 1 ) M_1=\left(l_1,m_1,u_1\right) M1=(l1,m1,u1) M 2 = ( l 2 , m 2 , u 2 ) M_2=\left(l_2,m_2,u_2\right) M2=(l2,m2,u2)
{ M 1 ⨁   M 2 = ( l 1 + l 1 , m 1 + m 2 , u 1 + u 2 ) M 1 ⨂   M 2 ≈ ( l 1 l 2 , m 1 m 2 , u 1 u 2 ) 1 M 1 ≈ ( 1 u , 1 m , 1 l ) \begin{cases} M_1 \bigoplus \ M_2 = \left(l_1 + l_1, m_1 + m_2, u_1 + u_2\right) \\ M_1 \bigotimes \ M_2 \approx \left(l_1 l_2, m_1 m_2, u_1 u_2\right) \\ \frac{1}{M_1} \approx \left(\frac{1}{u},\frac{1}{m}, \frac{1}{l}\right) \\ \end{cases} M1 M2=(l1+l1,m1+m2,u1+u2)M1 M2(l1l2,m1m2,u1u2)M11(u1,m1,l1)

表1.语言术语及其对应的三角模糊数
Saaty等级 定义 三角模糊数
1 同等重要(EI) (1,1,1)
3 稍微重要(WI) (2,3,4)
5 相当重要(FI) (4,5,6)
7 非常重要(SI) (6,7,8)
9 绝对重要(AI) (9,9,9)
2
4
6
8
两个相邻刻度之间的间歇值 (1,2,3)
(3,4,5)
(5,6,7)
(7,8,9)

\quad 如果C1比C2弱重要,则 C 1 → C 2 C1\rightarrow C2 C1C2取三角模糊数 ( 2 , 3 , 4 ) (2,3,4) (2,3,4), C 1 ← C 2 C1\leftarrow C2 C1C2取三角模糊数 ( 1 4 , 1 3 , 1 2 ) (\frac{1}{4},\frac{1}{3},\frac{1}{2}) (41,31,21)

S1. 建立三角模糊成对比较矩阵

\quad 第k个专家评价结果为:
A ~ k = [ d ~ 11 k d ~ 12 k … d ~ 1 n k d ~ 21 k d ~ 22 k … d ~ 2 n k ⋮ ⋮ ⋱ ⋮ d ~ n 1 k d ~ n 2 k … d ~ n n k ] (1) \tilde{A}^{k}= \begin{bmatrix} \tilde{d}_{11}^{k} & \tilde{d}_{12}^{k} & \ldots & \tilde{d}_{1n}^{k} \\ \tilde{d}_{21}^{k} & \tilde{d}_{22}^{k} & \ldots & \tilde{d}_{2n}^{k} \\ \vdots & \vdots & \ddots & \vdots \\ \tilde{d}_{n1}^{k} & \tilde{d}_{n2}^{k} & \ldots & \tilde{d}_{nn}^{k} \\ \end{bmatrix} \tag{1} A~k= d~11kd~21kd~n1kd~12kd~22kd~n2kd~1nkd~2nkd~nnk (1)

S2. 当存在多个决策者时,计算每个决策者的偏好( d i j k ~ \tilde{d_{ij}^{k}} dijk~)的平均值, d i j k ~ \tilde{d_{ij}^{k}} dijk~的计算表达式如下:
d i j k ~ = ∑ k = 1 K d ~ i j k K (2) \tilde{d_{ij}^{k}}=\frac{\sum_{k=1}^{K}\tilde{d}_{ij}^{k}}{K}\tag{2} dijk~=Kk=1Kd~ijk(2)

S3. 根据平均偏好,更新成对比较矩阵
A ~ = [ d 11 ~ d 12 ~ … d 1 n ~ d 21 ~ d 22 ~ … d 2 n ~ ⋮ ⋮ ⋱ ⋮ d n 1 ~ d n 2 ~ … d n n ~ ] (3) \tilde{A}= \begin{bmatrix} \tilde{d_{11}} & \tilde{d_{12}} & \ldots & \tilde{d_{1n}} \\ \tilde{d_{21}} & \tilde{d_{22}} & \ldots & \tilde{d_{2n}} \\ \vdots & \vdots & \ddots & \vdots \\ \tilde{d_{n1}} & \tilde{d_{n2}} & \ldots & \tilde{d_{nn}} \\ \end{bmatrix} \tag{3} A~= d11~d21~dn1~d12~d22~dn2~d1n~d2n~dnn~ (3)

S4. 根据Buckley,计算每个标准的模糊比较值的几何平均值 r i ~ \tilde{r_{i}} ri~(三角数)
r i ~ = ( ∏ j = 1 n d ~ i j ) 1 n , i = 1 , 2 , … , n (4) \tilde{r_{i}}={\left(\prod_{j=1}^{n}\tilde{d}_{ij}\right)}^{\frac{1}{n}},i=1,2,\ldots,n \tag{4} ri~=(j=1nd~ij)n1,i=1,2,,n(4)

S5. 计算每个标准的模糊权重:求每个 r i ~ \tilde{r_{i}} ri~的矢量和;求和向量的 − 1 -1 1次方,替换模糊三角数,使其按递增顺序排列;计算 r i ~ \tilde{r_{i}} ri~和它的逆向量的乘积
w ~ i = r i ~ ⨂ ( r 1 ~ ⨁ r 2 ~ ⨁ … ⨁ r n ~ ) − 1 = ( l w i , m w i , u w i ) (5) \tilde{w}_{i} = \tilde{r_{i}}\bigotimes {\left(\tilde{r_{1}} \bigoplus \tilde{r_{2}} \bigoplus \ldots \bigoplus \tilde{r_{n}}\right)}^{-1}=\left(lw_i,mw_i,uw_i\right) \tag{5} w~i=ri~(r1~r2~rn~)1=(lwi,mwi,uwi)(5)

S6.反模糊化计算
w i = l w i + m w i + u w i 3 (6) w_i = \frac{lw_i + mw_i + uw_i}{3} \tag{6} wi=3lwi+mwi+uwi(6)

S7. 归一化处理
n w i = w i ∑ n = 1 n w i (7) nw_i = \frac{w_i}{\sum_{n=1}^n w_i} \tag{7} nwi=n=1nwiwi(7)

\quad 然后,通过将每个备选权重与相关标准相乘,计算每个备选的分数。根据这些结果,向决策者建议得分最高的备选方案。

参考

  1. Cheng, C.H. (1997). Evaluating Naval Tactical Missile System by Fuzzy AHP Based on the Grade Value of Membership Function. European Journal of Operational Research,96(2),343-350.
  2. Cheng, C.H., Yang, L.L., and Hwang, C.L. (1999). Evaluating Attack Helicopter by AHP Based on Linguistic Variable Weight. European Journal of Operational Research,116(2),423-435.
  3. Ruoning, X. and Xiaoyan, Z. (1992). Extensions of the Analytic Hierarchy Process in Fuzzy Environment. Fuzzy Sets and System,52(3),251-257.
  4. Petkovic, J., Sevarac, Z., Jaksic, M.L., Marinkovic, S. (2012). Application of fuzzy AHP method for choosing a technology within service company. Technics Technologies Education Management,7(1),332-341.
  5. Kilic, H.S. (2011). A fuzzy AHP based performance assessment system for the strategic plan of Turkish Municipalities. International Journal of Business and Management Studies, 3(2),77-86.
  6. Kilincci, O., & Onal, S. A. (2011). Fuzzy AHP approach for supplier selection in a washing machine company. Expert Systems with Applications, 38(8),9656-9664.
  7. Ayhan, M.B.(2013). A Fuzzy AHP Approach for Supplier Selection Problem: A Case Study in A Gearmotor Company. International Journal of Managing Value and Supply Chains (IJMVSC),4(3).

Python源码

import numpy as np

# Function: Fuzzy AHP
def fuzzy_ahp_method(dataset):
    '''
    dataset: 专家判断矩阵,n*n*3,n表示指标数
    '''
    row_sum = []
    s_row   = []
    f_w     = []  #模糊权重
    d_w     = []  #去模糊权重
    # 一致性检测指标
    inc_rat  = np.array([0, 0, 0, 0.58, 0.9, 1.12, 1.24, 1.32, 1.41, 1.45, 1.49, 1.51, 1.48, 1.56, 1.57, 1.59])
    # 模糊判断矩阵转为清晰判断矩阵
    X       = [(item[0] + 4*item[1] + item[2])/6 for i in range(0, len(dataset)) for item in dataset[i]]  #三角数转为模糊数
    X       = np.asarray(X)  #列表转数组
    X       = np.reshape(X, (len(dataset), len(dataset)))  #转为n*n矩阵
    
    # S4. 计算每个准则的模糊比较值的几何平均值r_i(公式4)
    for i in range(0, len(dataset)):
        a, b, c = 1, 1, 1
        for j in range(0, len(dataset[i])):
            d, e, f = dataset[i][j]
            # 计算公式(4)的括号内部分: r_s = \prod_{j=1}^n d_ij
            a, b, c = a*d, b*e, c*f
        row_sum.append( (a, b, c) )
    L, M, U = 0, 0, 0
    for i in range(0, len(row_sum)):
        a, b, c = row_sum[i]
        # 计算公式(4)的括号外部分: s_r = (r_s)^(1/n)
        a, b, c = a**(1/len(dataset)), b**(1/len(dataset)), c**(1/len(dataset))
        s_row.append( ( a, b, c ) )
        # 计算公式(5)中⨁运算部分:R5 = r1⨁r2⨁...⨁rn
        L = L + a
        M = M + b
        U = U + c

    for i in range(0, len(s_row)):
        a, b, c = s_row[i]
        # 计算公式公式(5)中⨂运算部分:wi = ri⨂R5
        a, b, c = a*(U**-1), b*(M**-1), c*(L**-1)
        # 模糊权重
        f_w.append( ( a, b, c ) )
        # 计算公式(6):去模糊权重
        d_w.append( (a + b + c)/3 )
    # 计算公式(7): 归一化权重
    n_w      = [item/sum(d_w) for item in d_w]
    # 计算特征根向量
    vector   = np.sum(X*n_w, axis = 1)/n_w
    # 获得平均特征根
    lamb_max = np.mean(vector)
    # 计算一致性指标
    cons_ind = (lamb_max - X.shape[1])/(X.shape[1] - 1)
    # 一致性判断
    rc       = cons_ind/inc_rat[X.shape[1]]
    return f_w, d_w, n_w, rc

测试

dataset = list([
    [ (  1,   1,   1), (  4,   5,   6), (  3,   4,   5), (  6,   7,   8) ],   #g1
    [ (1/6, 1/5, 1/4), (  1,   1,   1), (1/3, 1/2, 1/1), (  2,   3,   4) ],   #g2
    [ (1/5, 1/4, 1/3), (  1,   2,   3), (  1,   1,   1), (  2,   3,   4) ],   #g3
    [ (1/8, 1/7, 1/6), (1/4, 1/3, 1/2), (1/4, 1/3, 1/2), (  1,   1,   1) ]    #g4
    ])
fuzzy_weights, defuzzified_weights, normalized_weights, rc = fuzzy_ahp_method(dataset)
print('模糊权重')
for i in range(0, len(fuzzy_weights)):
    print('g'+str(i+1)+': ', np.around(fuzzy_weights[i], 3))
print('清晰权重')
for i in range(0, len(defuzzified_weights)):
    print('g'+str(i+1)+': ', round(defuzzified_weights[i], 3))
print('归一化权重')
for i in range(0, len(normalized_weights)):
    print('g'+str(i+1)+': ', round(normalized_weights[i], 3))
    
print('一致性判断')
print('RC: ' + str(round(rc, 2)))
if (rc > 0.10):
    print('The solution is inconsistent, the pairwise comparisons must be reviewed')
else:
    print('The solution is consistent')

输出结果为:

模糊权重
g1:  [0.428 0.61  0.859]
g2:  [0.085 0.131 0.218]
g3:  [0.117 0.196 0.309]
g4:  [0.044 0.063 0.099]
清晰权重
g1:  0.632
g2:  0.145
g3:  0.207
g4:  0.068
归一化权重
g1:  0.601
g2:  0.138
g3:  0.197
g4:  0.065
一致性判断
RC: 0.06
The solution is consistent

你可能感兴趣的:(多属性决策算法,模糊理论,FAHP,多属性决策,python)