-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
acf55ed
commit 663692f
Showing
19 changed files
with
574 additions
and
299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
Package: MCDM | ||
Title: Multi-Criteria Decision Making Methods | ||
Version: 1.0 | ||
Date: 2015-09-10 | ||
Type: Package | ||
Title: Multi-Criteria Decision Making Methods for Crisp Data | ||
Version: 1.1 | ||
Date: 2016-09-05 | ||
Author: Blanca A. Ceballos Martin <[email protected]> | ||
Maintainer: Blanca A. Ceballos Martin <[email protected]> | ||
Description: An R implementation of Four Multi-Criteria Decision Making (MCDM) Methods: Technique for Order of Preference by Similarity to Ideal Solution (TOPSIS), "VIseKriterijumska Optimizacija I Kompromisno Resenje" (VIKOR), both Multi-Objective Optimization by Ratio Analysis and Full Multiplicative Form (Multi-MOORA) and Weighted Aggregated Sum Product ASsessment (WASPAS). In addition, this package provides a MetaRanking function which combines the output of the previous methods. | ||
Description: Implementation of several MCDM methos for crisp data for decision | ||
making problems. The methods that are implemented in this package are RIM, | ||
TOPSIS (with two normalization procedures), VIKOR, Multi-MOORA and WASPAS. | ||
In addition, MetaRanking function calculates a new ranking from the sum | ||
of the rankings calculated, as well as an aggregated ranking. | ||
Imports: RankAggreg | ||
License: LGPL (>= 3) | ||
URL: http://decsai.ugr.es/index.php?p=miembros&id=19909 | ||
LazyData: true | ||
RoxygenNote: 5.0.1 | ||
NeedsCompilation: no | ||
Packaged: 2015-11-18 16:00:54 UTC; Blanky | ||
Packaged: 2016-09-05 11:31:04 UTC; Modo | ||
Repository: CRAN | ||
Date/Publication: 2015-11-19 11:02:12 | ||
Date/Publication: 2016-09-05 13:53:38 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
b301612e520e87ecf367a63d632b0645 *DESCRIPTION | ||
0f714634d9b6e945d6b30e5d6276b22e *NAMESPACE | ||
a6d7468cec7f23a7d52226beb220a609 *R/MMOORA.R | ||
916b563fb195602c830dd3c55b3f1f7e *R/MetaRanking.R | ||
5b246b44eab588a3641bf7288c90f566 *R/TOPSIS.R | ||
6f0bdad34dcfb7883f3dc08ebdecb72e *R/VIKOR.R | ||
f80bef4b19a66218360122eb29b1f0b0 *R/WASPAS.R | ||
e91d631037e23f00c7fd70739a1278c3 *man/MMOORA.Rd | ||
c3d685827adbeb13256720e443d2687a *man/MetaRanking.Rd | ||
a263ae3ec5866104e5736868d3ebbd8e *man/TOPSIS.Rd | ||
73dae3c80f82ad4dd9119924e75ce00d *man/VIKOR.Rd | ||
244851b5223807a97aaceba704f70a8e *man/WASPAS.Rd | ||
9120b7e76ff718096df3feea7dce908d *vignettes/MCDM.pdf | ||
69910b71bb5bd011e994234c8b59b0c1 *DESCRIPTION | ||
9b7c4e38c891101fd4549788a687c7de *NAMESPACE | ||
8287ca47154ab5e73e30274a16880212 *R/MMOORA.R | ||
5b035e73afcd7f7bae9d167620a5a93b *R/MetaRanking.R | ||
76fbfe56c0a7f78ed63313786b5cff85 *R/RIM.R | ||
00ac3bdfc38bc0f08b8c3c52233e6555 *R/TOPSISLinear.R | ||
4688cfc2894c6138351b9d12525d697d *R/TOPSISVector.R | ||
8d25956de81910c4f10a7d01606915a3 *R/TheoryOfDominance.R | ||
36138b0987e910975df5fd5e956556a2 *R/VIKOR.R | ||
b5f8ffd3b9c728bd73b802be03486e88 *R/WASPAS.R | ||
6803bdbf53ad9f3fd94ebe327a580fb6 *man/MMOORA.Rd | ||
7e39cee422906ca0e238c31f6aaa3d15 *man/MetaRanking.Rd | ||
cbd050e6512a7d2e1db0dfb7c996371d *man/RIM.Rd | ||
2cb23006a72a752f685f0e05cd52e4f7 *man/TOPSISLinear.Rd | ||
f757fbf818251edabcb38bdf2d81879f *man/TOPSISVector.Rd | ||
33a7b42ebabfc5a90616c496db7639c4 *man/VIKOR.Rd | ||
3369c5e7b9317128957225d4a03fd52b *man/WASPAS.Rd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
exportPattern("^[[:alpha:]]+") | ||
|
||
import(RankAggreg) | ||
export(MetaRanking, MMOORA, RIM, TOPSISVector, TOPSISLinear, VIKOR, WASPAS) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,64 @@ | ||
#' Implementation of MetaRanking function for Multi-Criteria Decision Making Problems. | ||
#' | ||
#' @description The \code{MetaRanking} function internally calls functions \code{MMOORA}, \code{TOPSIS}, \code{VIKOR} and \code{WASPAS} and then calculates a sum of the their rankings. | ||
#' @param decision The decision matrix (\emph{m} x \emph{n}) with the values of the \emph{m} alternatives, for the \emph{n} criteria. | ||
#' @param weights A vector of length \emph{n}, containing the weights for the criteria. The sum of the weights has to be 1. | ||
#' @param cb A vector of length \emph{n}. Each component is either \code{cb(i)='max'} if the \emph{i-th} criterion is benefit or \code{cb(i)='min'} if the \emph{i-th} criterion is a cost. | ||
#' @param lambda A value in [0,1]. It is used in the calculation of the W index for WASPAS method. | ||
#' @param v A value in [0,1]. It is used in the calculation of the Q index for VIKOR method. | ||
#' @return \code{MetaRanking} returns a data frame which contains the rankings of the Multi-MOORA, TOPSIS, VIKOR, WASPAS Methods and the MetaRanking of the alternatives. | ||
#' @examples | ||
#' | ||
#' d <- matrix(rpois(12, 5), nrow = 4) | ||
#' w <- c(0.2, 0.2, 0.6) | ||
#' cb <- c('max','min','max') | ||
#' lambda <- 0.5 | ||
#' v <- 0.5 | ||
#' MetaRanking(d,w,cb,lambda,v) | ||
|
||
MetaRanking <- function(decision, #matrix with all the alternatives | ||
weights, #vector with the numeric values of the weights | ||
cb, #vector with the "type" of the criteria (benefit = "max", cost = "min") | ||
lambda, #value with the real number of the 'lambda' parameter to calculate W | ||
v #value with the real number of the 'v' parameter to calculate Q | ||
) | ||
{ | ||
#Checking the arguments | ||
if(! is.matrix(decision)) | ||
stop("'decision' must be a matrix with the values of the alternatives") | ||
if(missing(weights)) | ||
stop("a vector containing n weigths, adding up to 1, should be provided") | ||
if(sum(weights) != 1) | ||
stop("The sum of 'weights' is not equal to 1") | ||
if(! is.character(cb)) | ||
stop("'cb' must be a character vector with the type of the criteria") | ||
if(! all(cb == "max" | cb == "min")) | ||
stop("'cb' should contain only 'max' or 'min'") | ||
if(length(weights) != ncol(decision)) | ||
stop("length of 'weights' does not match the number of the criteria") | ||
if(length(cb) != ncol(decision)) | ||
stop("length of 'cb' does not match the number of the criteria") | ||
if(missing(lambda)) | ||
stop("a value for 'lambda' in [0,1] should be provided") | ||
if(missing(v)) | ||
stop("a value for 'v' in [0,1] should be provided") | ||
|
||
|
||
#Multi-MOORA method | ||
MMoora = MMOORA(decision,weights,cb) | ||
|
||
#TOPSIS method | ||
Topsis = TOPSIS(decision,weights,cb) | ||
|
||
#VIKOR method | ||
Vikor = VIKOR(decision,weights,cb,v) | ||
|
||
#WASPAS method | ||
Waspas = WASPAS(decision,weights,cb,lambda) | ||
|
||
#Meta-Ranking | ||
MetaR = MMoora[,8]+Topsis[,3]+Vikor[,5]+Waspas[,3] | ||
return(data.frame(Alternatives = 1:nrow(decision), MMOORA = MMoora[,8], TOPSIS = Topsis[,3], VIKOR = Vikor[,5], WASPAS = Waspas[,3], METARANKING = rank(MetaR, ties.method= "random"))) | ||
|
||
} | ||
#' Implementation of MetaRanking function for Multi-Criteria Decision Making Problems. | ||
#' | ||
#' @description The \code{MetaRanking} function internally calls functions \code{MMOORA}, \code{RIM}, \code{TOPSISLinear}, \code{TOPSISVector}, \code{VIKOR} and \code{WASPAS} and then calculates a sum of the their rankings and an aggregated ranking by applying the \code{RankAggreg} package. | ||
#' @param decision The decision matrix (\emph{m} x \emph{n}) with the values of the \emph{m} alternatives, for the \emph{n} criteria. | ||
#' @param weights A vector of length \emph{n}, containing the weights for the criteria. The sum of the weights has to be 1. | ||
#' @param cb A vector of length \emph{n}. Each component is either \code{cb(i)='max'} if the \emph{i-th} criterion is benefit or \code{cb(i)='min'} if the \emph{i-th} criterion is a cost. | ||
#' @param lambda A value in [0,1]. It is used in the calculation of the W index for WASPAS method. | ||
#' @param v A value in [0,1]. It is used in the calculation of the Q index for VIKOR method. | ||
#' @param AB A matrix (\emph{2} x \emph{n}). AB[1,] corresponds with the A extrem, and AB[2,] represents the B extrem of the domain of each criterion. | ||
#' @param CD A matrix (\emph{2} x \emph{n}). CD[1,] corresponds with the C extrem, and CD[2,] represents the D extrem of the ideal reference of each criterion. | ||
#' @return \code{MetaRanking} returns a data frame which contains the rankings of the Multi-MOORA, RIM, TOPSISLinear, TOPSISVector, VIKOR, WASPAS Methods and the both MetaRankings of the alternatives. | ||
#' @examples | ||
#' | ||
#' d <- matrix(c(1,2,5,3000,3750,4500),nrow = 3,ncol = 2) | ||
#' w <- c(0.5,0.5) | ||
#' cb <- c('min','max') | ||
#' lambda <- 0.5 | ||
#' v <- 0.5 | ||
#' AB <- matrix(c(1,5,3000,4500),nrow = 2,ncol=2) | ||
#' CD <- matrix(c(1,1,4500,4500),nrow = 2,ncol=2) | ||
#' MetaRanking(d,w,cb,lambda,v,AB,CD) | ||
|
||
MetaRanking <- function(decision, #matrix with all the alternatives | ||
weights, #vector with the numeric values of the weights | ||
cb, #vector with the "type" of the criteria (benefit = "max", cost = "min") | ||
lambda, #value with the real number of the 'lambda' parameter to calculate W | ||
v, #value with the real number of the 'v' parameter to calculate Q | ||
AB, #matrix with the range [A,B] of the universe of discourse | ||
CD #matrix with the Reference Ideal [C,D] | ||
) | ||
{ | ||
|
||
#Multi-MOORA method | ||
MMoora = MMOORA(decision,weights,cb) | ||
|
||
#RIM | ||
Rim = RIM(decision, weights, AB, CD) | ||
|
||
#TOPSIS method | ||
TopsisV = TOPSISVector(decision,weights,cb) | ||
TopsisL = TOPSISLinear(decision,weights,cb) | ||
|
||
#VIKOR method | ||
Vikor = VIKOR(decision,weights,cb,v) | ||
|
||
#WASPAS method | ||
Waspas = WASPAS(decision,weights,cb,lambda) | ||
|
||
#Meta-Ranking | ||
MetaR = MMoora[,8]+Rim[,3]+TopsisV[,3]+TopsisL[,3]+Vikor[,5]+Waspas[,5] | ||
|
||
#Ranking Aggregated | ||
#library(RankAggreg) | ||
ra = rbind(MMoora[,8],Rim[,3],TopsisV[,3],TopsisL[,3],Vikor[,5],Waspas[,5]) | ||
if(nrow(decision)<=10) | ||
RA = RankAggreg::BruteAggreg(ra, nrow(decision), distance="Spearman") | ||
else | ||
RA = RankAggreg::RankAggreg(ra, nrow(decision), method = "GA", distance = "Spearman", verbose=FALSE) | ||
|
||
return(data.frame(Alternatives = 1:nrow(decision), MMOORA = MMoora[,8], RIM = Rim[,3], TOPSISVector = TopsisV[,3], | ||
TOPSISLinear = TopsisL[,3], VIKOR = Vikor[,5], WASPAS = Waspas[,5], | ||
MetaRanking_Sum = rank(MetaR, ties.method= "first"), MetaRanking_Aggreg = RA$top.list)) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#' Implementation of RIM Method for Multi-Criteria Decision Making Problems. | ||
#' | ||
#' @description The \code{RIM} function implements the Reference Ideal Method (RIM). | ||
#' @param decision The decision matrix (\emph{m} x \emph{n}) with the values of the \emph{m} alternatives, for the \emph{n} criteria. | ||
#' @param weights A vector of length \emph{n}, containing the weights for the criteria. The sum of the weights has to be 1. | ||
#' @param AB A matrix (\emph{2} x \emph{n}). AB[1,] corresponds with the A extrem, and AB[2,] represents the B extrem of the domain of each criterion. | ||
#' @param CD A matrix (\emph{2} x \emph{n}). CD[1,] corresponds with the C extrem, and CD[2,] represents the D extrem of the ideal reference of each criterion. | ||
#' @return \code{RIM} returns a data frame which contains the score of the R index and the ranking of the alternatives. | ||
#' @references Cables, E.; Lamata, M.T.; Verdegay, J.L. RIM-reference ideal method in multicriteria decision making. Information Science, 337-338, 1-10, 2016. | ||
#' @examples | ||
#' | ||
#' d <- matrix(c(30,40,25,27,45,0,9,0,0,15,2,1,3,5,2,3,3,1,3,2,3,2,3,3,3,2,2,2,1,4), | ||
#' nrow = 5, ncol = 6) | ||
#' w <- c(0.2262,0.2143,0.1786,0.1429,0.119,0.119) | ||
#' AB = matrix(c(23,60,0,15,0,10,1,3,1,3,1,5),nrow = 2,ncol = 6) | ||
#' CD = matrix(c(30,35,10,15,0,0,3,3,3,3,4,5),nrow = 2,ncol = 6) | ||
#' RIM(d,w,AB,CD) | ||
|
||
RIM <- function(decision, #matrix with all the alternatives | ||
weights, #vector with the numeric values of the weights | ||
AB, #matrix with the range [A,B] of the universe of discourse | ||
CD #matrix with the Reference Ideal [C,D] | ||
) | ||
{ | ||
#Checking the arguments | ||
if(! is.matrix(decision)) | ||
stop("'decision' must be a matrix with the values of the alternatives") | ||
if(missing(weights)) | ||
stop("a vector containing n weigths, adding up to 1, should be provided") | ||
if(sum(weights) != 1) | ||
stop("The sum of 'weights' is not equal to 1") | ||
if(length(weights) != ncol(decision)) | ||
stop("length of 'weights' does not match the number of the criteria") | ||
if(ncol(AB) != ncol(decision)) | ||
stop("length of 'AB' does not match the number of the criteria") | ||
if(ncol(CD) != ncol(decision)) | ||
stop("length of 'CD' does not match the number of the criteria") | ||
|
||
|
||
#1. Normalization and weighting | ||
N <- matrix(nrow = nrow(decision), ncol = ncol(decision)) | ||
for(j in 1:ncol(decision)){ | ||
for(i in 1:nrow(decision)){ | ||
if((decision[i,j] >= CD[1,j]) && (decision[i,j]<= CD[2,j])){ | ||
N[i,j]=1 | ||
} | ||
else if( ((decision[i,j]>= AB[1,j]) && (decision[i,j]<= CD[1,j])) && (AB[1,j]!=CD[1,j])){ | ||
N[i,j]=1-(min(abs(decision[i,j]-CD[1,j]),abs(decision[i,j]-CD[2,j]))/abs(AB[1,j]-CD[1,j])) | ||
} | ||
else if( ((decision[i,j]>= CD[2,j]) && (decision[i,j]<= AB[2,j])) && (CD[2,j]!=AB[2,j])){ | ||
N[i,j]=1-(min(abs(decision[i,j]-CD[1,j]),abs(decision[i,j]-CD[2,j]))/abs(CD[2,j]-AB[2,j])) | ||
} | ||
else stop("error in normalization procedure: A != B and D != C") | ||
} | ||
} | ||
|
||
|
||
W <- diag(weights) | ||
NW <- N%*%W | ||
|
||
#2. Distances to the ideal solutions | ||
posDis = c(1:nrow(decision)) | ||
negDis = c(1:nrow(decision)) | ||
for(i in 1:nrow(decision)){ | ||
posDis[i] = sqrt(sum((NW[i,]-weights)^2)) | ||
negDis[i] = sqrt(sum(NW[i,]^2)) | ||
} | ||
|
||
|
||
#4. R index | ||
R <- negDis/(negDis+posDis) | ||
|
||
#5. Rank the alternatives | ||
return(data.frame(Alternatives = 1:nrow(decision), R = R, Ranking = rank(-R, ties.method= "first"))) | ||
|
||
} |
Oops, something went wrong.