群體決策:2 階決策因子模型

分析碼列表

rm(list=ls()) getWeight <- function(valueList) { m_sum = sum(valueList) ans = valueList / m_sum ans } getLevelWeight <- function(factorValueList) { sumAll = sum(factorValueList) colNum = length(factorValueList[1,]) rowNum = length(factorValueList[,1]) ans = matrix(0, nrow=1, ncol=colNum) for (i in 1:colNum) { colSumOfValue = sum(factorValueList[,i]) ans[i] = colSumOfValue / sumAll } ans } # 參與人決策效力陣列 PowerOfRoleSet = getWeight(c(1, 2, 1, 2)) # 決策方案政策偏好陣列 PreferenceOfSolutionSet = getWeight(c(1, 2, 3, 2)) # 參與人 首階=3 決策因子之重要性值資料矩陣 FactorValue_F1 = matrix(0, nrow=length(PowerOfRoleSet), ncol=3, byrow=TRUE) FactorValue_F1[1,] = c(4, 2, 3) FactorValue_F1[2,] = c(2, 3, 3) FactorValue_F1[3,] = c(3, 4, 3) FactorValue_F1[4,] = c(3, 4, 2) # 第一階決策因子權重 FactorValue_FV1 = getLevelWeight(FactorValue_F1) # 參與人 二階第一項 4 個子決策因子 之重要性值資料矩陣 FactorValue_F21 = matrix(0, nrow=length(PowerOfRoleSet), ncol=4, byrow=TRUE) # 參與人 1 各子決策因子 FactorValue_F21[1,] = c(3, 2, 3, 4) # 參與人 2 各子決策因子 FactorValue_F21[2,] = c(2, 2, 4, 3) # 參與人 3 各子決策因子 FactorValue_F21[3,] = c(1, 3, 2, 2) # 參與人 4 各子決策因子 FactorValue_F21[4,] = c(4, 3, 2, 3) # 第二階決策因子 1 權重 FactorValue_FV21 = getLevelWeight(FactorValue_F21) # 參與人 二階第二項 3 個子決策因子 之重要性值資料矩陣 FactorValue_F22 = matrix(0, nrow=length(PowerOfRoleSet), ncol=3, byrow=TRUE) FactorValue_F22[1,] = c(4, 3, 4) FactorValue_F22[2,] = c(4, 3, 4) FactorValue_F22[3,] = c(3, 3, 4) FactorValue_F22[4,] = c(5, 2, 4) # 第二階決策因子 2 權重 FactorValue_FV22 = getLevelWeight(FactorValue_F22) # 參與人 二階第三項 2 個子決策因子 之重要性值資料矩陣 FactorValue_F23 = matrix(0, nrow=length(PowerOfRoleSet), ncol=2, byrow=TRUE) FactorValue_F23[1,] = c(4, 2) FactorValue_F23[2,] = c(3, 3) FactorValue_F23[3,] = c(4, 2) FactorValue_F23[4,] = c(3, 3) # 第二階決策因子 3 權重 FactorValue_FV23 = getLevelWeight(FactorValue_F23) # 產生 2 階層 x 9 決策因子之 0 矩陣 FactorMatrix = matrix(0, nrow=3, ncol=sum(length(FactorValue_F21[1,]), length(FactorValue_F22[1,]), length(FactorValue_F23[1,])), byrow=TRUE) # 第一階決策因子權重展開 FactorMatrix[1,] = c(rep(FactorValue_FV1[1], each=length(FactorValue_FV21)), rep(FactorValue_FV1[2], each=length(FactorValue_FV22)), rep(FactorValue_FV1[3], each=length(FactorValue_FV23))) # 第二階決策因子權重 FactorMatrix[2,] = c(FactorValue_FV21, FactorValue_FV22, FactorValue_FV23) # 決策因子各階層權重乘積 FactorMatrix[3,] = FactorMatrix[1,] * FactorMatrix[2,] # 參與人決策方案重要性值比序資料矩陣 SolutionMatrix = matrix(0, nrow=length(PreferenceOfSolutionSet), ncol=sum(length(FactorValue_FV21[1,]), length(FactorValue_FV22[1,]), length(FactorValue_FV23[1,])), byrow=TRUE) # 參與人 1 各決策因子下 所有方案比序 SolutionMatrix_1 = SolutionMatrix SolutionMatrix_1[,1] = c(2, 3, 1, 4) SolutionMatrix_1[,2] = c(3, 1, 2, 4) SolutionMatrix_1[,3] = c(3, 2, 1, 4) SolutionMatrix_1[,4] = c(2, 3, 4, 1) SolutionMatrix_1[,5] = c(4, 3, 2, 3) SolutionMatrix_1[,6] = c(2, 4, 1, 3) SolutionMatrix_1[,7] = c(1, 4, 2, 3) SolutionMatrix_1[,8] = c(2, 1, 4, 3) SolutionMatrix_1[,9] = c(4, 4, 1, 2) # 參與人 2 各決策因子下 所有方案比序 SolutionMatrix_2 = SolutionMatrix SolutionMatrix_2[,1] = c(2, 3, 1, 4) SolutionMatrix_2[,2] = c(3, 1, 2, 4) SolutionMatrix_2[,3] = c(3, 2, 1, 4) SolutionMatrix_2[,4] = c(2, 3, 4, 1) SolutionMatrix_2[,5] = c(4, 3, 2, 3) SolutionMatrix_2[,6] = c(2, 4, 1, 3) SolutionMatrix_2[,7] = c(1, 4, 2, 3) SolutionMatrix_2[,8] = c(2, 1, 4, 3) SolutionMatrix_2[,9] = c(4, 4, 1, 2) # 參與人 3 各決策因子下 所有方案比序 SolutionMatrix_3 = SolutionMatrix SolutionMatrix_3[,1] = c(2, 1, 3, 4) SolutionMatrix_3[,2] = c(1, 2, 4, 3) SolutionMatrix_3[,3] = c(4, 1, 3, 2) SolutionMatrix_3[,4] = c(1, 3, 4, 2) SolutionMatrix_3[,5] = c(4, 3, 2, 1) SolutionMatrix_3[,6] = c(2, 4, 1, 3) SolutionMatrix_3[,7] = c(3, 4, 2, 1) SolutionMatrix_3[,8] = c(2, 3, 4, 1) SolutionMatrix_3[,9] = c(1, 3, 4, 2) # 參與人 4 各決策因子下 所有方案比序 SolutionMatrix_4 = SolutionMatrix SolutionMatrix_4[,1] = c(3, 1, 2, 4) SolutionMatrix_4[,2] = c(3, 2, 4, 1) SolutionMatrix_4[,3] = c(2, 1, 3, 4) SolutionMatrix_4[,4] = c(1, 2, 4, 3) SolutionMatrix_4[,5] = c(2, 3, 1, 4) SolutionMatrix_4[,6] = c(2, 4, 1, 3) SolutionMatrix_4[,7] = c(2, 4, 3, 1) SolutionMatrix_4[,8] = c(2, 3, 4, 1) SolutionMatrix_4[,9] = c(3, 2, 4, 1) SolutionMatrix_1[1,2] * FactorMatrix[3,2] # 決策方案 x 決策因子 SolutionMatrix_AllFactor = rbind(SolutionMatrix_1[1,], SolutionMatrix_2[1,], SolutionMatrix_3[1,], SolutionMatrix_4[1,]) # 決策方案 1 SolutionMatrix_F1 = SolutionMatrix_AllFactor[1,] * FactorMatrix[3,] SolutionMatrix_S1 = sum(SolutionMatrix_F1) SolutionMatrix_V1 = SolutionMatrix_S1 * PowerOfRoleSet SolutionMatrix_A1 = prod(SolutionMatrix_V1) ^ (1/length(PowerOfRoleSet)) # 決策方案 2 SolutionMatrix_F2 = SolutionMatrix_AllFactor[2,] * FactorMatrix[3,] SolutionMatrix_S2 = sum(SolutionMatrix_F2) SolutionMatrix_V2 = SolutionMatrix_S2 * PowerOfRoleSet SolutionMatrix_A2 = prod(SolutionMatrix_V2) ^ (1/length(PowerOfRoleSet)) # 決策方案 3 SolutionMatrix_F3 = SolutionMatrix_AllFactor[3,] * FactorMatrix[3,] SolutionMatrix_S3 = sum(SolutionMatrix_F3) SolutionMatrix_V3 = SolutionMatrix_S3 * PowerOfRoleSet SolutionMatrix_A3 = prod(SolutionMatrix_V3) ^ (1/length(PowerOfRoleSet)) # 決策方案 4 SolutionMatrix_F4 = SolutionMatrix_AllFactor[4,] * FactorMatrix[3,] SolutionMatrix_S4 = sum(SolutionMatrix_F4) SolutionMatrix_V4 = SolutionMatrix_S4 * PowerOfRoleSet SolutionMatrix_A4 = prod(SolutionMatrix_V4) ^ (1/length(PowerOfRoleSet)) # 決策方案 幾何平均數 # 決策方案總分數 SolutionMatrix_A = c(SolutionMatrix_A1, SolutionMatrix_A2, SolutionMatrix_A3, SolutionMatrix_A4) * PreferenceOfSolutionSet # 尋找極大值位置 ans = which.max(SolutionMatrix_A) ans