alts <- c("Corsa","Clio","Fiesta","Sandero")
style <- matrix(c(1.0, 1/4, 4.0, 1/6,
4.0, 1.0, 4.0, 1/4,
1/4, 1/4, 1.0, 1/5,
6.0, 4.0, 5.0, 1.0),
nrow=length(alts), ncol=length(alts), byrow=TRUE,
dimnames=list(alts,alts))
reliability <- matrix(c(1.0, 2.0, 5.0, 1.0,
1/2, 1.0, 3.0, 2.0,
1/5, 1/3, 1.0, 1/4,
1.0, 1/2, 4.0, 1.0),
nrow=length(alts), ncol=length(alts), byrow=TRUE,
dimnames=list(alts,alts))
fuel <- matrix(c(1.0, 2.0, 4.0, 1.0,
0.5, 1.0, 3.0, 2.0,
1/4, 1/3, 1.0, 1/5,
1.0, 1/2, 5.0, 1.0),
nrow=length(alts), ncol=length(alts), byrow=TRUE,
dimnames=list(alts,alts))
alternativesPairwiseComparisonsList <- list(style = style,
reliability = reliability,
fuel = fuel)
crit <- c("style","reliability","fuel")
criteriaWeightsPairwiseComparisons <- matrix(c(1.0, 1/2, 3.0,
2.0, 1.0, 4.0,
1/3, 1/4, 1.0),
nrow=length(crit),
ncol=length(crit),
dimnames=list(crit,crit))
# All attributes have pairwise comparisons
AHP(criteriaWeightsPairwiseComparisons, alternativesPairwiseComparisonsList)
# Fuel is a score
newFuel <- c(Corsa=34, Clio=27, Fiest=24, Sandero=28)
newFuel <- newFuel/sum(newFuel)
alternativesPairwiseComparisonsList$fuel <- newFuel
AHP(criteriaWeightsPairwiseComparisons, alternativesPairwiseComparisonsList)
Run the code above in your browser using DataLab