pyrepo_mcda.mcda_methods
Submodules
- pyrepo_mcda.mcda_methods.ahp
- pyrepo_mcda.mcda_methods.aras
- pyrepo_mcda.mcda_methods.cocoso
- pyrepo_mcda.mcda_methods.codas
- pyrepo_mcda.mcda_methods.copras
- pyrepo_mcda.mcda_methods.cradis
- pyrepo_mcda.mcda_methods.daria
- pyrepo_mcda.mcda_methods.edas
- pyrepo_mcda.mcda_methods.mabac
- pyrepo_mcda.mcda_methods.marcos
- pyrepo_mcda.mcda_methods.mcda_method
- pyrepo_mcda.mcda_methods.multimoora
- pyrepo_mcda.mcda_methods.promethee
- pyrepo_mcda.mcda_methods.prosa_c
- pyrepo_mcda.mcda_methods.pvm
- pyrepo_mcda.mcda_methods.saw
- pyrepo_mcda.mcda_methods.spotis
- pyrepo_mcda.mcda_methods.temporal_promethee
- pyrepo_mcda.mcda_methods.topsis
- pyrepo_mcda.mcda_methods.vikor
- pyrepo_mcda.mcda_methods.vikor_smaa
- pyrepo_mcda.mcda_methods.vmcm
- pyrepo_mcda.mcda_methods.waspas
Classes
Analytic Hierarchy Process (AHP) method for calculating criteria weights |
|
Additive Ratio Assessment (ARAS) method used to evaluate and rank |
|
Combined Compromise Solution (CoCoSo) method for evaluating and ranking |
|
Combinative Distance-based Assessment (CODAS) method for ranking |
|
Complex Proportional Assessment (COPRAS) method for evaluating and |
|
Compromise Ranking of Alternatives from Distance to Ideal Solution (CRADIS) |
|
Evaluation based on Distance from Average Solution (EDAS) method |
|
Multi-Attributive Border Approximation Area Comparison (MABAC) method |
|
Measurement Alternatives and Ranking according to Compromise Solution (MARCOS) |
|
Multi-Objective Optimization on the basis of Ratio Analysis |
|
Ratio System component of the MULTIMOORA method for multi-criteria |
|
Preference Ranking Organization Method for Enrichment Evaluation II |
|
PROMETHEE for Sustainability Assessment - Criteria (PROSA-C) |
|
Simple Additive Weighting (SAW) method for ranking alternatives based on |
|
Stable Preference Ordering Towards Ideal Solution (SPOTIS) method |
|
Technique for Order Preference by Similarity to Ideal Solution (TOPSIS) |
|
VIseKriterijumska Optimizacija I Kompromisno Resenje (VIKOR) |
|
Vector Measure Construction Method (VMCM) for evaluating and ranking |
|
Weighted Aggregated Sum Product Assessment (WASPAS) method |
|
VIKOR method combined with Stochastic Multicriteria Acceptability Analysis |
|
Preference Vector Method (PVM) for evaluating and ranking alternatives |
|
Data vARIability Assessment (DARIA) method for analyzing variability |
|
Temporal extension of the PROMETHEE II method that incorporates |
Package Contents
- class pyrepo_mcda.mcda_methods.AHP(normalization_method=minmax_normalization)
Bases:
pyrepo_mcda.mcda_methods.mcda_method.MCDA_methodAnalytic Hierarchy Process (AHP) method for calculating criteria weights from pairwise comparisons and supporting multi-criteria decision analysis.
- 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)
- class pyrepo_mcda.mcda_methods.ARAS(normalization_method=sum_normalization)
Bases:
pyrepo_mcda.mcda_methods.mcda_method.MCDA_methodAdditive Ratio Assessment (ARAS) method used to evaluate and rank alternatives according to their utility degree relative to the ideal solution.
- normalization_method
- __call__(matrix, weights, types)
Score alternatives provided in decision matrix matrix using criteria weights and criteria types.
Parameters
- matrixndarray
Decision matrix with m alternatives in rows and n criteria in columns.
- weights: ndarray
Criteria weights. 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
>>> aras = ARAS() >>> pref = aras(matrix, weights, types) >>> rank = rank_preferences(pref, reverse = True)
- static _aras(matrix, weights, types, normalization_method)
- class pyrepo_mcda.mcda_methods.COCOSO(normalization_method=minmax_normalization, lambda_param=0.5)
Bases:
pyrepo_mcda.mcda_methods.mcda_method.MCDA_methodCombined Compromise Solution (CoCoSo) method for evaluating and ranking alternatives using a combination of additive and multiplicative aggregation strategies.
- normalization_method
- lambda_param = 0.5
- __call__(matrix, weights, types)
Score alternatives provided in decision matrix matrix with m alternatives in rows and n criteria in columns using criteria weights and criteria types.
Parameters
- matrixndarray
Decision matrix with m alternatives in rows and n criteria in columns.
- weights: ndarray
Vector with criteria weights. Sum of weights must be equal to 1.
- types: ndarray
Vector with criteria types. Profit criteria are represented by 1 and cost by -1.
Returns
- ndrarray
Vector with preference values of each alternative. The best alternative has the highest preference value.
Examples
>>> cocoso = COCOSO(lambda_param = lambda_param) >>> pref = cocoso(matrix, weights, types) >>> rank = rank_preferences(pref, reverse = True)
- static _cocoso(matrix, weights, types, normalization_method=minmax_normalization, lambda_param=0.5)
- class pyrepo_mcda.mcda_methods.CODAS(normalization_method=linear_normalization, distance_metric=euclidean, tau=0.02)
Bases:
pyrepo_mcda.mcda_methods.mcda_method.MCDA_methodCombinative Distance-based Assessment (CODAS) method for ranking alternatives based on their distances from the negative ideal solution.
- normalization_method
- distance_metric
- tau = 0.02
- __call__(matrix, weights, types)
Score alternatives provided in decision matrix matrix with m alternatives and n criteria using criteria weights and criteria types.
Parameters
- matrixndarray
Decision matrix with m alternatives in rows and n criteria in columns.
- weights: ndarray
Vector with criteria weights. Sum of weights must be equal to 1.
- types: ndarray
Vector with criteria types. Profit criteria are represented by 1 and cost by -1.
Returns
- ndrarray
Vector with preference values of each alternative. The best alternative has the highest preference value.
Examples
>>> codas = CODAS(normalization_method = linear_normalization, distance_metric = euclidean, tau = 0.02) >>> pref = codas(matrix, weights, types) >>> rank = rank_preferences(pref, reverse = True)
- _psi(x)
- static _codas(self, matrix, weights, types, normalization_method, distance_metric)
- class pyrepo_mcda.mcda_methods.COPRAS(normalization_method=sum_normalization)
Bases:
pyrepo_mcda.mcda_methods.mcda_method.MCDA_methodComplex Proportional Assessment (COPRAS) method for evaluating and ranking alternatives based on their proportional significance and utility degree.
- normalization_method
- __call__(matrix, weights, types)
Score alternatives provided in decision matrix matrix using criteria weights and criteria types.
Parameters
- matrixndarray
Decision matrix with m alternatives in rows and n criteria in columns.
- weights: ndarray
Criteria weights. 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
>>> copras = COPRAS(normalization_method = sum_normalization) >>> pref = copras(matrix, weights, types) >>> rank = rank_preferences(pref, reverse = True)
- static _copras(matrix, weights, types, normalization_method)
- class pyrepo_mcda.mcda_methods.CRADIS(normalization_method=linear_normalization)
Bases:
pyrepo_mcda.mcda_methods.mcda_method.MCDA_methodCompromise Ranking of Alternatives from Distance to Ideal Solution (CRADIS) method for ranking alternatives according to their distances from ideal and anti-ideal solutions.
- normalization_method
- __call__(matrix, weights, types)
Score alternatives provided in decision matrix matrix using criteria weights and criteria types.
Parameters
- matrixndarray
Decision matrix with m alternatives in rows and n criteria in columns.
- weights: ndarray
Criteria weights. 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
>>> cradis = CRADIS() >>> pref = cradis(matrix, weights, types) >>> rank = rank_preferences(pref, reverse = True)
- static _cradis(matrix, weights, types, normalization_method)
- class pyrepo_mcda.mcda_methods.EDAS
Bases:
pyrepo_mcda.mcda_methods.mcda_method.MCDA_methodEvaluation based on Distance from Average Solution (EDAS) method for ranking alternatives according to their positive and negative distances from the average solution.
- __call__(matrix, weights, types)
Score alternatives provided in decision matrix matrix using criteria weights and criteria types.
Parameters
- matrixndarray
Decision matrix with m alternatives in rows and n criteria in columns.
- weights: ndarray
Vector with criteria weights. Sum of weights must be equal to 1.
- types: ndarray
Vevtor with criteria types. Profit criteria are represented by 1 and cost by -1.
Returns
- ndrarray
Vector with preference values of each alternative. The best alternative has the highest preference value.
Examples
>>> edas = EDAS() >>> pref = edas(matrix, weights, types) >>> rank = rank_preferences(pref, reverse = True)
- _edas(weights, types)
- class pyrepo_mcda.mcda_methods.MABAC(normalization_method=minmax_normalization)
Bases:
pyrepo_mcda.mcda_methods.mcda_method.MCDA_methodMulti-Attributive Border Approximation Area Comparison (MABAC) method for ranking alternatives according to their distances from the border approximation area.
- normalization_method
- __call__(matrix, weights, types)
Score alternatives provided in decision matrix matrix using criteria weights and criteria types.
Parameters
- matrixndarray
Decision matrix with m alternatives in rows and n criteria in columns.
- weights: ndarray
Vector with criteria weights. Sum of weights must be equal to 1.
- types: ndarray
Vector with criteria types. Profit criteria are represented by 1 and cost by -1.
Returns
- ndrarray
Vector with preference values of each alternative. The best alternative has the highest preference value.
Examples
>>> mabac = MABAC(normalization_method = minmax_normalization) >>> pref = mabac(matrix, weights, types) >>> rank = rank_preferences(pref, reverse = True)
- _mabac(weights, types, normalization_method)
- class pyrepo_mcda.mcda_methods.MARCOS
Bases:
pyrepo_mcda.mcda_methods.mcda_method.MCDA_methodMeasurement Alternatives and Ranking according to Compromise Solution (MARCOS) method for ranking alternatives based on their utility degrees relative to ideal and anti-ideal solutions.
- __call__(matrix, weights, types)
Score alternatives provided in decision matrix matrix using criteria weights and criteria types.
Parameters
- matrixndarray
Decision matrix with m alternatives in rows and n criteria in columns.
- weights: ndarray
Criteria weights. 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
>>> marcos = MARCOS() >>> pref = marcos(matrix, weights, types) >>> rank = rank_preferences(pref, reverse = True)
- static _marcos(matrix, weights, types)
- class pyrepo_mcda.mcda_methods.MULTIMOORA(compromise_rank_method=dominance_directed_graph)
Bases:
pyrepo_mcda.mcda_methods.mcda_method.MCDA_methodMulti-Objective Optimization on the basis of Ratio Analysis (MULTIMOORA) method for ranking alternatives using the Ratio System, Reference Point, and Full Multiplicative Form approaches.
- compromise_rank_method
- __call__(matrix, weights, types)
Score alternatives provided in decision matrix matrix using vector with criteria weights weights and vector with criteria types types.
Parameters
- matrixndarray
Decision matrix with m alternatives in rows and n criteria in columns.
- weights: ndarray
Criteria weights. 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
>>> multimoora = MULTIMOORA() >>> rank = multimoora(matrix, weights, types)
- _multimoora(weights, types, compromise_rank_method)
- class pyrepo_mcda.mcda_methods.MULTIMOORA_RS
Bases:
pyrepo_mcda.mcda_methods.mcda_method.MCDA_methodRatio System component of the MULTIMOORA method for multi-criteria decision analysis.
- __call__(matrix, weights, types)
Score alternatives provided in decision matrix matrix using vector with criteria weights weights and vector with criteria types types.
Parameters
- matrixndarray
Decision matrix with m alternatives in rows and n criteria in columns.
- weights: ndarray
Criteria weights. 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
>>> multimoora_rs = MULTIMOORA_RS() >>> pref = multimoora_rs(matrix, weights, types) >>> rank = rank_preferences(pref, reverse = True)
- static _multimoora_rs(matrix, weights, types)
- class pyrepo_mcda.mcda_methods.PROMETHEE_II
Bases:
pyrepo_mcda.mcda_methods.mcda_method.MCDA_methodPreference Ranking Organization Method for Enrichment Evaluation II (PROMETHEE II) for ranking alternatives based on positive, negative, and net preference flows.
- __call__(matrix, weights, types, preference_functions=None, p=None, q=None)
Score alternatives from decision matrix matrix using criteria weights weights and criteria types types
Parameters
- matrixndarray
decision matrix with performance values for m alternatives in rows and n criteria in columns
- weightsndarray
matrix with criteria weights vectors with number of columns equal to number of columns n of matrix
- typesndarray
vector with criteria types containing values of 1 for profit criteria and -1 for cost criteria with size equal to number of columns n of matrix
- _usual_function(d, p, q)
- _ushape_function(d, p, q)
- _vshape_function(d, p, q)
- _level_function(d, p, q)
- _linear_function(d, p, q)
- _gaussian_function(d, p, q)
- static _promethee_II(self, matrix, weights, types, preference_functions, p, q)
Score alternatives provided in the decision matrix matrix using criteria weights and criteria types.
Parameters
- matrixndarray
Decision matrix with m alternatives in rows and n criteria in columns.
- weights: ndarray
Criteria weights. The sum of weights must be equal to 1.
- types: ndarray
Criteria types. Profit criteria are represented by 1 and cost by -1.
- preference_functionslist
List with methods containing preference functions for calculating the preference degree for each criterion. If None, default PROMETHEE preference function (usual) is applied.
- pndarray
Vector with values representing the threshold of absolute preference. If None, default PROMETHEE preference thresholds are applied.
- qndarray
Vector with values representing the threshold of indifference. If None, default PROMETHEE indifference thresholds are applied.
Returns
- ndrarray
Preference values of each alternative. The best alternative has the highest preference value.
Examples
>>> promethee_II = PROMETHEE_II() >>> preference_functions = [promethee_II._linear_function for pf in range(len(weights))] >>> u = np.sqrt(np.sum(np.square(np.mean(matrix, axis = 0) - matrix), axis = 0) / matrix.shape[0]) >>> p = 2 * u >>> q = 0.5 * u >>> pref = promethee_II(matrix, weights, types, preference_functions, p = p, q = q) >>> rank = rank_preferences(pref, reverse = True)
- class pyrepo_mcda.mcda_methods.PROSA_C
Bases:
pyrepo_mcda.mcda_methods.promethee.PROMETHEE_IIPROMETHEE for Sustainability Assessment - Criteria (PROSA-C) method for ranking alternatives using preference flows and a compensation coefficient.
- __call__(matrix, weights, types, preference_functions=None, p=None, q=None, s=None)
- static _prosa_c(self, matrix, weights, types, preference_functions, p, q, s)
Score alternatives provided in the decision matrix matrix using criteria weights and criteria types.
Parameters
- matrixndarray
Decision matrix with m alternatives in rows and n criteria in columns.
- weights: ndarray
Criteria weights. The sum of weights must be equal to 1.
- types: ndarray
Criteria types. Profit criteria are represented by 1 and cost by -1.
- preference_functionslist
List with methods containing preference functions for calculating the preference degree for each criterion.
- pndarray
Vector with values representing the threshold of absolute preference.
- qndarray
Vector with values representing the threshold of indifference.
- sndarray
Vector with values of the coefficient sj for the criteria
Returns
- ndrarray
Preference values of each alternative. The best alternative has the highest preference value.
Examples
>>> prosa_c = PROSA_C() >>> preference_functions = [prosa_c._linear_function for pf in range(len(weights))] >>> u = np.sqrt(np.sum(np.square(np.mean(matrix, axis = 0) - matrix), axis = 0) / matrix.shape[0]) >>> p = 2 * u >>> q = 0.5 * u >>> s = np.repeat(0.3, len(weights)) >>> pref = prosa_c(matrix, weights, types, preference_functions, p = p, q = q, s = s) >>> rank = rank_preferences(pref, reverse = True)
- class pyrepo_mcda.mcda_methods.SAW(normalization_method=linear_normalization)
Bases:
pyrepo_mcda.mcda_methods.mcda_method.MCDA_methodSimple Additive Weighting (SAW) method for ranking alternatives based on the weighted sum of normalized criterion values.
- normalization_method
- __call__(matrix, weights, types)
Score alternatives provided in decision matrix matrix with m alternatives in rows and n criteria in columns using criteria weights and criteria types.
Parameters
- matrixndarray
Decision matrix with m alternatives in rows and n criteria in columns.
- weights: ndarray
Vector with criteria weights. Sum of weights must be equal to 1.
- types: ndarray
Vector with criteria types. Profit criteria are represented by 1 and cost by -1.
Returns
- ndrarray
Vector with preference values of each alternative. The best alternative has the highest preference value.
Examples
>>> saw = SAW(normalization_method = minmax_normalization) >>> pref = saw(matrix, weights, types) >>> rank = rank_preferences(pref, reverse = True)
- static _saw(matrix, weights, types, normalization_method)
- class pyrepo_mcda.mcda_methods.SPOTIS
Bases:
pyrepo_mcda.mcda_methods.mcda_method.MCDA_methodStable Preference Ordering Towards Ideal Solution (SPOTIS) method for ranking alternatives according to their distances from the ideal solution defined within criterion bounds.
- __call__(matrix, weights, types, bounds)
Score alternatives provided in decision matrix matrix using criteria weights and criteria types.
Parameters
- matrixndarray
Decision matrix with m alternatives in rows and n criteria in columns.
- weights: ndarray
Vector with criteria weights. Sum of weights must be equal to 1.
- types: ndarray
Vector with criteria types. Profit criteria are represented by 1 and cost by -1.
- bounds: ndarray
Bounds is ndarray with 2 rows and number of columns equal to criteria number. Bounds contain minimum values in the first row and maximum values in the second row for each criterion. Minimum and maximum values for the same criterion cannot be the same.
Returns
- ndrarray
Vector with preference values of each alternative. The best alternative has the lowest preference value.
Examples
>>> bounds_min = np.amin(matrix, axis = 0) >>> bounds_max = np.amax(matrix, axis = 0) >>> bounds = np.vstack((bounds_min, bounds_max)) >>> spotis = SPOTIS() >>> pref = spotis(matrix, weights, types, bounds) >>> rank = rank_preferences(pref, reverse = False)
- static _spotis(matrix, weights, types, bounds)
- class pyrepo_mcda.mcda_methods.TOPSIS(normalization_method=minmax_normalization, distance_metric=euclidean)
Bases:
pyrepo_mcda.mcda_methods.mcda_method.MCDA_methodTechnique for Order Preference by Similarity to Ideal Solution (TOPSIS) method for ranking alternatives according to their distances from ideal and anti-ideal solutions.
- normalization_method
- distance_metric
- __call__(matrix, weights, types)
Score alternatives provided in decision matrix matrix with m alternatives in rows and n criteria in columns using criteria weights and criteria types.
Parameters
- matrixndarray
Decision matrix with m alternatives in rows and n criteria in columns.
- weights: ndarray
Vector with criteria weights. Sum of weights must be equal to 1.
- types: ndarray
Vector with criteria types. Profit criteria are represented by 1 and cost by -1.
Returns
- ndrarray
Vector with preference values of each alternative. The best alternative has the highest preference value.
Examples
>>> topsis = TOPSIS(normalization_method = minmax_normalization, distance_metric = euclidean) >>> pref = topsis(matrix, weights, types) >>> rank = rank_preferences(pref, reverse = True)
- static _topsis(matrix, weights, types, normalization_method, distance_metric)
- class pyrepo_mcda.mcda_methods.VIKOR(normalization_method=None, v=0.5)
Bases:
pyrepo_mcda.mcda_methods.mcda_method.MCDA_methodVIseKriterijumska Optimizacija I Kompromisno Resenje (VIKOR) method for ranking alternatives and identifying compromise solutions based on group utility and individual regret measures.
- v = 0.5
- normalization_method = None
- __call__(matrix, weights, types)
Score alternatives provided in decision matrix matrix using criteria weights and criteria types.
Parameters
- matrixndarray
Decision matrix with m alternatives in rows and n criteria in columns.
- weights: ndarray
Vector with criteria weights. Sum of weights must be equal to 1.
- types: ndarray
Vector with criteria types. Profit criteria are represented by 1 and cost by -1.
Returns
- ndrarray
Vector with preference values of each alternative. The best alternative has the lowest preference value.
Examples
>>> vikor = VIKOR(normalization_method = minmax_normalization) >>> pref = vikor(matrix, weights, types) >>> rank = rank_preferences(pref, reverse = False)
- static _vikor(matrix, weights, types, normalization_method, v)
- class pyrepo_mcda.mcda_methods.VMCM
Bases:
pyrepo_mcda.mcda_methods.mcda_method.MCDA_methodVector Measure Construction Method (VMCM) for evaluating and ranking alternatives using vector-based measures of their performance across multiple criteria.
- _elimination(matrix)
Calculate significance coefficient values for each criterion. Criteria with significance coefficient values between 0 and 0.1 are recommended to be eliminated from the considered criteria set.
Parameters
- matrixndarray
Decision matrix with m alternatives in rows and n criteria in columns.
Examples
>>> vmcm = VMCM() >>> vmcm._elimination(matrix)
- _weighting(matrix)
Calculate criteria weights
Parameters
- matrixndarray
Decision matrix with m alternatives in rows and n criteria in columns.
Returns
- ndarray
Vector with criteria weights
Examples
>>> vmcm = VMCM() >>> weights = vmcm._weighting(matrix)
- _normalization(matrix)
Calculates normalized matrix
Parameters
- matrixndarray
Decision matrix with m alternatives in rows and n criteria in columns.
Returns
- ndarray
Normalized matrix
Examples
>>> vmcm = VMCM() >>> norm_matrix = vmcm._normalization(matrix)
- _pattern_determination(matrix, types)
Automatic determination of pattern and anti-pattern
Parameters
- matrixndarray
Decision matrix with m alternatives in rows and n criteria in columns.
Returns
- ndarray, ndarray
Two vectors including values respectively of pattern and anti-pattern
Examples
>>> vmcm = VMCM() >>> pattern, antipattern = vmcm._pattern_determination(matrix, types)
- _classification(m)
Assign evaluated objects to classes
Parameters
- mndarray
Vector with values of synthetic measure
Returns
- ndarray
Vector including classes assigned to evaluated objects
Examples
>>> vmcm = VMCM() >>> pref = vmcm(matrix, weights, types) >>> classes = vmcm._classification(pref)
- __call__(matrix, weights, types, pattern, anti_pattern)
Score alternatives provided in decision matrix matrix with m alternatives in rows and n criteria in columns using criteria weights and criteria types.
Parameters
- matrixndarray
Decision matrix with m alternatives in rows and n criteria in columns.
- weights: ndarray
Vector with criteria weights. Sum of weights must be equal to 1.
- typesndarray
Vector with criteria types. Profit criteria are represented by 1 and cost by -1.
- patternndarray
Vector with values of pattern
- anti_patternndarray
Vector with values of anti-pattern
Returns
- ndrarray
Vector with preference values of each alternative. The best alternative has the highest preference value.
Examples
>>> vmcm = VMCM() >>> pattern, antipattern = vmcm._pattern_determination(matrix, types) >>> pref = vmcm(matrix, weights, types, pattern, antipattern) >>> rank = rank_preferences(pref, reverse = True)
- static _vmcm(self, matrix, weights, types, pattern, anti_pattern)
- class pyrepo_mcda.mcda_methods.WASPAS(normalization_method=linear_normalization, lambda_param=0.5)
Bases:
pyrepo_mcda.mcda_methods.mcda_method.MCDA_methodWeighted Aggregated Sum Product Assessment (WASPAS) method for ranking alternatives by combining the Weighted Sum Model and Weighted Product Model.
- normalization_method
- lambda_param = 0.5
- __call__(matrix, weights, types)
Score alternatives provided in decision matrix matrix with m alternatives and n criteria using criteria weights and criteria types.
Parameters
- matrixndarray
Decision matrix with m alternatives in rows and n criteria in columns.
- weights: ndarray
Vector with criteria weights. Sum of weights must be equal to 1.
- types: ndarray
Vector with criteria types. Profit criteria are represented by 1 and cost by -1.
Returns
- ndrarray
Vector with preference values of each alternative. The best alternative has the highest preference value.
Examples
>>> waspas = WASPAS(normalization_method = linear_normalization, lambda_param = 0.5) >>> pref = waspas(matrix, weights, types) >>> rank = rank_preferences(pref, reverse = True)
- static _waspas(matrix, weights, types, normalization_method, lambda_param)
- class pyrepo_mcda.mcda_methods.VIKOR_SMAA(normalization_method=None, v=0.5)
VIKOR method combined with Stochastic Multicriteria Acceptability Analysis (SMAA) for ranking alternatives under uncertain criteria weights.
- v = 0.5
- normalization_method = None
- __call__(matrix, weights, types)
Score alternatives provided in decision matrix matrix using criteria weights and criteria types.
Parameters
- matrixndarray
Decision matrix with m alternatives in rows and n criteria in columns.
- weightsndarray
Matrix with i vectors in rows of n weights in columns. i means number of iterations of SMAA
- typesndarray
Vector with criteria types. Profit criteria are represented by 1 and cost by -1.
Returns
- ndrarray, ndarray, ndarray
Matrix with acceptability indexes values for each alternative in rows in relation to each rank in columns, Matrix with central weight vectors for each alternative in rows Matrix with final ranking of alternatives
Examples
>>> vikor_smaa = VIKOR_SMAA(normalization_method = minmax_normalization) >>> rank_acceptability_index, central_weight_vector, rank_scores = vikor_smaa(matrix, weights, types)
- _generate_weights(n, iterations)
Function to generate multiple weight vectors
Parameters
- nint
Number of criteria
- iterationsint
Number of weight vector to generate
Returns
- ndarray
Matrix containing in rows vectors with weights for n criteria
- static _vikor_smaa(self, matrix, weights, types, normalization_method, v)
- class pyrepo_mcda.mcda_methods.PVM
Preference Vector Method (PVM) for evaluating and ranking alternatives based on their similarity to motivating and dissimilarity to demotivating preference vectors.
- __call__(matrix, weights, types, psi=None, phi=None)
Score alternatives provided in decision matrix matrix using criteria weights and criteria types.
Parameters
- matrixndarray
Decision matrix with m alternatives in rows and n criteria in columns.
- weights: ndarray
Attribute weights to the criteria. Sum of weights must be equal to 1.
- types: list
Define the criteria character: Motivating criteria are represented by m Demotivating criteria are represented by dm Desirable criteria are represented by d Non-desirable criteria are represented by nd
- psi: ndarray
Preference vector with motivating or desirable values. Providing of psi is optional.
- phi: ndarray
Preference vector with demotivating or non-desirable values. Providing of psi is optional.
Returns
- ndrarray
Preference values of each alternative. The best alternative has the highest preference value.
Examples
>>> pvm = PVM() >>> pref = pvm(matrix, weights, types) >>> rank = rank_preferences(pref, reverse = True)
- static _pvm(matrix, weights, types, psi, phi)
- class pyrepo_mcda.mcda_methods.DARIA
Data vARIability Assessment (DARIA) method for analyzing variability and temporal changes in alternative preferences.
- _gini(R)
Calculate variability values measured by the Gini coefficient in scores obtained by each evaluated option.
Parameters
- Rndarray
Matrix with preference values obtained with MCDA method (for example, TOPSIS) with t periods of time in rows and m alternatives in columns.
Returns
- ndarray
Vector with Gini coefficient values for each alternative.
Examples
>>> daria = DARIA() >>> variability = daria._gini(matrix)
- _entropy(R)
Calculate variability values measured by the Entropy in scores obtained by each evaluated option.
Parameters
- Rndarray
Matrix with preference values obtained with MCDA method (for example, TOPSIS) with t periods of time in rows and m alternatives in columns.
Returns
- ndarray
Vector with Entropy values for each alternative.
Examples
>>> daria = DARIA() >>> variability = daria._entropy(matrix)
- _std(R)
Calculate variability values measured by the Standard Deviation in scores obtained by each evaluated option.
Parameters
- Rndarray
Matrix with preference values obtained with MCDA method (for example, TOPSIS) with t periods of time in rows and m alternatives in columns.
Returns
- ndarray
Vector with Standard Deviation values for each alternative.
Examples
>>> daria = DARIA() >>> variability = daria._std(matrix)
- _stat_var(X)
Calculate variability values measured by the Statistical Variance in scores obtained by each evaluated option.
Parameters
- Rndarray
Matrix with preference values obtained with MCDA method (for example, TOPSIS) with t periods of time in rows and m alternatives in columns.
Returns
- ndarray
Vector with Statistical Variance values for each alternative.
Examples
>>> daria = DARIA() >>> variability = daria._stat_var(matrix)
- _coeff_var(X)
Calculate variability values measured by the Coefficient of Variation in scores obtained by each evaluated option.
Parameters
- Rndarray
Matrix with preference values obtained with MCDA method (for example, TOPSIS) with t periods of time in rows and m alternatives in columns.
Returns
- ndarray
Vector with Coefficient of Variation values for each alternative.
Examples
>>> daria = DARIA() >>> variability = daria._coeff_var(matrix)
- _direction(R, preference_type=1)
Determine the direction of the variability of alternatives scores obtained in the following periods of time.
Parameters
- Rndarray
Matrix with preference values obtained with MCDA method (for example, TOPSIS) with t periods of time in rows and m alternatives in columns.
- preference_typeint
The variable represents the ordering of alternatives by the MCDA method. It can be equal to 1 or -1. 1 means that the MCDA method sorts options in descending order according to preference values (for example, the TOPSIS method). -1 means that the MCDA method sorts options in ascending order according to preference values (for example, the VIKOR method).
Returns
- direction_listlist
List with strings representing the direction of variability in the form of the arrow up for improvement, arrow down for worsening, and = for stability. It is useful for results presentation.
- dir_classndarray
Vector with numerical values representing the direction of variability. 1 represents increasing preference values, and -1 means decreasing preference values. It is used to calculate final aggregated preference values using DARIA method in next stage of DARIA method.
Examples
>>> daria = DARIA() >>> dir_list, dir_class = daria._direction(matrix, preference_type)
- _update_efficiency(scores, variability, direction)
Calculate final aggregated preference values of alternatives of DARIA method. Obtained preference values can be sorted according to chosen MCDA method rule to generate ranking of alternatives.
Parameters
- scoresndarray
Vector with preference values of alternatives from the most recent year analyzed obtained by chosen MCDA method.
- variabilityndarray
Vector with variability values of alternatives preferences obtained in investigated periods.
- directionndarray
Vector with numerical values of the direction of variability in values of alternatives preferences obtained in investigated periods. 1 represents increasing in following preference values, and -1 means decreasing in following preference values.
Returns
- ndarray
Final aggregated preference values of alternatives considering variability in preference values obtained in the following periods.
Examples
>>> updated_scores = daria._update_efficiency(scores, variability, direction) >>> rank = rank_preferences(updated_scores, reverse = True)
- class pyrepo_mcda.mcda_methods.Temporal_PROMETHEE_II
Temporal extension of the PROMETHEE II method that incorporates variability of preferences over multiple time periods using DARIA.
- __call__(matrices: dict[str, numpy.ndarray], weights: numpy.ndarray, types: numpy.ndarray, variability_function: Callable[[numpy.ndarray], numpy.ndarray] | None = None, preference_functions: list[Callable] | None = None, ps: list[float | int] | None = None, qs: list[float | int] | None = None, alt_names: list[str] | None = None) tuple[numpy.ndarray, tuple[numpy.ndarray, numpy.ndarray, pandas.DataFrame]]
Calculate Temporal PROMETHEE II scores considering variability of alternative preferences over multiple time periods.
The method first calculates PROMETHEE II net flows for each decision matrix representing a separate time period. Next, variability and direction of changes in preferences are determined using selected DARIA measures. Finally, the PROMETHEE II scores from the most recent period are updated using variability information to obtain temporal preference scores.
Decision matrices must contain the same number of alternatives and criteria in all periods.
Parameters
- matricesdict[str, np.ndarray]
Dictionary containing decision matrices for subsequent time periods. Keys represent time periods (for example years) and values are decision matrices. All matrices must have the same shape, where rows represent alternatives and columns represent criteria.
- weightsnp.ndarray
Criteria weights.
- typesnp.ndarray
Criteria types. Use 1 for profit criteria and -1 for cost criteria.
- variability_functionCallable[[np.ndarray], np.ndarray], optional
Function used to calculate variability values for alternatives based on preference values obtained in consecutive periods. The function should accept a matrix with periods in rows and alternatives in columns and return a one-dimensional array of variability values.
If
None, standard deviation from the DARIA method is used.Examples include:
DARIA()._stdDARIA()._giniDARIA()._entropyDARIA()._stat_varDARIA()._coeff_var
- preference_functionslist[Callable], optional
Preference functions used by the PROMETHEE II method for each criterion. If None, default PROMETHEE preference function (usual) is applied.
- pslist[float | int], optional
Preference thresholds used by selected PROMETHEE preference functions. If None, default PROMETHEE preference thresholds are applied.
- qslist[float | int], optional
Indifference thresholds used by selected PROMETHEE preference functions. If None, default PROMETHEE indifference thresholds are applied.
- alt_nameslist[str], optional
Names of alternatives. If provided, they are assigned as row labels in the returned DataFrame containing PROMETHEE II net flows.
Returns
- tuple[np.ndarray, tuple[np.ndarray, np.ndarray, pd.DataFrame]]
- updated_scoresnp.ndarray
Final temporal preference scores obtained after updating the most recent PROMETHEE II net flows using DARIA variability information.
- tuple[np.ndarray, np.ndarray, pd.DataFrame]
- variabilitynp.ndarray
Variability values for alternatives calculated with the selected variability function.
- directionnp.ndarray
Numerical direction of preference changes over time. Values equal to 1 indicate improvement, -1 indicate deterioration, and 0 indicate stability.
- all_net_flows_dfpd.DataFrame
DataFrame containing PROMETHEE II net flows for all analyzed periods. Rows correspond to alternatives and columns correspond to time periods.
Raises
- ValueError
If no decision matrices are provided.
- ValueError
If decision matrices do not have identical shapes.
- ValueError
If the number of alternative names does not match the number of alternatives.
- TypeError
If variability_function is not callable.
Examples
>>> import numpy as np >>> from pyrepo_mcda.mcda_methods import Temporal_PROMETHEE_II, DARIA >>> matrices = { ... "2022": np.array([ ... [10, 5], ... [12, 7], ... [8, 9] ... ]), ... "2023": np.array([ ... [11, 6], ... [13, 7], ... [9, 8] ... ]), ... "2024": np.array([ ... [12, 7], ... [14, 8], ... [10, 9] ... ]) ... } >>> weights = np.array([0.6, 0.4]) >>> types = np.array([1, -1]) >>> tp = Temporal_PROMETHEE_II() >>> daria = DARIA() >>> scores, (variability, direction, net_flows) = tp( ... matrices=matrices, ... weights=weights, ... types=types, ... variability_function=daria._gini ... ) >>> scores