A Fuzzy Analytical Hierarchy Process (FAHP) using R

What is Fuzzy Analytical hierarchical process

Table-1

Implementation of fuzzy analytics hierarchy process for selecting a car model based on certain criteria using R.

Figure-2: The hierarchical structure of the car model selection problem
Figure-3: Fuzzy Analytical process flow diagram
Figure-4: weight matrix for criteria
C <- array(NA,dim = c(n,n,3))
C[1,1,] = c(1,1,1)
C[1,2,] = c(8,8,8)
C[1,3,] = c(6,7,8)
C[1,4,] = c(1,2,3)
C <- MatrixFiller(C)
MatrixFiller <- function(A)
{
s2 <- dim(A)
for(i in 2:s2[1])
{
for(j in 1:s2[1])
{
A[i,j,] <- A[1,i,]/A[1,j,]
}
}
return(A)
}
#Enter criteria 
# Enter the number of Criteria
# As in the case of Carexample
# the number of criteria is 4 that are 1. Cost 2. Safety 3. Capacity 4. Style
# n is the number of Criteria
library(psych)
library(ggplot2)
n <- 4
# The criteria weight matrix
C <- array(NA,dim = c(n,n,3))
#Assignment of pair-wise weight for criteria C[1,2,] means prefrence of
#Criteria 1 over Criteria 2
#Calculation of MAtrix
A <- A1
MatrixFiller <- function(A)
{
s2 <- dim(A)
for(i in 2:s2[1])
{
for(j in 1:s2[1])
{
A[i,j,] <- A[1,i,]/A[1,j,]
}
}
return(A)
}
C[1,1,] = c(1,1,1)
C[1,2,] = c(8,8,8)
C[1,3,] = c(6,7,8)
C[1,4,] = c(1,2,3)
C <- MatrixFiller(C)
new.function <- function(P)
{
s <- dim(P)
n <- s[1]
D <- matrix(NA, nrow = n, ncol = 3)
for(i in 1:3)
{
for(j in 1:n)
{
D[j,i] <- geometric.mean(c(P[j,1,i],P[j,2,i],P[j,3,i],P[j,4,i]))
}
}
return(D)
}
#Geometric mean of fuzzy comparison value
D1 <- new.function(C)
Cw <- rowMeans(D1)/sum(rowMeans(D1))
# Calculation for weights for Alternatives
# Entering pair-wise weights for Criteria 1: Cost for Alternatives
# In Car example Alternatives are A1: Accord Sedan, A2: Accord Hybrid
# A3: Pilot, A4: CR-V, A5: Element, A6: Odyssey
# Entering weights w.r.t criteria Cost
N <- 6
A1 <- array(NA,dim = c(N,N,3))
A1[1,1,] = c(1,1,1)
A1[1,2,] = c(2,3,4)
A1[1,3,] = c(5,6,7)
A1[1,4,] = c(1,2,3)
A1[1,5,] = c(3,4,5)
A1[1,6,] = c(6,7,8)
A1 <-MatrixFiller(A1)
D2 <- new.function(A)
A1w <- rowMeans(D2)/sum(rowMeans(D2))
#Entering weights w.r.t Criteria safety
N <- 6
A2 <- array(NA,dim = c(N,N,3))
A2[1,1,] = c(1,1,1)
A2[1,2,] = c(6,7,8)
A2[1,3,] = c(1,2,3)
A2[1,4,] = c(1,2,3)
A2[1,5,] = c(9,9,9)
A2[1,6,] = c(6,7,8)
A2 <- MatrixFiller(A2)
D3 <- new.function(A2)
A2w <- rowMeans(D3)/sum(rowMeans(D3))
#Entering Weights for Criteria w.r.t Capacity
N <- 6
A3 <- array(NA,dim = c(N,N,3))
A3[1,1,] = c(1,1,1)
A3[1,2,] = c(1,2,3)
A3[1,3,] = c(9,9,9)
A3[1,4,] = c(1,2,3)
A3[1,5,] = c(1,2,3)
A3[1,6,] = c(6,7,8)
A3 <- MatrixFiller(A3)
D4 <- new.function(A3)
A3w <- rowMeans(D4)/sum(rowMeans(D4))
#Entering Criteria w.r.t. Style
N <- 6
A4 <- array(NA,dim = c(N,N,3))
A4[1,1,] = c(1,1,1)
A4[1,2,] = c(9,9,9)
A4[1,3,] = c(4,5,6)
A4[1,4,] = c(1,2,3)
A4[1,5,] = c(3,4,5)
A4[1,6,] = c(6,7,8)
A4 <- MatrixFiller(A4)
D5 <- new.function(A4)
A4w <- rowMeans(D5)/sum(rowMeans(D5))
Alt_MAt <- matrix(c(A1w,A2w,A3w,A4w), nrow = N)
Crt_MAT <- matrix(Cw, nrow = 4)
Final_Score <- Alt_MAt %*% Crt_MAT
#create plot
data <- data.frame(CarModel = c("Accord Sedan", "Accord Hybrid","Pilot","CR-V","Element", "Odessey"), score = Final_Score)
ggplot(data, aes(x=CarModel, y= score)) +
geom_bar(stat = "identity")
Figure-5: the final scores calculated by FAHP.
Table-2: Final score calculated

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store