pyrepo_mcda.mcda_methods ======================== .. py:module:: pyrepo_mcda.mcda_methods Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/pyrepo_mcda/mcda_methods/ahp/index /autoapi/pyrepo_mcda/mcda_methods/aras/index /autoapi/pyrepo_mcda/mcda_methods/cocoso/index /autoapi/pyrepo_mcda/mcda_methods/codas/index /autoapi/pyrepo_mcda/mcda_methods/copras/index /autoapi/pyrepo_mcda/mcda_methods/cradis/index /autoapi/pyrepo_mcda/mcda_methods/daria/index /autoapi/pyrepo_mcda/mcda_methods/edas/index /autoapi/pyrepo_mcda/mcda_methods/mabac/index /autoapi/pyrepo_mcda/mcda_methods/marcos/index /autoapi/pyrepo_mcda/mcda_methods/mcda_method/index /autoapi/pyrepo_mcda/mcda_methods/multimoora/index /autoapi/pyrepo_mcda/mcda_methods/promethee/index /autoapi/pyrepo_mcda/mcda_methods/prosa_c/index /autoapi/pyrepo_mcda/mcda_methods/pvm/index /autoapi/pyrepo_mcda/mcda_methods/saw/index /autoapi/pyrepo_mcda/mcda_methods/spotis/index /autoapi/pyrepo_mcda/mcda_methods/temporal_promethee/index /autoapi/pyrepo_mcda/mcda_methods/topsis/index /autoapi/pyrepo_mcda/mcda_methods/vikor/index /autoapi/pyrepo_mcda/mcda_methods/vikor_smaa/index /autoapi/pyrepo_mcda/mcda_methods/vmcm/index /autoapi/pyrepo_mcda/mcda_methods/waspas/index Classes ------- .. autoapisummary:: 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.EDAS pyrepo_mcda.mcda_methods.MABAC pyrepo_mcda.mcda_methods.MARCOS pyrepo_mcda.mcda_methods.MULTIMOORA pyrepo_mcda.mcda_methods.MULTIMOORA_RS pyrepo_mcda.mcda_methods.PROMETHEE_II pyrepo_mcda.mcda_methods.PROSA_C pyrepo_mcda.mcda_methods.SAW pyrepo_mcda.mcda_methods.SPOTIS pyrepo_mcda.mcda_methods.TOPSIS pyrepo_mcda.mcda_methods.VIKOR pyrepo_mcda.mcda_methods.VMCM pyrepo_mcda.mcda_methods.WASPAS pyrepo_mcda.mcda_methods.VIKOR_SMAA pyrepo_mcda.mcda_methods.PVM pyrepo_mcda.mcda_methods.DARIA pyrepo_mcda.mcda_methods.Temporal_PROMETHEE_II Package Contents ---------------- .. py:class:: AHP(normalization_method=minmax_normalization) Bases: :py:obj:`pyrepo_mcda.mcda_methods.mcda_method.MCDA_method` Analytic Hierarchy Process (AHP) method for calculating criteria weights from pairwise comparisons and supporting multi-criteria decision analysis. .. py:attribute:: normalization_method .. py:method:: __call__(matrix, weights, types) Score alternatives provided in decision matrix `matrix` using criteria `weights` and criteria `types`. Parameters ------------ matrix : ndarray 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) .. py:method:: _check_consistency(X) Consistency Check on the Pairwise Comparison Matrix of the Criteria or alternatives Parameters ----------- X : ndarray 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) .. py:method:: _calculate_eigenvector(X) Compute the Priority Vector of Criteria (weights) or alternatives using Eigenvector method Parameters ----------- X : ndarray 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) .. py:method:: _normalized_column_sum(X) Compute the Priority Vector of Criteria (weights) or alternatives using The normalized column sum method Parameters ----------- X : ndarray 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) .. py:method:: _geometric_mean(X) Compute the Priority Vector of Criteria (weights) or alternatives using The geometric mean method Parameters ----------- X : ndarray 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) .. py:method:: _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_matrices : list list with matrices including values of pairwise comparisons of alternatives weights : ndarray priority vector of criteria (weights) calculate_priority_vector_method : function 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) .. py:method:: _ahp(self, matrix, weights, types, normalization_method) :staticmethod: Score alternatives provided in decision matrix `matrix` using criteria `weights` and criteria `types`. Parameters ------------ matrix : ndarray 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) .. py:class:: ARAS(normalization_method=sum_normalization) Bases: :py:obj:`pyrepo_mcda.mcda_methods.mcda_method.MCDA_method` Additive Ratio Assessment (ARAS) method used to evaluate and rank alternatives according to their utility degree relative to the ideal solution. .. py:attribute:: normalization_method .. py:method:: __call__(matrix, weights, types) Score alternatives provided in decision matrix `matrix` using criteria `weights` and criteria `types`. Parameters ----------- matrix : ndarray 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) .. py:method:: _aras(matrix, weights, types, normalization_method) :staticmethod: .. py:class:: COCOSO(normalization_method=minmax_normalization, lambda_param=0.5) Bases: :py:obj:`pyrepo_mcda.mcda_methods.mcda_method.MCDA_method` Combined Compromise Solution (CoCoSo) method for evaluating and ranking alternatives using a combination of additive and multiplicative aggregation strategies. .. py:attribute:: normalization_method .. py:attribute:: lambda_param :value: 0.5 .. py: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 ---------- matrix : ndarray 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) .. py:method:: _cocoso(matrix, weights, types, normalization_method=minmax_normalization, lambda_param=0.5) :staticmethod: .. py:class:: CODAS(normalization_method=linear_normalization, distance_metric=euclidean, tau=0.02) Bases: :py:obj:`pyrepo_mcda.mcda_methods.mcda_method.MCDA_method` Combinative Distance-based Assessment (CODAS) method for ranking alternatives based on their distances from the negative ideal solution. .. py:attribute:: normalization_method .. py:attribute:: distance_metric .. py:attribute:: tau :value: 0.02 .. py:method:: __call__(matrix, weights, types) Score alternatives provided in decision matrix `matrix` with m alternatives and n criteria using criteria `weights` and criteria `types`. Parameters ----------- matrix : ndarray 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) .. py:method:: _psi(x) .. py:method:: _codas(self, matrix, weights, types, normalization_method, distance_metric) :staticmethod: .. py:class:: COPRAS(normalization_method=sum_normalization) Bases: :py:obj:`pyrepo_mcda.mcda_methods.mcda_method.MCDA_method` Complex Proportional Assessment (COPRAS) method for evaluating and ranking alternatives based on their proportional significance and utility degree. .. py:attribute:: normalization_method .. py:method:: __call__(matrix, weights, types) Score alternatives provided in decision matrix `matrix` using criteria `weights` and criteria `types`. Parameters ----------- matrix : ndarray 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) .. py:method:: _copras(matrix, weights, types, normalization_method) :staticmethod: .. py:class:: CRADIS(normalization_method=linear_normalization) Bases: :py:obj:`pyrepo_mcda.mcda_methods.mcda_method.MCDA_method` Compromise Ranking of Alternatives from Distance to Ideal Solution (CRADIS) method for ranking alternatives according to their distances from ideal and anti-ideal solutions. .. py:attribute:: normalization_method .. py:method:: __call__(matrix, weights, types) Score alternatives provided in decision matrix `matrix` using criteria `weights` and criteria `types`. Parameters ----------- matrix : ndarray 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) .. py:method:: _cradis(matrix, weights, types, normalization_method) :staticmethod: .. py:class:: EDAS Bases: :py:obj:`pyrepo_mcda.mcda_methods.mcda_method.MCDA_method` Evaluation based on Distance from Average Solution (EDAS) method for ranking alternatives according to their positive and negative distances from the average solution. .. py:method:: __call__(matrix, weights, types) Score alternatives provided in decision matrix `matrix` using criteria `weights` and criteria `types`. Parameters ----------- matrix : ndarray 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) .. py:method:: _edas(weights, types) .. py:class:: MABAC(normalization_method=minmax_normalization) Bases: :py:obj:`pyrepo_mcda.mcda_methods.mcda_method.MCDA_method` Multi-Attributive Border Approximation Area Comparison (MABAC) method for ranking alternatives according to their distances from the border approximation area. .. py:attribute:: normalization_method .. py:method:: __call__(matrix, weights, types) Score alternatives provided in decision matrix `matrix` using criteria `weights` and criteria `types`. Parameters ----------- matrix : ndarray 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) .. py:method:: _mabac(weights, types, normalization_method) .. py:class:: MARCOS Bases: :py:obj:`pyrepo_mcda.mcda_methods.mcda_method.MCDA_method` Measurement Alternatives and Ranking according to Compromise Solution (MARCOS) method for ranking alternatives based on their utility degrees relative to ideal and anti-ideal solutions. .. py:method:: __call__(matrix, weights, types) Score alternatives provided in decision matrix `matrix` using criteria `weights` and criteria `types`. Parameters ----------- matrix : ndarray 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) .. py:method:: _marcos(matrix, weights, types) :staticmethod: .. py:class:: MULTIMOORA(compromise_rank_method=dominance_directed_graph) Bases: :py:obj:`pyrepo_mcda.mcda_methods.mcda_method.MCDA_method` Multi-Objective Optimization on the basis of Ratio Analysis (MULTIMOORA) method for ranking alternatives using the Ratio System, Reference Point, and Full Multiplicative Form approaches. .. py:attribute:: compromise_rank_method .. py: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 ---------- matrix : ndarray 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) .. py:method:: _multimoora(weights, types, compromise_rank_method) .. py:class:: MULTIMOORA_RS Bases: :py:obj:`pyrepo_mcda.mcda_methods.mcda_method.MCDA_method` Ratio System component of the MULTIMOORA method for multi-criteria decision analysis. .. py: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 ---------- matrix : ndarray 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) .. py:method:: _multimoora_rs(matrix, weights, types) :staticmethod: .. py:class:: PROMETHEE_II Bases: :py:obj:`pyrepo_mcda.mcda_methods.mcda_method.MCDA_method` Preference Ranking Organization Method for Enrichment Evaluation II (PROMETHEE II) for ranking alternatives based on positive, negative, and net preference flows. .. py:method:: __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 ---------- matrix : ndarray decision matrix with performance values for m alternatives in rows and n criteria in columns weights : ndarray matrix with criteria weights vectors with number of columns equal to number of columns n of `matrix` types : ndarray 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` .. py:method:: _usual_function(d, p, q) .. py:method:: _ushape_function(d, p, q) .. py:method:: _vshape_function(d, p, q) .. py:method:: _level_function(d, p, q) .. py:method:: _linear_function(d, p, q) .. py:method:: _gaussian_function(d, p, q) .. py:method:: _promethee_II(self, matrix, weights, types, preference_functions, p, q) :staticmethod: Score alternatives provided in the decision matrix `matrix` using criteria `weights` and criteria `types`. Parameters ----------- matrix : ndarray 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_functions : list List with methods containing preference functions for calculating the preference degree for each criterion. If None, default PROMETHEE preference function (usual) is applied. p : ndarray Vector with values representing the threshold of absolute preference. If None, default PROMETHEE preference thresholds are applied. q : ndarray 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) .. py:class:: PROSA_C Bases: :py:obj:`pyrepo_mcda.mcda_methods.promethee.PROMETHEE_II` PROMETHEE for Sustainability Assessment - Criteria (PROSA-C) method for ranking alternatives using preference flows and a compensation coefficient. .. py:method:: __call__(matrix, weights, types, preference_functions=None, p=None, q=None, s=None) .. py:method:: _prosa_c(self, matrix, weights, types, preference_functions, p, q, s) :staticmethod: Score alternatives provided in the decision matrix `matrix` using criteria `weights` and criteria `types`. Parameters ---------- matrix : ndarray 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_functions : list List with methods containing preference functions for calculating the preference degree for each criterion. p : ndarray Vector with values representing the threshold of absolute preference. q : ndarray Vector with values representing the threshold of indifference. s : ndarray 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) .. py:class:: SAW(normalization_method=linear_normalization) Bases: :py:obj:`pyrepo_mcda.mcda_methods.mcda_method.MCDA_method` Simple Additive Weighting (SAW) method for ranking alternatives based on the weighted sum of normalized criterion values. .. py:attribute:: normalization_method .. py: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 ---------- matrix : ndarray 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) .. py:method:: _saw(matrix, weights, types, normalization_method) :staticmethod: .. py:class:: SPOTIS Bases: :py:obj:`pyrepo_mcda.mcda_methods.mcda_method.MCDA_method` Stable Preference Ordering Towards Ideal Solution (SPOTIS) method for ranking alternatives according to their distances from the ideal solution defined within criterion bounds. .. py:method:: __call__(matrix, weights, types, bounds) Score alternatives provided in decision matrix `matrix` using criteria `weights` and criteria `types`. Parameters ----------- matrix : ndarray 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) .. py:method:: _spotis(matrix, weights, types, bounds) :staticmethod: .. py:class:: TOPSIS(normalization_method=minmax_normalization, distance_metric=euclidean) Bases: :py:obj:`pyrepo_mcda.mcda_methods.mcda_method.MCDA_method` Technique for Order Preference by Similarity to Ideal Solution (TOPSIS) method for ranking alternatives according to their distances from ideal and anti-ideal solutions. .. py:attribute:: normalization_method .. py:attribute:: distance_metric .. py: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 ---------- matrix : ndarray 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) .. py:method:: _topsis(matrix, weights, types, normalization_method, distance_metric) :staticmethod: .. py:class:: VIKOR(normalization_method=None, v=0.5) Bases: :py:obj:`pyrepo_mcda.mcda_methods.mcda_method.MCDA_method` VIseKriterijumska Optimizacija I Kompromisno Resenje (VIKOR) method for ranking alternatives and identifying compromise solutions based on group utility and individual regret measures. .. py:attribute:: v :value: 0.5 .. py:attribute:: normalization_method :value: None .. py:method:: __call__(matrix, weights, types) Score alternatives provided in decision matrix `matrix` using criteria `weights` and criteria `types`. Parameters ----------- matrix : ndarray 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) .. py:method:: _vikor(matrix, weights, types, normalization_method, v) :staticmethod: .. py:class:: VMCM Bases: :py:obj:`pyrepo_mcda.mcda_methods.mcda_method.MCDA_method` Vector Measure Construction Method (VMCM) for evaluating and ranking alternatives using vector-based measures of their performance across multiple criteria. .. py:method:: _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 -------------- matrix : ndarray Decision matrix with m alternatives in rows and n criteria in columns. Examples -------------- >>> vmcm = VMCM() >>> vmcm._elimination(matrix) .. py:method:: _weighting(matrix) Calculate criteria weights Parameters ------------- matrix : ndarray 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) .. py:method:: _normalization(matrix) Calculates normalized matrix Parameters -------------- matrix : ndarray Decision matrix with m alternatives in rows and n criteria in columns. Returns --------------- ndarray Normalized matrix Examples --------------- >>> vmcm = VMCM() >>> norm_matrix = vmcm._normalization(matrix) .. py:method:: _pattern_determination(matrix, types) Automatic determination of pattern and anti-pattern Parameters -------------- matrix : ndarray 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) .. py:method:: _classification(m) Assign evaluated objects to classes Parameters ------------- m : ndarray 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) .. py:method:: __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 ---------- matrix : ndarray 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. pattern : ndarray Vector with values of pattern anti_pattern : ndarray 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) .. py:method:: _vmcm(self, matrix, weights, types, pattern, anti_pattern) :staticmethod: .. py:class:: WASPAS(normalization_method=linear_normalization, lambda_param=0.5) Bases: :py:obj:`pyrepo_mcda.mcda_methods.mcda_method.MCDA_method` Weighted Aggregated Sum Product Assessment (WASPAS) method for ranking alternatives by combining the Weighted Sum Model and Weighted Product Model. .. py:attribute:: normalization_method .. py:attribute:: lambda_param :value: 0.5 .. py:method:: __call__(matrix, weights, types) Score alternatives provided in decision matrix `matrix` with m alternatives and n criteria using criteria `weights` and criteria `types`. Parameters ----------- matrix : ndarray 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) .. py:method:: _waspas(matrix, weights, types, normalization_method, lambda_param) :staticmethod: .. py:class:: VIKOR_SMAA(normalization_method=None, v=0.5) VIKOR method combined with Stochastic Multicriteria Acceptability Analysis (SMAA) for ranking alternatives under uncertain criteria weights. .. py:attribute:: v :value: 0.5 .. py:attribute:: normalization_method :value: None .. py:method:: __call__(matrix, weights, types) Score alternatives provided in decision matrix `matrix` using criteria `weights` and criteria `types`. Parameters ----------- matrix : ndarray Decision matrix with m alternatives in rows and n criteria in columns. weights : ndarray Matrix with i vectors in rows of n weights in columns. i means number of iterations of SMAA types : ndarray 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) .. py:method:: _generate_weights(n, iterations) Function to generate multiple weight vectors Parameters ----------- n : int Number of criteria iterations : int Number of weight vector to generate Returns ---------- ndarray Matrix containing in rows vectors with weights for n criteria .. py:method:: _vikor_smaa(self, matrix, weights, types, normalization_method, v) :staticmethod: .. py:class:: PVM Preference Vector Method (PVM) for evaluating and ranking alternatives based on their similarity to motivating and dissimilarity to demotivating preference vectors. .. py:method:: __call__(matrix, weights, types, psi=None, phi=None) Score alternatives provided in decision matrix `matrix` using criteria `weights` and criteria `types`. Parameters ----------- matrix : ndarray 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) .. py:method:: _pvm(matrix, weights, types, psi, phi) :staticmethod: .. py:class:: DARIA Data vARIability Assessment (DARIA) method for analyzing variability and temporal changes in alternative preferences. .. py:method:: _gini(R) Calculate variability values measured by the Gini coefficient in scores obtained by each evaluated option. Parameters ----------- R : ndarray 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) .. py:method:: _entropy(R) Calculate variability values measured by the Entropy in scores obtained by each evaluated option. Parameters ----------- R : ndarray 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) .. py:method:: _std(R) Calculate variability values measured by the Standard Deviation in scores obtained by each evaluated option. Parameters ----------- R : ndarray 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) .. py:method:: _stat_var(X) Calculate variability values measured by the Statistical Variance in scores obtained by each evaluated option. Parameters ---------- R : ndarray 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) .. py:method:: _coeff_var(X) Calculate variability values measured by the Coefficient of Variation in scores obtained by each evaluated option. Parameters ---------- R : ndarray 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) .. py:method:: _direction(R, preference_type=1) Determine the direction of the variability of alternatives scores obtained in the following periods of time. Parameters ---------- R : ndarray Matrix with preference values obtained with MCDA method (for example, TOPSIS) with `t` periods of time in rows and `m` alternatives in columns. preference_type : int 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_list : list 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_class : ndarray 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) .. py:method:: _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 ---------- scores : ndarray Vector with preference values of alternatives from the most recent year analyzed obtained by chosen MCDA method. variability : ndarray Vector with variability values of alternatives preferences obtained in investigated periods. direction : ndarray 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) .. py:class:: Temporal_PROMETHEE_II Temporal extension of the PROMETHEE II method that incorporates variability of preferences over multiple time periods using DARIA. .. py:method:: __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 ---------- matrices : dict[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. weights : np.ndarray Criteria weights. types : np.ndarray Criteria types. Use 1 for profit criteria and -1 for cost criteria. variability_function : Callable[[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()._std`` - ``DARIA()._gini`` - ``DARIA()._entropy`` - ``DARIA()._stat_var`` - ``DARIA()._coeff_var`` preference_functions : list[Callable], optional Preference functions used by the PROMETHEE II method for each criterion. If None, default PROMETHEE preference function (usual) is applied. ps : list[float | int], optional Preference thresholds used by selected PROMETHEE preference functions. If None, default PROMETHEE preference thresholds are applied. qs : list[float | int], optional Indifference thresholds used by selected PROMETHEE preference functions. If None, default PROMETHEE indifference thresholds are applied. alt_names : list[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_scores : np.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] variability : np.ndarray Variability values for alternatives calculated with the selected variability function. direction : np.ndarray Numerical direction of preference changes over time. Values equal to 1 indicate improvement, -1 indicate deterioration, and 0 indicate stability. all_net_flows_df : pd.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