pyrepo_mcda.mcda_methods.ahp

Classes

AHP

Module Contents

class pyrepo_mcda.mcda_methods.ahp.AHP(normalization_method=minmax_normalization)

Bases: pyrepo_mcda.mcda_methods.mcda_method.MCDA_method

normalization_method
__call__(matrix, weights, types)

Score alternatives provided in decision matrix matrix using criteria weights and criteria types.

Parameters

matrixndarray

Decision matrix with numerical performance values of alternatives. Decision matrix includes m alternatives in rows and n criteria in columns.

weights: ndarray

Vector with criteria weights given in numerical values. The sum of weights must be equal to 1.

types: ndarray

Criteria types. Profit criteria are represented by 1 and cost by -1.

Returns

ndrarray

Preference values of each alternative. The best alternative has the highest preference value.

Examples

>>> ahp = AHP()
>>> pref = ahp(matrix, weights, types)
>>> rank = rank_preferences(pref, reverse = True)
_check_consistency(X)

Consistency Check on the Pairwise Comparison Matrix of the Criteria or alternatives

Parameters

Xndarray

matrix of pairwise comparisons

Examples

>>> PCcriteria = np.array([[1, 1, 5, 3], [1, 1, 5, 3], [1/5, 1/5, 1, 1/3], [1/3, 1/3, 3, 1]])
>>> ahp = AHP()
>>> ahp._check_consistency(PCcriteria)
_calculate_eigenvector(X)

Compute the Priority Vector of Criteria (weights) or alternatives using Eigenvector method

Parameters

Xndarray

matrix of pairwise comparisons

Returns

ndarray

Eigenvector

Examples

>>> PCM1 = np.array([[1, 5, 1, 1, 1/3, 3],
[1/5, 1, 1/3, 1/5, 1/7, 1],
[1, 3, 1, 1/3, 1/5, 1],
[1, 5, 3, 1, 1/3, 3],
[3, 7, 5, 3, 1, 7],
[1/3, 1, 1, 1/3, 1/7, 1]])
>>> ahp = AHP()
>>> S = ahp._calculate_eigenvector(PCM1)
_normalized_column_sum(X)

Compute the Priority Vector of Criteria (weights) or alternatives using The normalized column sum method

Parameters

Xndarray

matrix of pairwise comparisons

Returns

ndarray

Vector with weights calculated with The normalized column sum method

Examples

>>> PCM1 = np.array([[1, 5, 1, 1, 1/3, 3],
[1/5, 1, 1/3, 1/5, 1/7, 1],
[1, 3, 1, 1/3, 1/5, 1],
[1, 5, 3, 1, 1/3, 3],
[3, 7, 5, 3, 1, 7],
[1/3, 1, 1, 1/3, 1/7, 1]])
>>> ahp = AHP()
>>> S = ahp._normalized_column_sum(PCM1)
_geometric_mean(X)

Compute the Priority Vector of Criteria (weights) or alternatives using The geometric mean method

Parameters

Xndarray

matrix of pairwise comparisons

Returns

ndarray

Vector with weights calculated with The geometric mean method

Examples

>>> PCM1 = np.array([[1, 5, 1, 1, 1/3, 3],
[1/5, 1, 1/3, 1/5, 1/7, 1],
[1, 3, 1, 1/3, 1/5, 1],
[1, 5, 3, 1, 1/3, 3],
[3, 7, 5, 3, 1, 7],
[1/3, 1, 1, 1/3, 1/7, 1]])
>>> ahp = AHP()
>>> S = ahp._geometric_mean(PCM1)
_classic_ahp(alt_matrices, weights, calculate_priority_vector_method=None)

Calculate the global alternative priorities. This is a method for classic AHP where you provide matrices with values of pairwise comparisons of alternatives and weights in the form of a priority vector.

Parameters

alt_matriceslist

list with matrices including values of pairwise comparisons of alternatives

weightsndarray

priority vector of criteria (weights)

calculate_priority_vector_methodfunction

Method for calculation of the priority vector. It can be chosen from three available methods: _calculate_eigenvector, _normalized_column_sum and _geometric_mean if the user does not provide calculate_priority_vector_method, it is automatically set as the default _calculate_eigenvector

Returns

ndarray

vector with the global alternative priorities

Examples

>>> PCcriteria = np.array([[1, 1, 5, 3], [1, 1, 5, 3],
[1/5, 1/5, 1, 1/3], [1/3, 1/3, 3, 1]])
>>> PCM1 = np.array([[1, 5, 1, 1, 1/3, 3],
[1/5, 1, 1/3, 1/5, 1/7, 1],
[1, 3, 1, 1/3, 1/5, 1],
[1, 5, 3, 1, 1/3, 3],
[3, 7, 5, 3, 1, 7],
[1/3, 1, 1, 1/3, 1/7, 1]])
>>> PCM2 = np.array([[1, 7, 3, 1/3, 1/3, 1/3],
[1/7, 1, 1/3, 1/7, 1/9, 1/7],
[1/3, 3, 1, 1/5, 1/5, 1/5],
[3, 7, 5, 1, 1, 1],
[3, 9, 5, 1, 1, 1],
[3, 7, 5, 1, 1, 1]])
>>> PCM3 = np.array([[1, 1/9, 1/7, 1/9, 1, 1/5],
[9, 1, 1, 1, 5, 3],
[7, 1, 1, 1, 5, 1],
[9, 1, 1, 1, 7, 3],
[1, 1/5, 1/5, 1/7, 1, 1/3],
[5, 1/3, 1, 1/3, 3, 1]])
>>> PCM4 = np.array([[1, 1/5, 1/5, 1/3, 1/7, 1/5],
[5, 1, 1, 3, 1/3, 1],
[5, 1, 1, 1, 1/3, 1],
[3, 1/3, 1, 1, 1/7, 1],
[7, 3, 3, 7, 1, 5],
[5, 1, 1, 1, 1/5, 1]])
>>> ahp = AHP()
>>> ahp._check_consistency(PCcriteria)
>>> weights = ahp._calculate_eigenvector(PCcriteria)
>>> alt_matrices = []
>>> alt_matrices.append(PCM1)
>>> alt_matrices.append(PCM2)
>>> alt_matrices.append(PCM3)
>>> alt_matrices.append(PCM4)
>>> calculate_priority_vector_method = ahp._calculate_eigenvector
>>> pref = ahp._classic_ahp(alt_matrices, weights, calculate_priority_vector_method)
>>> rank = rank_preferences(pref, reverse = True)
static _ahp(self, matrix, weights, types, normalization_method)

Score alternatives provided in decision matrix matrix using criteria weights and criteria types.

Parameters

matrixndarray

Decision matrix with numerical performance values of alternatives. The decision matrix includes m alternatives in rows and n criteria in columns.

weights: ndarray

Vector with criteria weights given in numerical values. The sum of weights must be equal to 1.

types: ndarray

Criteria types. Profit criteria are represented by 1 and cost by -1.

Returns

ndrarray

Preference values of each alternative. The best alternative has the highest preference value.

Examples

>>> ahp = AHP()
>>> pref = ahp(matrix, weights, types)
>>> rank = rank_preferences(pref, reverse = True)