Type: | Package |
Title: | (Fuzzy) AHP Calculation |
Version: | 0.9.5 |
Date: | 2019-12-06 |
URL: | http://github.com/JanCaha/FuzzyAHP/ |
Description: | Calculation of AHP (Analytic Hierarchy Process - http://en.wikipedia.org/wiki/Analytic_hierarchy_process) with classic and fuzzy weights based on Saaty's pairwise comparison method for determination of weights. |
Encoding: | UTF-8 |
Depends: | R (≥ 3.0.0), methods, MASS |
Suggests: | knitr, testthat |
License: | LGPL (≥ 3) |
LazyData: | TRUE |
VignetteBuilder: | knitr |
RoxygenNote: | 7.0.1 |
Collate: | 'class-FuzzyData.R' 'class-PairwiseComparisonMatrix.R' 'class-FuzzyPairwiseComparisonMatrix.R' 'class-FuzzyWeights.R' 'class-Weights.R' 'function-bindFuzzyData.R' 'function-buildFuzzyPairwiseComparisonMatrix.R' 'function-buildPairwiseComparisonMatrix.R' 'function-calculateAHP.R' 'function-calculateWeights.R' 'function-compare.R' 'function-consistencyIndex.R' 'function-consistencyRatio.R' 'function-defuzzify.R' 'function-getFuzzyNumbers.R' 'function-getFuzzyScale.R' 'function-insertInto.R' 'function-internal-optimization.R' 'function-internal-weights.R' 'function-print.R' 'function-strictConsistency.R' 'function-textRepresentation.R' 'function-weakConsistency.R' 'package-FuzzyAHP.R' |
NeedsCompilation: | no |
Packaged: | 2019-12-06 16:19:23 UTC; Cahik |
Author: | Jan Caha [aut, cre] |
Maintainer: | Jan Caha <cahik@atlas.cz> |
Repository: | CRAN |
Date/Publication: | 2019-12-06 16:40:02 UTC |
Package for calculation of classic and Fuzzy AHP
Description
FuzzyAHP is an open source (LGPL 3) package for R. The package is only suitable for AHP that uses categorical rating of criteria for alternatives instead of pairwise comparison of alternatives according to each criteria. This adaptation of AHP is common in situations when the number of alternatives is hight and the pairwise comparison is thus inadequate or impossible to construct. The weights for criteria are, however, still determined from the pairwise comparison matrix. This approach towards AHP is common in Geosciences as well as other fields.
The determination of criteria weights is done according to process described by Krejčí, Pavlačka, and Talašová (2016), which yelds significantly narrower fuzzy numbers than previously used approaches.
Details
Please see vignettes for more details about the package and examples of use.
Complete list of classes and methods call help(package="FuzzyAHP")
.
Author(s)
Jan Caha cahik@atlas.cz, with contributions from Aneta Drážná
References
Krejčí, Jana, Ondřej Pavlačka, and Jana Talašová. 2016. “A fuzzy extension of Analytic Hierarchy Process based on the constrained fuzzy arithmetic.” Fuzzy Optimization and Decision Making. doi:10.1007/s10700-016-9241-0.
Class "FuzzyData"
Description
An S4 class to represent fuzzy data.
Slots
fnMin
A numeric vector of minimal values of fuzzy data.
fnModal
A numeric vector of modal values of fuzzy data.
fnMax
A numeric vector of maximal values of fuzzy data.
Class "FuzzyPairwiseComparisonMatrix"
Description
An S4 class to represent a fuzzy pairwise comparison matrix.
Slots
fnMin
A matrix of minimal values of fuzzy preferences.
fnModal
A matrix of modal values of fuzzy preferences.
fnMax
A matrix of maximal values of fuzzy preferences.
variableNames
Names of variables in the pariwise comparison matrix obtained either as colnames or rownames.
Class "FuzzyWeights"
Description
An S4 class to represent fuzzy weights for fuzzy AHP calculation.
Slots
fnMin
Object of class
numeric
containing minimal values of fuzzy weights.fnModal
Object of class
numeric
containing modal values of fuzzy weights.fnMax
Object of class
numeric
containing maximal values of fuzzy weights.
Class "PairwiseComparisonMatrix"
Description
An S4 class to represent a pairwise comparison matrix.
Slots
valuesChar
A pairwise comparison matrix based on Saaty's method as characters.
values
A pairwise comparison matrix based on Saaty's method as numeric.
variableNames
Names of variables in the pariwise comparison matrix obtained either as colnames or rownames.
Class "Weights"
Description
An S4 class representing weights for AHP calculation. Each value in numeric
vector
represents one weight.
Slots
weights
Object of class
numeric
containing weights.
Function that binds two FuzzyData together into one FuzzyData
Description
This methods construct object FuzzyData
based on two FuzzyData
.
The functions merges the sources into single output. This method should be used in situations when both
weights and input data are fuzzy.
Usage
bindColums(data1, data2)
## S4 method for signature 'FuzzyData,FuzzyData'
bindColums(data1, data2)
Arguments
data1 |
An object of |
data2 |
An object of |
Value
An object of class FuzzyData
Function that builds Fuzzy Pairwise Comparison Matrix based on list of Pairwise Comparison Matrices
Description
This functions builds Fuzzy Pairwise Comparison Matrix based on list of Pairwise Comparison Matrices
the resulting Fuzzy Pairwise Comparison Matrix is calculated as minimum, geometric mean and maximum of
each cell of all Pairwise Comparison Matrices in listOfMatrices
.
Usage
buildFuzzyPairwiseComparisonMatrix(listOfMatrices)
## S4 method for signature 'list'
buildFuzzyPairwiseComparisonMatrix(listOfMatrices)
Arguments
listOfMatrices |
An object of |
Value
An object of class FuzzyPairwiseComparisonMatrix
Function that builds Pairwise Comparison Matrix based on list of Pairwise Comparison Matrices
Description
This functions builds Pairwise Comparison Matrix based on list of Pairwise Comparison Matrices
the resulting Pairwise Comparison Matrix is calculated as geometric mean of all
Pairwise Comparison Matrices in listOfMatrices
.
Usage
buildPairwiseComparisonMatrix(listOfMatrices)
## S4 method for signature 'list'
buildPairwiseComparisonMatrix(listOfMatrices)
Arguments
listOfMatrices |
An object of |
Value
An object of class PairwiseComparisonMatrix
Function to calculate result of AHP
Description
This function calculates output of AHP based on Weights
or FuzzyWeights
on data represented either by matrix
or
FuzzyData
.
Usage
calculateAHP(weights, data)
## S4 method for signature 'Weights,matrix'
calculateAHP(weights, data)
## S4 method for signature 'FuzzyWeights,matrix'
calculateAHP(weights, data)
## S4 method for signature 'FuzzyWeights,FuzzyData'
calculateAHP(weights, data)
## S4 method for signature 'PairwiseComparisonMatrix,matrix'
calculateAHP(weights, data)
## S4 method for signature 'FuzzyPairwiseComparisonMatrix,matrix'
calculateAHP(weights, data)
## S4 method for signature 'FuzzyPairwiseComparisonMatrix,FuzzyData'
calculateAHP(weights, data)
Arguments
weights |
object of class Weights or FuzzyWeights. Alternatively objects of classes PairwiseComparisonMatrix or FuzzyPairwiseComparisonMatrix can be passed to directly calculate weights from these classes. |
data |
matrix or FuzzyData with number of colums equal to number of rows in |
Value
Either a matrix (if Weights and matrix
were used as inputs) or
FuzzyData (if FuzzyWeights were used).
Function to calculate fuzzy weights based on comparison matrix
Description
This functions calculates Weights
or FuzzyWeights
based on input pairwise comparison matrix.
Usage
calculateWeights(comparisonMatrix)
## S4 method for signature 'PairwiseComparisonMatrix'
calculateWeights(comparisonMatrix)
## S4 method for signature 'FuzzyPairwiseComparisonMatrix'
calculateWeights(comparisonMatrix)
Arguments
comparisonMatrix |
object of either PairwiseComparisonMatrix or FuzzyPairwiseComparisonMatrix |
References
KREJČÍ, Jana, PAVLAČKA, Ondřej and TALAŠOVÁ, Jana, 2016, A fuzzy extension of Analytic Hierarchy Process based on the constrained fuzzy arithmetic. Fuzzy Optimization and Decision Making. 2016. DOI 10.1007/s10700-016-9241-0.
See Also
PairwiseComparisonMatrix-class
Function to calculate fuzzy weights based on comparison matrix using older approaches
Description
This functions calculates FuzzyWeights
based on input fuzzy pairwise comparison matrix.
Usage
calculateWeights_old_methods(comparisonMatrix, type = "Chang")
## S4 method for signature 'FuzzyPairwiseComparisonMatrix'
calculateWeights_old_methods(comparisonMatrix, type = "Chang")
Arguments
comparisonMatrix |
object of FuzzyPairwiseComparisonMatrix |
type |
A |
Value
FuzzyWeights
. If fuzzy weighting vector is to be obtained
please see calculate_weighting_vector
function.
References
CHANG, Da-Yong, 1996, Applications of the extent analysis method on fuzzy AHP. European Journal of Operational Research. 1996. Vol. 95, no. 3, p. 649–655. DOI 10.1016/0377-2217(95)00300-2.
TESFAMARIAM, Solomon and SADIQ, Rehan, 2006, Risk-based environmental decision-making using fuzzy analytic hierarchy process (F-AHP). Stochastic Environmental Research and Risk Assessment. 2006. Vol. 21, no. 1, p. 35–50. DOI 10.1007/s00477-006-0042-9.
WANG, Tien-Chin and CHEN, Yueh-Hsiang, 2008, Applying fuzzy linguistic preference relations to the improvement of consistency of fuzzy AHP. Information Sciences [online]. October 2008. Vol. 178, no. 19, p. 3755–3765. DOI 10.1016/j.ins.2008.05.028.
See Also
Function to calculate fuzzy weighting vector
Description
This functions calculates fuzzy weighting vector from FuzzyWeights
.
The calculation was first described by Chang (1996).
Usage
calculate_weighting_vector(fuzzyWeights)
## S4 method for signature 'FuzzyWeights'
calculate_weighting_vector(fuzzyWeights)
Arguments
fuzzyWeights |
object of FuzzyWeights |
Value
weighting vector for defined FuzzyWeights.
References
CHANG, Da-Yong, 1996, Applications of the extent analysis method on fuzzy AHP. European Journal of Operational Research. 1996. Vol. 95, no. 3, p. 649–655. DOI 10.1016/0377-2217(95)00300-2.
Function to mutually compare fuzzy data
Description
This function compares fuzzy data FuzzyData
to identify the optimal (best) cases.
The FuzzyData
can only contain one fuzzy number, otherwise the comparison is not possible.
The calculation of type "possibilityTheory"
can be time consuming as it is based on comparing each fuzzy
number to a maximal fuzzy number obtained from the set of fuzzy numbers.
Usage
compareFuzzyNumbers(fuzzyData, type, progressBar = FALSE)
## S4 method for signature 'FuzzyData,character'
compareFuzzyNumbers(fuzzyData, type, progressBar = FALSE)
Arguments
fuzzyData |
|
type |
A |
progressBar |
logical value indicating if textual progress bar should be printed (default value |
Value
A "matrix"
of numeric value in case of "Chen"
method or
a "matrix"
with two values in case of "possibilityTheory"
.
Function to rank results
Description
This function ranks data from the highest value to the lowest. Essentially it does
(nrow(data)+1) - rank(data, na.last ="keep", ties.method= "max")
.
Usage
compareResults(data)
## S4 method for signature 'matrix'
compareResults(data)
Arguments
data |
A matrix with one column. Usually an output of function |
Value
A "matrix"
of numeric value that indicates ranking of each row, with the highest value ranked as 1.
Function to determine Consistency Index
Description
This methods calculates Consistency index for PairwiseComparisonMatrix
.
Usage
consistencyIndex(comparisonMatrix)
## S4 method for signature 'PairwiseComparisonMatrix'
consistencyIndex(comparisonMatrix)
## S4 method for signature 'FuzzyPairwiseComparisonMatrix'
consistencyIndex(comparisonMatrix)
Arguments
comparisonMatrix |
Value
A numeric value of Consistency index.
Function to determine Consistency Ratio
Description
This methods calculates Consistency Ratio for PairwiseComparisonMatrix
.
The consistency ratio can only be provided for PairwiseComparisonMatrix
with
less than 10 rows. For bigger matrices the value is not known.
Usage
consistencyRatio(comparisonMatrix, print.report = TRUE)
## S4 method for signature 'PairwiseComparisonMatrix'
consistencyRatio(comparisonMatrix, print.report = TRUE)
## S4 method for signature 'FuzzyPairwiseComparisonMatrix'
consistencyRatio(comparisonMatrix, print.report = TRUE)
Arguments
comparisonMatrix |
|
print.report |
Optional boolean parameter stating if short report should be printed along with determination
of Consistency Ratio. Default value is |
Details
Generally pairwise comparison matrixes are considered to be consistent if the value of Consistency Ration
is smaller than 0.1. For matrices comparing more then 10 elements then Consistency Ratio is unsuitable, because the
values of random index, that is necessary to obtain Consistency Ratio, are only known for matrixes with size smaller
than 10\times10
.
Value
A numeric value of Consistency Ratio, for PairwiseComparisonMatrix
with more than 10
an error is raised.
Function to defuzzify fuzzy data
Description
This function defuzzifies FuzzyData
into single value.
The FuzzyData
can only contain one fuzzy number, otherwise the defuzzification is not possible.
Usage
defuzziffy(fuzzyData, type = "mean")
## S4 method for signature 'FuzzyData'
defuzziffy(fuzzyData, type = "mean")
Arguments
fuzzyData |
|
type |
A |
Details
The triangular fuzzy numbers \tilde{A}
represented as triplet [a1,a2,a3]
are defuzzified using these
methods:
"Yager"
:
def (\tilde{A}) = \frac{(a2-a1)(a1+2/3(a2-a1)+(a3-a2)(a2+1/3(a3-a2))}{(a2-a1)+(a3-a2))}
"modalvalue"
:
def (\tilde{A}) = a2
"modalValueDominancy"
:
def(\tilde{A}) = (a1 + 4*a2 + a3)/6
"mean"
:
def(\tilde{A}) = (a1 + a2 + a3)/3
.
Value
A numeric value of defuzzified value, based on deffuzification method.
Function that creates FuzzyData
Description
This methods construct object FuzzyData
based on provided matrix
.
The matrix needs to be have rows represent individual fuzzy numbers and three colums that
represent minimal, modal and maximal value of fuzzy number.
Usage
fuzzyData(data, single.value = TRUE)
## S4 method for signature 'matrix'
fuzzyData(data, single.value = TRUE)
Arguments
data |
A |
single.value |
An optional boolean parameter (default value TRUE) specifying if the data to be turn into fuzzy data is single vector of fuzzy numbers (then it needs to have 3 colums) or if the whole matrix needs to be turn into fuzzy values. |
Value
An object of class FuzzyData
See Also
Function that creates Fuzzy Pairwise Comparions Matrix
Description
This methods construct object FuzzyPairwiseComparisonMatrix based on provided PairwiseComparisonMatrix and an optional fuzzy scale.
Usage
fuzzyPairwiseComparisonMatrix(pairwiseComparisonMatrix, fuzzyScale,
comparsionNotInScale, width)
## S4 method for signature 'PairwiseComparisonMatrix'
fuzzyPairwiseComparisonMatrix(
pairwiseComparisonMatrix,
fuzzyScale = getFuzzyScale(type = "full"),
comparsionNotInScale = FALSE,
width = 1
)
## S4 method for signature 'matrix'
fuzzyPairwiseComparisonMatrix(pairwiseComparisonMatrix)
Arguments
pairwiseComparisonMatrix |
PairwiseComparisonMatrix or |
fuzzyScale |
A numeric vector that definies fuzzy scale. Default scale is described in
details. Default value |
comparsionNotInScale |
A boolean variable. If |
width |
A numeric parameter, specifying the width of calculated fuzzy intensity. If
|
Details
Parameter fuzzyScale is expected as a vector containing n*3 values that represent triangular fuzzy
numbers used as fuzzy intensity of importance (only the values equal or higher than 1, inverse values
are calculated automatically). The values need to be ordered by fuzzy values. Default value of this
parameter is as.double(c(1/2,1,2,1,2,3,2,3,4,3,4,5,4,5,6,5,6,7,6,7,8,7,8,9,8,9,9))
. Another
possibility is eg. as.double(c(1/3,1,3,1,3,5,3,5,7,5,7,9,7,9,9))
If param pairwiseComparisonMatrix
is matrix
then it needs to be of character
type.
Each element in the matrix must be specified as triplet "x;y;z"
, where x<=y<=z
.
From this matrix a pairwise comparison is constructed from y
values and x
and z
function as lower and upper limits of y
respectively. In this case the optional parameter
fuzzyScale
is not taken into account at all.
Value
Object of class FuzzyPairwiseComparisonMatrix
Function that creates Fuzzy Pairwise Comparions Matrix
Description
This methods construct object FuzzyPairwiseComparisonMatrix based on provided PairwiseComparisonMatrix and two matrices that form lower an upper significant values of the PairwiseComparisonMatrix that form middle significant value.
Usage
fuzzyPairwiseComparisonMatrix1(lowerValues, pairwiseComparisonMatrix, upperValues)
## S4 method for signature 'matrix,PairwiseComparisonMatrix,matrix'
fuzzyPairwiseComparisonMatrix1(
lowerValues,
pairwiseComparisonMatrix,
upperValues
)
Arguments
lowerValues |
A matrix of |
pairwiseComparisonMatrix |
PairwiseComparisonMatrix that consists of middle significant values. |
upperValues |
A matrix of |
Details
This function allows user to specify fuzzy pairwise comparison matrix that is not based on fuzzy scale but rely more on user's specification. The middle significant values have to be definied by PairwiseComparisonMatrix to ensure some elementary properties. The significant values provided to this function have to be correctly ordered and fuzzy numbers have to be reciprocal otherwise the function fails.
Value
Object of class FuzzyPairwiseComparisonMatrix
Function to extract specific fuzzy numbers
Description
This methods helps with extracting fuzzy numbers from FuzzyData
and
FuzzyWeights
.
Usage
getFuzzyNumber(object, index)
## S4 method for signature 'FuzzyData,integer'
getFuzzyNumber(object, index)
## S4 method for signature 'FuzzyWeights,integer'
getFuzzyNumber(object, index)
Arguments
object |
An object of class |
index |
An object of class |
Value
A matrix
where rows are fuzzy numbers and columns are important values.
Function to create Fuzzy Scale
Description
This methods creates fuzzy scale that are used while fuzzifying Piecewise comparison matrix.
Full scale is:
1/2 | 1 | 2 |
1 | 2 | 3 |
2 | 3 | 4 |
3 | 4 | 5 |
4 | 5 | 6 |
5 | 6 | 7 |
6 | 7 | 8 |
7 | 8 | 9 |
8 | 9 | 9 |
Basic scale is:
1/3 | 1 | 3 |
1 | 3 | 5 |
3 | 5 | 7 |
5 | 7 | 9 |
7 | 9 | 9 |
Usage
getFuzzyScale(type)
## S4 method for signature 'character'
getFuzzyScale(type)
Arguments
type |
An object of class |
Value
A matrix
representing the fuzzy scale.
Function that inserts FuzzyData on specific column number in another FuzzyData
Description
This methods construct object FuzzyData
based on two FuzzyData
and index.
The functions merges the sources into single output. It inserts data2 onto specific position (defined by index) in
data1.
Usage
insertInto(data1, data2, index)
## S4 method for signature 'FuzzyData,FuzzyData'
insertInto(data1, data2, index)
Arguments
data1 |
An object of |
data2 |
An object of |
index |
An integer specifying the column position on which data2 should be inserted. |
Value
An object of class FuzzyData
Examples
values = (c(1,2,3,4,5,6,7,8,9))
values = matrix(values, nrow = 3, ncol = 3, byrow = TRUE)
fData = fuzzyData(values, single.value = FALSE)
v = (c(15,16,17))
v = matrix(v, nrow = 3, ncol = 1, byrow = TRUE)
fd = fuzzyData(v, single.value = FALSE)
fData = insertInto(fData, fd, 2)
Function that creates Pairwise Comparions Matrix
Description
This methods construct object PairwiseComparisonMatrix
based on provided matrix
.
The matrix needs to be square and reciprocal with the intensity of importance
(comparisons).
Since the version 0.6.9 the comparsions can be represented as either characters (e.g. "1", "9", "1/9")
or numeric (e.g. 1, 9, 1/9) .
Usage
pairwiseComparisonMatrix(matrix)
## S4 method for signature 'matrix'
pairwiseComparisonMatrix(matrix)
Arguments
matrix |
A reciprocal square matrix with ones on the main diagonal. |
Value
An object of class PairwiseComparisonMatrix
See Also
Examples
comparisonMatrixValues = c("1","9","5","1/9","1","1/3","1/5","3","1")
comparisonMatrix = matrix(comparisonMatrixValues, nrow = 3, ncol = 3, byrow = TRUE)
matrix = pairwiseComparisonMatrix(comparisonMatrix)
comparisonMatrixValues = c(1,9,5,1/9,1,1/3,1/5,3,1)
comparisonMatrix = matrix(comparisonMatrixValues, nrow = 3, ncol = 3, byrow = TRUE)
matrix = pairwiseComparisonMatrix(comparisonMatrix)
Function to assess strict consistency of Comparison Matrix
Description
Check if
a_{ik} = a_{ij} \times a_{jk}
applies
for all i,j,k = 1,2,\dots,n
, where n
is size of a
.
Usage
strictConsistency(PairwiseComparisonMatrix, print.report = TRUE)
## S4 method for signature 'FuzzyPairwiseComparisonMatrix'
strictConsistency(PairwiseComparisonMatrix, print.report = TRUE)
## S4 method for signature 'PairwiseComparisonMatrix'
strictConsistency(PairwiseComparisonMatrix, print.report = TRUE)
Arguments
PairwiseComparisonMatrix |
A FuzzyPairwiseComparisonMatrix or PairwiseComparisonMatrix. |
print.report |
Optional boolean parameter stating if short report should be printed along with determination
of Weak Consistency. Default value is |
Value
Boolean value indicating if Comparison Matrix passed the weak consistency test and a warning message listing the problematic triplets if the matrix is not consisten.
Function to create text representation of (Fuzzy) Pairwise comparison matrix
Description
This methods creates text representation of Pairwise comparison matrices.
Usage
textRepresentation(x, whole = TRUE)
## S4 method for signature 'FuzzyPairwiseComparisonMatrix'
textRepresentation(x, whole = TRUE)
## S4 method for signature 'PairwiseComparisonMatrix'
textRepresentation(x, whole = TRUE)
Arguments
x |
An object of class |
whole |
A boolean object specifying if the whole matrix should be created or only its upper half should be filled. |
Value
A dataframe
of character
type.
Function to assess Weak Consistency of Comparison Matrix
Description
Check if for a_{ij}>1,a_{jk}>1
applies that
a_{ik}>=\max(a_{ij},a_{jk})
for all i,j,k = 1,2,\dots,n
, where
n
is size of a
.
Usage
weakConsistency(PairwiseComparisonMatrix, print.report = TRUE)
## S4 method for signature 'FuzzyPairwiseComparisonMatrix'
weakConsistency(PairwiseComparisonMatrix, print.report = TRUE)
## S4 method for signature 'PairwiseComparisonMatrix'
weakConsistency(PairwiseComparisonMatrix, print.report = TRUE)
Arguments
PairwiseComparisonMatrix |
A FuzzyPairwiseComparisonMatrix or PairwiseComparisonMatrix. |
print.report |
Optional boolean parameter stating if short report should be printed along with determination
of Weak Consistency. Default value is |
Value
Boolean value indicating if Comparison Matrix passed the weak consistency test and a warning message listing the problematic triplets if the matrix is not consisten.