pymcdm.methods

class pymcdm.methods.ARAS(normalization_function=<function sum_normalization>, esp=None)

Bases: MCDA_method

Additive Ratio ASsessment (ARAS) method.

The ARAS method is based on a utility function value that determines the complex relative efficiency of a feasible alternative [1]. This relationship is directly proportional to the relative effect of the values and weights of the main criteria.

Read more in the User Guide.

Parameters:
  • normalization_function (callable) – Function which should be used to normalize matrix columns. It should match signature foo(x, cost), where x is a vector which should be normalized and cost is a bool variable which says if x is a cost or profit criterion.

  • esp (ndarray or None) – Optimal values for alternatives evaluation. Should be array with ideal (expected) value for each criterion. If None, ESP will be calculated based on data and criteria types. Default is None.

References

Examples

>>> from pymcdm.methods import ARAS
>>> import numpy as np
>>> body = ARAS()
>>> matrix = np.array([[4.64, 3.00, 3.00, 3.00, 2.88, 3.63],
...                    [4.00, 4.00, 4.64, 3.56, 3.63, 5.00],
...                    [3.30, 4.31, 3.30, 4.00, 3.30, 4.00],
...                    [2.62, 5.00, 4.22, 4.31, 5.00, 5.00]])
>>> weights = np.array([0.28, 0.25, 0.19, 0.15, 0.08, 0.04])
>>> types = np.array([1, 1, 1, 1, 1, 1])
>>> [round(preference, 2) for preference in body(matrix, weights, types)]
[0.74, 0.86, 0.78, 0.86]
class pymcdm.methods.COCOSO(normalization_function=<function minmax_normalization>, l=0.5)

Bases: MCDA_method

COmbined COmpromise SOlution (COCOSO) method.

The COCOSO method is based on an integrated model of simple additive weighting and exponentially weighted product [2].

Read more in the User Guide.

Parameters:

normalization_function (callable) – Function which should be used to normalize matrix columns. It should match signature foo(x, cost), where x is a vector which should be normalized and cost is a bool variable which says if x is a cost or profit criterion.

References

Examples

>>> from pymcdm.methods import COCOSO
>>> import numpy as np
>>> body = COCOSO()
>>> matrix = np.array([[60, 0.4, 2540, 500, 990],
...                    [6.35, 0.15, 1016, 3000, 1041],
...                    [6.8, 0.1, 1727.2, 1500, 1676],
...                    [10, 0.2, 1000, 2000, 965],
...                    [2.5, 0.1, 560, 500, 915],
...                    [4.5, 0.08, 1016, 350, 508],
...                    [3, 0.1, 1778, 1000, 920]])
>>> weights = np.array([0.036, 0.192, 0.326, 0.326, 0.12])
>>> types = np.array([1, -1, 1, 1, 1])
>>> [round(preference, 3) for preference in body(matrix, weights, types)]
[2.041, 2.788, 2.882, 2.416, 1.299, 1.443, 2.519]
class pymcdm.methods.CODAS(normalization_function=<function linear_normalization>)

Bases: MCDA_method

COmbinative Distance-based ASsessment (CODAS) method.

The CODAS method is based on an approach based on Euclidean distance and Taxicab from the negative ideal solution [3].

Read more in the User Guide.

Parameters:

normalization_function (callable) – Function which should be used to normalize matrix columns. It should match signature foo(x, cost), where x is a vector which should be normalized and cost is a bool variable which says if x is a cost or profit criterion.

References

Examples

>>> from pymcdm.methods import CODAS
>>> import numpy as np
>>> body = CODAS()
>>> matrix = np.array([[45, 3600, 45, 0.9],
...                    [25, 3800, 60, 0.8],
...                    [23, 3100, 35, 0.9],
...                    [14, 3400, 50, 0.7],
...                    [15, 3300, 40, 0.8],
...                    [28, 3000, 30, 0.6]])
>>> weights = np.array([0.2857, 0.3036, 0.2321, 0.1786])
>>> types = np.array([1, -1, 1, 1])
>>> [round(preference, 4) for preference in body(matrix, weights, types)]
[1.3914, 0.3411, -0.2170, -0.5381, -0.7292, -0.2481]
class pymcdm.methods.COMET(cvalues, expert_function)

Bases: MCDA_method

Characteristic Objects METhod (COMET).

COMET is a method based on characteristic objects on the basis of which preference of the deicision variants is calculated [4]. Due to this dependence the method is resistant to the phenomenon of ranking reversal paradox.

Read more in the User Guide.

Parameters:
  • cvalues (ndarray or list of lists) – Each row represent characteristic values for each criteria.

  • expert_function (callable) –

    Function to rate CO. Matrix with CO as rows is passed as an argument. Function should return vector which will be used as SJ and the MEJ matrix. If MEJ was not build None should be returned.

    Signature of the function should be as followed:

    rate_function(co: np.array) -> np.array, np.array or None

    Please, see the implementation of ManualExpert and MethodExpert in the pymcdm.comet_tools submodule if you want to create your own custom expert_function.

References

Examples

>>> from pymcdm.methods import COMET, TOPSIS
>>> from pymcdm.methods.comet_tools import MethodExpert
>>> import numpy as np
>>> matrix = np.array([[64, 128, 2.9, 4.3, 3.2, 280, 495, 24763, 3990],
...                    [28, 56, 3.1, 3.8, 3.8, 255, 417, 12975, 2999],
...                    [8, 16, 3.5, 5.3, 4.8, 125, 636, 5725, 539],
...                    [12, 24, 3.7, 4.8, 4.5, 105, 637, 8468, 549],
...                    [10, 20, 3.7, 5.3, 4.9, 125, 539, 6399, 499],
...                    [8, 16, 3.6, 4.4, 4.0, 65, 501, 4834, 329],
...                    [6, 12, 3.7, 4.6, 4.2, 65, 604, 4562, 299],
...                    [16, 32, 3.4, 4.9, 4.2, 105, 647, 10428, 799],
...                    [8, 16, 3.6, 5.0, 4.5, 125, 609, 5615, 399],
...                    [18, 36, 3.0, 4.8, 4.3, 165, 480, 8848, 979],
...                    [24, 48, 3.8, 4.5, 4.0, 280, 509, 13552, 1399],
...                    [28, 56, 2.5, 3.8, 2.8, 205, 376, 8585, 10000]])
>>> cvalues = np.vstack((
...     np.min(matrix, axis=0),
...     np.max(matrix, axis=0)
... )).T
>>> types = np.array([1, 1, 1, 1, 1, -1, 1, 1, -1])
>>> weights = np.array([1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9])
>>> body = COMET(cvalues, MethodExpert(TOPSIS(), weights, types))
>>> [round(preference, 4) for preference in body(matrix)]
[0.5433, 0.3447, 0.6115, 0.6168, 0.6060, 0.4842, 0.5516, 0.6100, 0.5719, 0.4711, 0.4979, 0.1452]
__call__(matrix, weights=None, types=None, validation=True, verbose=False)

Rank alternatives from decision matrix matrix.

Parameters:
  • matrix (ndarray) – Decision matrix / alternatives data. Alternatives are in rows and Criteria are in columns.

  • weights (None) – Not used in the COMET method.

  • types (None) – Not used in the COMET method.

  • validation (bool) – Enable (True) or disable (False) validation of the input data. For the COMET method only matrix and cvalues are validated. Default is True.

  • verbose (bool) – Explain the MCDA, i.e. provide matrices and vectors from all the steps of the method, instead of return just the preference vector. Default is False.

get_MEJ()

Return the Matrix Expert Judgment (MEJ) generated from the feature object comparisons.

static make_cvalues(matrix, numbers_of_cvalues=3)

Returns characteristic values matrix with nubmers_of_cvalues cvalues for each criterion. Characteristic values are generated equally from min to max.

Parameters:
  • matrix (ndarray) – Decision matrix. Alternatives are in rows and Criteria are in columns.

  • numbers_of_cvalues (int, optional) – Number of characteristic value for each criterion. Default value is 3.

Returns:

cvalues – Characteristic values for COMET method.

Return type:

ndarray

Examples

>>> import numpy as np
>>> from pymcdm.methods import COMET, TOPSIS
>>> from pymcdm.methods.comet_tools import MethodExpert
>>> matrix = np.array([[ 96, 145, 200],
                       [100, 145, 200],
                       [120, 170,  80],
                       [140, 180, 140],
                       [100, 110,  30]])
>>> types = np.ones(3)
>>> weights = np.ones(3)/3
>>> body = COMET(cvalues,
                 MethodExpert(TOPSIS(), weights, types))
>>> preferences = body(matrix)
>>> np.round(preferences, 4)
array([0.5   , 0.5455, 0.5902, 0.9118, 0.0227])
class pymcdm.methods.COPRAS

Bases: MCDA_method

COmplex PRoportional ASsessment (COPRAS) method.

COPRAS is used to assess the maximizing and minimizing index values, and the effect of maximizing and minimizing indexes of attributes on the results assessment is considered separately. See [5] [6].

Read more in the User Guide.

References

Examples

>>> from pymcdm.methods import COPRAS
>>> import numpy as np
>>> body = COPRAS()
>>> matrix = np.array([[1543, 2000, 39000, 15, 13.76, 3.86, 5, 3, 5000],
...                    [1496, 3600, 43000, 14, 14, 2.5, 4, 4, 4000],
...                    [1584, 3100, 24500, 10, 13.1, 3.7, 2, 2, 3500],
...                    [1560, 2700, 36000, 12, 13.2, 3.2, 3, 3, 3500],
...                    [1572, 2500, 31500, 13, 13.3, 3.4, 3, 2, 3500],
...                    [1580, 2400, 20000, 12, 12.8, 3.9, 2, 2, 3000]])
>>> weights = np.array([0.2027, 0.1757, 0.1622, 0.1351, 0.1081, 0.0946, 0.0676, 0.0405, 0.0135])
>>> types = np.array([-1, -1, -1, 1, 1, -1, 1, 1, 1])
>>> [round(preference, 4) for preference in body(matrix, weights, types)]
[0.9459, 1.0, 0.8192, 0.8839, 0.8556, 0.7789]
class pymcdm.methods.EDAS

Bases: MCDA_method

Evaluation based on Distance from Average Solution (EDAS) method.

The EDAS method is based on an approach in which the decision alternatives are evaluated with respect to their distance from the mean solutions i.e. negative mean solution and positive mean solution [7].

Read more in the User Guide.

References

Examples

>>> from pymcdm.methods import EDAS
>>> import numpy as np
>>> body = EDAS()
>>> matrix = np.array([[3873, 39.55, 0.27, 0.87, 150, 0.07, 12, 2130],
...                    [5067, 67.26, 0.23, 0.23, 40, 0.02, 21, 2200],
...                    [2213, 24.69, 0.08, 0.17, 200, 0.04, 35, 570],
...                    [6243, 132, 0.07, 0.25, 100, 0.04, 16, 100],
...                    [8312, 460.47, 0.05, 0.21, 25, 0.1, 25, 200]])
>>> weights = np.array([0.131, 0.113, 0.126, 0.125, 0.126, 0.129, 0.132, 0.117])
>>> types = np.array([-1, -1, -1, 1, 1, -1, 1, 1])
>>> [round(preference, 3) for preference in body(matrix, weights, types)]
[0.841, 0.632, 0.883, 0.457, 0.104]
class pymcdm.methods.ERVD(ref_point, lambd=2.25, alpha=0.88)

Bases: MCDA_method

Election based on Relative Value Distances method [8].

References

Examples

>>> matrix = np.array([
...     [80, 70, 87, 77, 76, 80, 75],
...     [85, 65, 76, 80, 75, 65, 75],
...     [78, 90, 72, 80, 85, 90, 85],
...     [75, 84, 69, 85, 65, 65, 70],
...     [84, 67, 60, 75, 85, 75, 80],
...     [85, 78, 82, 81, 79, 80, 80],
...     [77, 83, 74, 70, 71, 65, 70],
...     [78, 82, 72, 80, 78, 70, 60],
...     [85, 90, 80, 88, 90, 80, 85],
...     [89, 75, 79, 67, 77, 70, 75],
...     [65, 55, 68, 62, 70, 50, 60],
...     [70, 64, 65, 65, 60, 60, 65],
...     [95, 80, 70, 75, 70, 75, 75],
...     [70, 80, 79, 80, 85, 80, 70],
...     [60, 78, 87, 70, 66, 70, 65],
...     [92, 85, 88, 90, 85, 90, 95],
...     [86, 87, 80, 70, 72, 80, 85]
... ])
>>> weights = np.array([0.066, 0.196, 0.066, 0.130, 0.130, 0.216, 0.196])
>>> types = np.ones(7)
>>> ref = np.ones(7) * 80
>>> ervd = ERVD(ref_point=ref)
>>> pref = ervd(matrix, weights, types)
>>> rank = ervd.rank(pref)
>>> print(pref)
[0.66  0.503 0.885 0.521 0.61  0.796 0.498 0.549 0.908 0.565 0.07  0.199 0.632 0.716 0.438 0.972 0.767]
>>> print(rank)
[ 7. 13.  3. 12.  9.  4. 14. 11.  2. 10. 17. 16.  8.  6. 15.  1.  5.]
class pymcdm.methods.LoPM(property_limits: ndarray = None, property_types: ndarray = None)

Bases: MCDA_method

Limits on Property Method

Limits on Property Method is a method primarily proposed for dealing with material selection problems. It operates on three types of criteria (in method’s convention): lower-limit, upper-limit and target properties [9].

Read more in the User Guide.

Parameters:
  • property_limits (np.ndarray or None) – Vector of lower-limit, upper-limit and target value properties. If None, then limits will be derived from matrix based on types on each call. Default is None.

  • property_types (np.ndarray or None) – Vector of property types: should be iterable with int values that define types of properties provided in property_limits argument. Possible values: - 1 for lower-limit, treated as “no lower than”, equivalent to profit criteria. - -1 for upper-limit, treated as “no bigger than”, equivalent to cost criteria. - 0 for target properties, equivalent of Expected Solution Point. If None, then types argument will be used to determine limits’ types. Note, that if the Default is None.

References

Examples

>>> import numpy as np
>>> from pymcdm.methods import LoPM
>>> matrix = np.array([
...     [14_820, 18, 0.0002, 2.1,  9.5, 4.5],
...     [21_450, 18, 0.0012, 2.7, 14.4, 9.0],
...     [78_000, 16, 0.0006, 2.6,  9.0, 8.5],
...     [20_475, 17, 0.0006, 2.6,  6.5, 2.6],
...     [16_575, 14, 0.0010, 3.1,  5.6, 3.5],
...     [21_450, 16, 0.0005, 2.2,  8.6, 1.0]
... ])
>>> weights = np.array([0.20, 0.33, 0.13, 0.07, 0.07, 0.20])
>>> lopm = LoPM([10_000, 14, 0.0015, 3.5, 2.3, 9.0], [1, 1, -1, -1, 0, -1])
>>> print(lopm(matrix, weights, None).round(2))
[0.77 1.08 0.81 0.66 0.78 0.68]
__call__(matrix: ndarray | list | tuple, weights: ndarray | list | tuple, types: ndarray | list | tuple = None, validation: bool = True, verbose: bool = False)

Rank alternatives from decision matrix matrix, with criteria weights weights and criteria types types.

Parameters:
  • matrix (ndarray) – Decision matrix / alternatives data. Alternatives are in rows and Criteria are in columns.

  • weights (ndarray) – Criteria weights. Sum of the weights should be 1. (e.g. sum(weights) == 1)

  • types (ndarray or None) – Array with definitions of criteria types: 1 if criteria is profit and -1 if criteria is cost for each criteria in matrix. Can be omitted if property_limits and property_types were provided in the constructor. Note, that if both types and property_types are provided, property_types are preferred and will be used.

  • validation (bool) – Enable or disable validation of the all input data. True - validation is enabled, False - validation is disabled. Default is True.

  • verbose (bool) – Explain the MCDA, i.e. provide matrices and vectors from all the steps of the method, instead of return just the preference vector. Default is False.

reverse_ranking = False
class pymcdm.methods.MABAC(normalization_function=<function minmax_normalization>)

Bases: MCDA_method

Multi-Attributive Border Approximation Area Comparison (MABAC) method.

The MABAC method is based on determining the distance measure between each possible alternative and the Boundary Approximation Area (BAA) [10].

Parameters:

normalization_function (callable) – Function which should be used to normalize matrix columns. It should match signature foo(x, cost), where x is a vector which should be normalized and cost is a bool variable which says if x is a cost or profit criterion.

References

Examples

>>> from pymcdm.methods import MABAC
>>> import numpy as np
>>> body = MABAC()
>>> matrix = np.array([[22600, 3800, 2, 5, 1.06, 3.00, 3.5, 2.8, 24.5, 6.5],
...                    [19500, 4200, 3, 2, 0.95, 3.00, 3.4, 2.2, 24, 7.0],
...                    [21700, 4000, 1, 3, 1.25, 3.20, 3.3, 2.5, 24.5, 7.3],
...                    [20600, 3800, 2, 5, 1.05, 3.25, 3.2, 2.0, 22.5, 11.0],
...                    [22500, 3800, 4, 3, 1.35, 3.20, 3.7, 2.1, 23, 6.3],
...                    [23250, 4210, 3, 5, 1.45, 3.60, 3.5, 2.8, 23.5, 7.0],
...                    [20300, 3850, 2, 5, 0.90, 3.25, 3.0, 2.6, 21.5, 6.0]])
>>> weights = np.array([0.146, 0.144, 0.119, 0.121, 0.115, 0.101, 0.088, 0.068, 0.050, 0.048])
>>> types = np.array([-1, 1, 1, 1, -1, -1, 1, 1, 1, 1])
>>> [round(preference, 4) for preference in body(matrix, weights, types)]
[0.0826, 0.2183, -0.0488, 0.0246, -0.0704, 0.0465, 0.0464]
class pymcdm.methods.MAIRCA(normalization_function=<function minmax_normalization>)

Bases: MCDA_method

Multi-Attributive RealIdeal Comparative Analysis (MARICA) method.

The MAIRCA method is based on an assumption in which it determines the gap between ideal and empirical rates [11].

Read more in the User Guide.

Parameters:

normalization_function (callable) – Function which should be used to normalize matrix columns. It should match signature foo(x, cost), where x is a vector which should be normalized and cost is a bool variable which says if x is a cost or profit criterion.

References

Examples

>>> from pymcdm.methods import MAIRCA
>>> import numpy as np
>>> body = MAIRCA()
>>> matrix = np.array([[70, 245, 16.4, 19],
...                    [52, 246, 7.3, 22],
...                    [53, 295, 10.3, 25],
...                    [63, 256, 12, 8],
...                    [64, 233, 5.3, 17]])
>>> weights = np.array([0.04744, 0.02464, 0.51357, 0.41435])
>>> types = np.array([1, 1, 1, 1])
>>> [round(preference, 4) for preference in body(matrix, weights, types)]
[0.0332, 0.1122, 0.0654, 0.1304, 0.1498]
class pymcdm.methods.MARCOS(normalization_function=<function _marcos_normalization>)

Bases: MCDA_method

Measurement of Alternatives and Ranking according to COmpromise Solution (MARCOS) method.

The MARCOS method is based on the approach of evaluating alternatives according to reference values (ideal and anti-ideal) using a utility function [12].

Parameters:

normalization_function (callable) – Function which should be used to normalize matrix columns. It should match signature foo(x, cost), where x is a vector which should be normalized and cost is a bool variable which says if x is a cost or profit criterion.

References

Examples

>>> from pymcdm.methods import MARCOS
>>> import numpy as np
>>> body = MARCOS()
>>> matrix = np.array([[660, 1000, 1600, 18, 1200],
...                    [800, 1000, 1600, 24, 900],
...                    [980, 1000, 2500, 24, 900],
...                    [920, 1500, 1600, 24, 900],
...                    [1380, 1500, 1500, 24, 1150],
...                    [1230, 1000, 1600, 24, 1150],
...                    [680, 1500, 1600, 18, 1100],
...                    [960, 2000, 1600, 12, 1150]])
>>> weights = np.array([0.1061, 0.3476, 0.3330, 0.1185, 0.0949])
>>> types = np.array([-1, 1, 1, 1, 1])
>>> [round(preference, 4) for preference in body(matrix, weights, types)]
[0.5649, 0.5543, 0.6410, 0.6174, 0.6016, 0.5453, 0.6282, 0.6543]
class pymcdm.methods.MOORA

Bases: MCDA_method

Multi-Objective Optimization on the basis of Ratio Analysis (MOORA) method.

The MOORA method is based on an approach using multi-objective optimization to evaluate alternatives [13].

References

Examples

>>> from pymcdm.methods import MOORA
>>> import numpy as np
>>> body = MOORA()
>>> matrix = np.array([[1.5, 3, 5, 3.3],
...                    [2, 7, 5, 3.35],
...                    [3, 1, 5, 3.07],
...                    [2.2, 4, 5, 3.5],
...                    [2, 5, 3, 3.09],
...                    [3.2, 2, 3, 3.48],
...                    [2.775, 3, 5, 3.27]])
>>> weights = np.array([0.3, 0.2, 0.1, 0.4])
>>> types = np.array([-1, 1, 1, 1])
>>> [round(preference, 4) for preference in body(matrix, weights, types)]
[0.1801, 0.2345, 0.0625, 0.1757, 0.1683, 0.0742, 0.1197]
class pymcdm.methods.OCRA(normalization_function=<function _ocra_normalization>)

Bases: MCDA_method

Operational Competitiveness Rating (OCRA) method.

The main idea of the OCRA method is toperform independent evaluation ofalternatives with respect to beneficial andnon beneficial criteria, and finally tocombine these two sets of ratings to obtainthe operational competitiveness ratings [14].

Parameters:

normalization_function (callable) – Function which should be used to normalize matrix columns. It should match signature foo(x, cost), where x is a vector which should be normalized and cost is a bool variable which says if x is a cost or profit criterion.

References

Examples

>>> from pymcdm.methods import OCRA
>>> import numpy as np
>>> body = OCRA()
>>> matrix = np.array([[7.7, 256, 7.2, 7.3, 7.3],
...                    [8.1, 250, 7.9, 7.8, 7.7],
...                    [8.7, 352, 8.6, 7.9, 8.0],
...                    [8.1, 262, 7.0, 8.1, 7.2],
...                    [6.5, 271, 6.3, 6.4, 6.1],
...                    [6.8, 228, 7.1, 7.2, 6.5]])
>>> weights = np.array([0.239, 0.225, 0.197, 0.186, 0.153])
>>> types = np.array([1, -1, 1, 1, 1])
>>> [round(preference, 3) for preference in body(matrix, weights, types)]
[0.143, 0.210, 0.164, 0.167, 0, 0.112]
class pymcdm.methods.PROBID

Bases: MCDA_method

Preference Ranking on the Basis of Ideal-Average Distance Method [15].

References

Examples

>>> matrix = np.array([
...     [1.679 * 10**6, 1.525 * 10**(-7), 3.747 * 10**(-5), 0.251, 2.917],
...     [2.213 * 10**6, 1.304 * 10**(-7), 3.250 * 10**(-5), 0.218, 6.633],
...     [2.461 * 10**6, 1.445 * 10**(-7), 3.854 * 10**(-5), 0.259, 0.553],
...     [2.854 * 10**6, 1.540 * 10**(-7), 3.970 * 10**(-5), 0.266, 1.597],
...     [3.107 * 10**6, 1.522 * 10**(-7), 3.779 * 10**(-5), 0.254, 2.905],
...     [3.574 * 10**6, 1.469 * 10**(-7), 3.297 * 10**(-5), 0.221, 6.378],
...     [3.932 * 10**6, 1.977 * 10**(-7), 3.129 * 10**(-5), 0.210, 11.381],
...     [4.383 * 10**6, 1.292 * 10**(-7), 3.142 * 10**(-5), 0.211, 9.929],
...     [4.988 * 10**6, 1.690 * 10**(-7), 3.767 * 10**(-5), 0.253, 8.459],
...     [5.497 * 10**6, 5.703 * 10**(-7), 3.012 * 10**(-5), 0.200, 18.918],
...     [5.751 * 10**6, 4.653 * 10**(-7), 3.017 * 10**(-5), 0.201, 17.517],
... ])
>>> weights = np.array([0.1819, 0.2131, 0.1838, 0.1832, 0.2379])
>>> types = np.array([1, -1, -1, -1, -1])
>>> pr = methods.PROBID()
>>> pref = np.round(pr(matrix, weights, types), 4)
>>> print(pref)
[0.8568, 0.7826, 0.9362, 0.9369, 0.9379, 0.8716, 0.5489, 0.7231, 0.7792, 0.3331, 0.3387]
class pymcdm.methods.PROMETHEE_II(preference_function, p=None, q=None)

Bases: PROMETHEE_I

Preference Ranking Organization Method for Enrichment of Evaluations II (PROMETHEE II) method.

The PROMETHEE II method is based on a pairwise comparison of alternatives given a preference function [16].

Parameters:
  • preference_function (str) – Name of the preference function (‘usual’, ‘ushape’, ‘vshape’, ‘level’, ‘vshape_2’)

  • p (ndarray or list) – p values for each criterion. Can be either float values or function. If function, p value will be calculated based on difference table.

  • q (ndarray or list) – q values for each criterion. Can be either float values or function. If function, q value will be calculated based on difference table.

References

Examples

>>> from pymcdm.methods import PROMETHEE_II
>>> import numpy as np
>>> body = PROMETHEE_II('usual')
>>> matrix =  np.array([[4, 3, 2],
...                     [3, 2, 4],
...                     [5, 1, 3]])
>>> weights = np.array([0.5, 0.3, 0.2])
>>> types = np.ones(3)
>>> [round(preference, 2) for preference in body(matrix, weights, types)]
[0.1, -0.3, 0.2]
class pymcdm.methods.RAM(normalization_function=<function sum_normalization>)

Bases: MCDA_method

Root Assessment Method (RAM) [17].

Parameters:

normalization_function (Callable) – Function which should be used to normalize matrix columns. It should match signature foo(x, cost), where x is a vector which should be normalized and cost is a bool variable which says if x is a cost or profit criterion.

References

Examples

>>> import numpy as np
>>> from pymcdm.methods import RAM
>>> matrix = np.array([
...     [0.068, 0.066, 0.150, 0.098, 0.156, 0.114, 0.098],
...     [0.078, 0.076, 0.108, 0.136, 0.082, 0.171, 0.105],
...     [0.157, 0.114, 0.128, 0.083, 0.108, 0.113, 0.131],
...     [0.106, 0.139, 0.058, 0.074, 0.132, 0.084, 0.120],
...     [0.103, 0.187, 0.125, 0.176, 0.074, 0.064, 0.057],
...     [0.105, 0.083, 0.150, 0.051, 0.134, 0.094, 0.113],
...     [0.137, 0.127, 0.056, 0.133, 0.122, 0.119, 0.114],
...     [0.100, 0.082, 0.086, 0.060, 0.062, 0.109, 0.093],
...     [0.053, 0.052, 0.043, 0.100, 0.050, 0.078, 0.063],
...     [0.094, 0.074, 0.097, 0.087, 0.080, 0.054, 0.106]
... ])
>>> weights = np.array([0.132, 0.135, 0.138, 0.162, 0.09, 0.223, 0.12])
>>> types = np.array([1, -1, -1, 1, 1, 1, 1])
>>> ram = RAM()
>>> output_method = ram(matrix, weights, types)
>>> output_method = np.round(output_method, 4)
>>> print(output_method)
[1.4332 1.4392 1.4353 1.4322 1.4279 1.4301 1.4394 1.4308 1.4294 1.4288]
class pymcdm.methods.RIM(bounds: ndarray | list | tuple, ref_ideal: ndarray | list | tuple = None)

Bases: MCDA_method

Reference Ideal Method [18].

RIM is an MCDA method which uses criteria bounds and reference ideal to evaluate alternatives.

References

Examples

>>> import numpy as np
>>> from pymcdm.methods import RIM
>>> matrix = np.array([
...     [30,  0, 2, 3, 3, 2],
...     [40,  9, 1, 3, 2, 2],
...     [25,  0, 3, 1, 3, 2],
...     [27,  0, 5, 3, 3, 1],
...     [45, 15, 2, 2, 3, 4]
... ])
>>> weights = np.array([0.2262, 0.2143, 0.1786, 0.1429, 0.1190, 0.1190])
>>> types = np.array([1, 1, -1, 1, 1, 1])
>>> range_t = np.array([
...      [23, 60],
...      [0, 15],
...      [0, 10],
...      [1, 3],
...      [1, 3],
...      [1, 5]
...  ])
>>>  ref_s = [
...      [30, 35],
...      [10, 15],
...      [0, 0],
...      [3, 3],
...      [3, 3],
...      [4, 5]
...  ]
>>>  pr = RIM(range_t, ref_s)
>>>  pref = pr(matrix, weights, types)
>>>  rank = pr.rank(pref)
>>>  print(pref)
...  [0.5866 0.7558 0.3716 0.4666 0.7401]
>>>  print(rank)
...  [3. 1. 5. 4. 2.]
get_ideal_from_bounds(bounds, types)
class pymcdm.methods.SPOTIS(bounds, esp=None)

Bases: MCDA_method

Stable Preference Ordering Towards Ideal Solution (SPOTIS) method.

The SPOTIS method is based on an approach in which it evaluates given decision alternatives using the distance from the best ideal solution. [19].

Read more in the User Guide.

References

Examples

>>> from pymcdm.methods import SPOTIS
>>> import numpy as np
>>> matrix = np.array([[10.5, -3.1, 1.7],
...                    [-4.7, 0, 3.4],
...                    [8.1, 0.3, 1.3],
...                    [3.2, 7.3, -5.3]])
>>> bounds = np.array([[-5, 12],
...                    [-6, 10],
...                    [-8, 5]], dtype=float)
>>> weights = np.array([0.2, 0.3, 0.5])
>>> types = np.array([1, -1, 1])
>>> body = SPOTIS(bounds)
>>> [round(preference, 4) for preference in body(matrix, weights, types)]
[0.1989, 0.3705, 0.3063, 0.7491]
static make_bounds(matrix)

Returns bounds matrix for each criterion, e.g. extract min and max for each criterion values.

Parameters:

matrix (ndarray) – Decision matrix. Alternatives are in rows and Criteria are in columns.

Returns:

bounds – Min and max values (bounds) for each criterion.

Return type:

ndarray

Examples

>>> import numpy as np
>>> from pymcdm.methods import SPOTIS
>>> matrix = np.array([[ 96, 145, 200],
                       [100, 145, 200],
                       [120, 170,  80],
                       [140, 180, 140],
                       [100, 110,  30]])
>>> types = np.ones(3)
>>> weights = np.ones(3)/3
>>> body = SPOTIS()
>>> preferences = body(matrix, weights, types, bounds=bounds)
>>> np.round(preferences, 4)
array([0.5   , 0.4697, 0.4344, 0.1176, 0.9697])
class pymcdm.methods.TOPSIS(normalization_function=<function minmax_normalization>)

Bases: MCDA_method

Technique for Order of Preference by Similarity to Ideal Solution (TOPSIS).

The TOPSIS method is based on an approach in which it evaluates alternatives to a positive ideal solution and a negative ideal solution [20].

Parameters:

normalization_function (Callable) – Function which should be used to normalize matrix columns. It should match signature foo(x, cost), where x is a vector which should be normalized and cost is a bool variable which says if x is a cost or profit criterion.

References

Examples

>>> from pymcdm.methods import TOPSIS
>>> import numpy as np
>>> body = TOPSIS()
>>> matrix = np.array([[1, 2, 5],
...                     3000, 3750, 4500]]).T
>>> weights = np.array([0.5, 0.5])
>>> types = np.array([-1, 1])
>>> [round(preference, 3) for preference in body(matrix, weights, types)]
[0.500, 0.617, 0.500]
class pymcdm.methods.VIKOR(normalization_function=None, v=0.5)

Bases: MCDA_method

VIšekriterijumsko KOmpromisno Rangiranje (VIKOR) method.

The VIKOR method is based on an approach that uses a compromise mechanism to evaluate alternatives using distance from the ideal [21].

Parameters:

normalization_function (None or callable) – Function which should be used to normalize matrix columns. It should match signature foo(x, cost), where x is a vector which should be normalized and cost is a bool variable which says if x is a cost or profit criterion.

References

Examples

>>> from pymcdm.methods import VIKOR
>>> import numpy as np
>>> body = VIKOR()
>>> matrix = np.array([[78, 56, 34, 6],
...                    [4, 45, 3, 97],
...                    [18, 2, 50, 63],
...                    [9, 14, 11, 92],
...                    [85, 9, 100, 29]])
>>> weights = np.array([0.25, 0.25, 0.25, 0.25])
>>> types = np.array([1, 1, 1, 1])
>>> [round(preference, 4) for preference in body(matrix, weights, types)]
[0.5679, 0.7667, 1, 0.7493, 0]
class pymcdm.methods.WASPAS(normalization_function=<function linear_normalization>, l=0.5)

Bases: MCDA_method

Weighted Aggregated Sum Product ASSessment (WASPAS) [22].

The WASPAS method is a unique combination of two well-known MCDM approaches, i.e. Weighted Sum Model (WSM) and Weighted Product Model (WPM).

Parameters:

normalization_function (callable) – Function which should be used to normalize matrix columns. It should match signature foo(x, cost), where x is a vector which should be normalized and cost is a bool variable which says if x is a cost or profit criterion.

References

Examples

>>> from pymcdm.methods import WASPAS
>>> import numpy as np
>>> body = WASPAS()
>>> matrix = np.array([[30, 23, 5, 0.745, 0.745, 1500, 5000],
...                    [18, 13, 15, 0.745, 0.745, 1300, 6000],
...                    [15, 12, 10, 0.500, 0.500, 950, 7000],
...                    [25, 20, 13, 0.745, 0.745, 1200, 4000],
...                    [14, 18, 14, 0.255, 0.745, 950, 3500],
...                    [17, 15, 9, 0.745, 0.500, 1250, 5250],
...                    [23, 18, 20, 0.500, 0.745, 1100, 3000],
...                    [16, 8, 14, 0.255, 0.500, 1500, 3000]])
>>> weights = np.array([0.1181, 0.1181, 0.0445, 0.1181, 0.2861, 0.2861, 0.0445])
>>> types = np.array([1, 1, 1, 1, 1, -1, -1])
>>> [round(preference, 3) for preference in body(matrix, weights, types)]
[0.8329, 0.7884, 0.6987, 0.8831, 0.7971, 0.7036, 0.8728, 0.5749]
class pymcdm.methods.WPM(normalization_function=<function sum_normalization>)

Bases: MCDA_method

Weighted Product Model (WPM) [23].

WPM is based on an approach that evaluates alternatives by weighted product.

Parameters:

normalization_function (callable) – Function which should be used to normalize matrix columns. It should match signature foo(x, cost), where x is a vector which should be normalized and cost is a bool variable which says if x is a cost or profit criterion.

References

Examples

>>> from pymcdm.methods import WPM
>>> import numpy as np
>>> body = WPM()
>>> matrix = np.array([[96, 83, 75, 7],
...                    [63, 5, 56, 9],
...                    [72, 30, 32, 48],
...                    [11, 4, 27, 9],
...                    [77, 21, 17, 11]])
>>> weights = np.array([8/13, 5/13, 6/13, 7/13])
>>> types = np.array([1, 1, -1, -1])
>>> [round(preference, 3) for preference in body(matrix, weights, types)]
[0.065, 0.017, 0.019, 0.007, 0.052]
class pymcdm.methods.WSM(normalization_function=<function sum_normalization>)

Bases: MCDA_method

Weighted Sum Model (WSM) [24].

WSM is based on an approach that evaluates alternatives by weighted sum.

Parameters:

normalization_function (callable) – Function which should be used to normalize matrix columns. It should match signature foo(x, cost), where x is a vector which should be normalized and cost is a bool variable which says if x is a cost or profit criterion.

References

Examples

>>> from pymcdm.methods import WSM
>>> import numpy as np
>>> body = WSM()
>>> matrix = np.array([[96, 83, 75, 7],
...                    [63, 5, 56, 9],
...                    [72, 30, 32, 48],
...                    [11, 4, 27, 9],
...                    [77, 21, 17, 11]])
>>> weights = np.array([8/13, 5/13, 6/13, 7/13])
>>> types = np.array([1, 1, -1, -1])
>>> [round(preference, 3) for preference in body(matrix, weights, types)]
[0.609, 0.313, 0.334, 0.265, 0.479]
class pymcdm.methods.mcda_method.MCDA_method

Bases: ABC

__call__(matrix: ndarray | list | tuple, weights: ndarray | list | tuple, types: ndarray | list | tuple, validation: bool = True, verbose: bool = False)

Rank alternatives from decision matrix matrix, with criteria weights weights and criteria types types.

Parameters:
  • matrix (ndarray) – Decision matrix / alternatives data. Alternatives are in rows and Criteria are in columns.

  • weights (ndarray) – Criteria weights. Sum of the weights should be 1. (e.g. sum(weights) == 1)

  • types (ndarray) – Array with definitions of criteria types: 1 if criteria is profit and -1 if criteria is cost for each criteria in matrix.

  • validation (bool) – Enable or disable validation of the all input data. True - validation is enabled, False - validation is disabled. Default is True.

  • verbose (bool) – Explain the MCDA, i.e. provide matrices and vectors from all the steps of the method, instead of return just the preference vector. Default is False.

rank(a)

pymcdm.methods.comet_tools

class pymcdm.methods.comet_tools.CompromiseExpert(evaluation_functions, vote_limit=None)

Bases: object

Create an object which will rate characteristic objects (CO) using compromise of several preferences. If the CO is better in most of the preferences, than it is bigger in the final MEJ.

Parameters:
  • evaluation_functions (list[Callable]) – List of functions which will evaluate preferences of the characteristic objets. If you want to use MCDA methods, please use lambda or partial to provide weights and types to them.

  • vote_limit (float) – Vote limit decides the limit for the voting. If number of votes CO_i > CO_j are bigger then vote_limit, then in the final MEJ matrix CO_i > CO_j, otherwise CO_i < CO_j.

Examples

>>> # Compromise solution for 3 different weights vectors
>>> import numpy as np
>>> from pymcdm.methods import COMET, TOPSIS
>>> from pymcdm.methods.comet_tools import CompromiseExpert
>>> cvalues = [
...         [0, 500, 1000],
...         [1, 5],
...         [1, 3, 10],
...         ]
>>> types = np.ones(3)
>>> topsis = TOPSIS()
>>> evaluation_function = [
...         lambda co: topsis(co, np.array([0.2, 0.3, 0.5]), types),
...         lambda co: topsis(co, np.array([0.3, 0.4, 0.3]), types),
...         lambda co: topsis(co, np.array([0.1, 0.5, 0.4]), types),
...         ]
>>> expert_function = CompromiseExpert(evaluation_function)
>>> comet = COMET(cvalues, expert_function)
class pymcdm.methods.comet_tools.ESPExpert(esps, bounds, distance_function=None, distance_aggregation=<function min>, cvalues_psi=None, full_domain_psi=False)

Bases: object

Create an object which will rate characteristic objects using Expected Solution Points (ESPs) provided by an expert to rate the characteristic objects.

Parameters:
  • esps (ndarray) – Numpy 2d matrix which defines chosed Expected Solution Points. Each row should define one ESP, number of the colums should be equal to the number of criteria.

  • bounds (ndarray) – Each row should contain min and max values for each criterion. Min and max should be different values!

  • distance_function (Callable or None) – Function which will be used to calculate the distance between two numpy array a and b. Signature of the function is d(a, b). If None, ESPExpert._euclides function is used and the Euclides distance is calculated between vectors.

  • distance_aggregation (Callable) – Function which is used to aggregate distances to several ESP for each characteristic object. Default is np.min().

  • cvalues_psi (float or None) – Float in range (0, 1). This value determines location of the additional ESP-guided characteristic values. E.g. criteria domain bounds are [0, 10] and ESP is 3. Then if we chose psi = 0.2 we will get following characteristic values for such criterion: [0, 2.4, 3, 4.4, 10] (the psi part of the distance between bound and ESP is substracted and added).

  • full_domain_psi (bool) – Determines if additional characteristic values will be generated using full domain (True) or distance between ESP and bounds (False). E.g. if full_domain_psi=True, criteria domain bounds are [0, 10] and ESP is 3. If we chose psi = 0.2 we will get following characteristic values for such criterion: [0, 1, 3, 5, 10] (the psi part of the distance between all domain is substracted and added).

Examples

>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> import pymcdm as pm
>>> # Define criteria bounds for the decision problem
>>> bounds = np.array([[0, 1]] * 2, dtype=float)
>>> # Define the Expected Solution Point (or Points) for this problem
>>> esps = np.array([[0.4, 0.4]])
>>> # Create the expert function using ESPExpert class
>>> expert = pm.methods.comet_tools.ESPExpert(esps,
...                                           bounds,
...                                           cvalues_psi=0.2)
>>> # Generate ESP-guided cvalues based on provided ESP and psi
>>> cvalues = expert.make_cvalues()
>>> # Create and identify COMET model
>>> comet = pm.methods.COMET(cvalues, expert)
>>> # Create a visualization of the characteriscic values,
>>> # ESP and preference function
>>> fig, ax = plt.subplots(figsize=(4, 3.5), dpi=200)
>>> ax, cax = pm.visuals.comet_2d_esp_plot(comet, esps, bounds)
>>> plt.tight_layout()
>>> plt.show()
__call__(co)

Evaluate characteristic objects using provided expected solution points.

Parameters:

co (np.array) – Characteristic objects which should be compared.

Returns:

  • sj (np.array) – SJ vector (see the COMET procedure for more info).

  • mej (np.array) – Identified MEJ matrix.

make_cvalues()

Generate the characteristic values array based on provided ESPs and psi values. Usually using COMET with such cvalues will provide better results, however it is not mandatory.

Returns:

cvalues – Characteristic values created based on ESPs and psi.

Return type:

np.array

class pymcdm.methods.comet_tools.FunctionExpert(expert_function)

Bases: object

Create an object which will rate characteristic objects using expert function.

Parameters:

expert_function (Callable) – Function with a signature (co_i, co_j) -> float. If co_i < co_j this function should return 0.0. If co_i == co_j this function should return 0.5. If co_i > co_j this function should return 1.0.

__call__(co)

Evaluate characteristic objects using provided expert function.

Parameters:

co (np.array) – Characteristic objects which should be compared.

Returns:

  • sj (np.array) – SJ vector (see the COMET procedure for more info).

  • mej (None) – Because of how this method works MEJ matrix is not generated.

class pymcdm.methods.comet_tools.ManualExpert(criteria_names, show_MEJ=False, tablefmt='simple_grid', filename='mej.csv', force_file_use=False)

Bases: object

Create object of the ManualExpert expert function which allows to manually identify Matrix of Expert Judgements (MEJ).

Parameters:
  • criteria_names (list[str]) – Criteria names which would be used during the procedure of the MEJ identification.

  • show_MEJ (bool) – If MEJ should be shown after each question answered. Default is False.

  • tablefmt (str) – tablefmt argument for the tablulate function. See tabulate documentation for more info. Default is ‘simple_grid’.

  • filename (str or None) – Path to the file in which identified save should be saved. If None, MEJ will be not saved. If file exists, MEJ will be loaded from this file. Default is ‘mej.csv’.

Examples

>>> import numpy as np
>>> from pymcdm.methods import COMET
>>> from pymcdm.methods.comet_tools import ManualExpert
>>> cvalues = [
...     [0, 500, 1000],
...     [1, 5]
...     ]
>>> expert_function = ManualExpert(
...     criteria_names=['Price [$]', 'Profit [grade]'],
...     show_MEJ=True
...     )
>>> # You will prompted to evaluate all CO
>>> comet = COMET(cvalues, expert_function)
__call__(characteristic_objects)

Evaluate characteristic objects by asking pairwise comparison questions.

Parameters:

characteristic_objects (np.array) – Characteristic objects which should be compared.

Returns:

  • sj (np.array) – SJ vector (see the COMET procedure for more info).

  • mej (np.array) – MEJ matrix created by comparisons (see the COMET procedure for more info).

class pymcdm.methods.comet_tools.MethodExpert(method, weights, types)

Bases: object

Create an object which will rate characteristic objects with any MCDA method.

Parameters:
  • method (MCDA_Method) – Any object of the MCDA method inherited from MCDA_Method.

  • weights (ndarray) – Criteria weights. Sum of the weights should be 1. (e.g. sum(weights) == 1)

  • types (ndarray) – Array with definitions of criteria types: 1 if criteria is profit and -1 if criteria is cost for each criteria in matrix.

Examples

>>> import numpy as np
>>> from pymcdm.methods import COMET, TOPSIS
>>> from pymcdm.methods.comet_tools import MethodExpert
>>> cvalues = [
...     [0, 500, 1000],
...     [1, 5]
...     ]
>>> weights = np.array([0.5, 0.5])
>>> types = np.array([-1, 1])
>>> expert_function = MethodExpert(TOPSIS(), weights, types)
>>> comet = COMET(cvalues, expert_function)
__call__(co)

Evaluate characteristic objects using provided MCDA method.

Parameters:

co (np.array) – Characteristic objects which should be compared.

Returns:

  • sj (np.array) – SJ vector (see the COMET procedure for more info).

  • mej (None) – Because of how this method works MEJ matrix is not generated.

class pymcdm.methods.comet_tools.StructuralCOMET(submodels, cvalues, criteria_names=None)

Bases: MCDA_method

Create Structural COMET model with defined structure [25].

Parameters:
  • submodels (list of Submodel objects) – List of the submodels which defines structure of the model. See example for more details.

  • cvalues (list of lists) – Characteristic values for criteria.

  • criteria_names (list or None) – Names of the criteria

References

Examples

See examples/comet_tool_examples.ipynb for example with explanation.

__call__(matrix, weights=None, types=None, validation=False, verbose=False)

Rank alternatives from decision matrix matrix.

Parameters:
  • matrix (ndarray) – Decision matrix / alternatives data. Alternatives are in rows and Criteria are in columns.

  • weights (None) – Not used in the StructuralCOMET method.

  • types (None) – Not used in the StructuralCOMET method.

  • validation (bool) – Not used in the StructuralCOMET method.

  • verbose (bool) – If explained_call is True, then results of all submodels will be returned.

all_to_names(structure)
all_to_structures(structure)
class pymcdm.methods.comet_tools.Submodel(structure, cvalues, expert_function, name)

Bases: object

Create object of the COMET submodel. This class is mostly for internal use in the StructuralCOMET class or for creating StructuralCOMET object.

Parameters:
  • structure (tuple or int) – Structure of the submodel. Refer to the single criteria by names (str) or by indexes (int). If structure is more complex use defined names or nested structures. See example use of StructuralCOMET for more information.

  • cvalues (list or None) – Cvalues for output of this submodel. Pass None if it is a final model to be evaluated.

  • expert_function (Callable or None) – Expert function to evaluate characteristic objects in the submodel. See COMET documentation for more information. None is reserved for internal use in StructuralCOMET class.

  • name (str or None) – Name (alias) of the Submodel. If name is not None Submodel could be referred by it in another Submodel in one StructuralCOMET model.

build(submodels)
class pymcdm.methods.comet_tools.TriadSupportExpert(criteria_names, show_MEJ=False, tablefmt='simple_grid', filename='mej.csv', force_file_use=False)

Bases: ManualExpert

Create object of the TriadSupportExpert expert function which allows to manually identify Matrix of Expert Judgements (MEJ), but with the support of the consistent triads.

Parameters:
  • criteria_names (list[str]) – Criteria names which would be used during the procedure of the MEJ identification.

  • show_MEJ (bool) – If MEJ should be shown after each question answered. Default is False.

  • tablefmt (str) – tablefmt argument for the tablulate function. See tabulate documentation for more info. Default is ‘simple_grid’.

  • filename (str or None) – Path to the file in which identified save should be saved. If None, MEJ will be not saved. If file exists, MEJ will be loaded from this file. Default is ‘mej.csv’.

Examples

>>> import numpy as np
>>> from pymcdm.methods import COMET
>>> from pymcdm.methods.comet_tools import TriadSupportExpert
>>> cvalues = [
...     [0, 500, 1000],
...     [1, 5]
...     ]
>>> expert_function = TriadSupportExpert(
...     criteria_names=['Price [$]', 'Profit [grade]'],
...     show_MEJ=True
...     )
>>> # You will prompted to evaluate some of the CO and
>>> # other CO will be completed using consistent triads.
>>> comet = COMET(cvalues, expert_function)
pymcdm.methods.comet_tools.get_local_weights(comet, alt, percent_step=0.01)

Calculates local weights for alternative alt for each criterion using the algorithm presented in [26] and [27].

Parameters:
  • comet (COMET) – Identified COMET object to evaluate alternatives.

  • alt (np.ndarray) – Single alternative in form of 1d numpy array.

  • percent_step (float, optional) – Step for changing values in alternative for different criteria (see [27]). Default is 0.01.

References

pymcdm.methods.comet_tools.triads_consistency(comet_or_mej)

MEJ consistency coefficient based on inconsistence triads [28].

Parameters:

comet_or_mej (COMET or np.array) – Either identified COMET method object or MEJ matrix from it.

Return type:

Consistency coefficient value. See reference for details.

References

Examples

>>> import numpy as np
>>> from pymcdm.methods.comet_tools import triads_consistency
>>> mej = np.array([
...     [0.5, 0.0, 0.0, 1.0, 0.0, 1.0],
...     [1.0, 0.5, 0.0, 0.0, 0.0, 0.0],
...     [1.0, 1.0, 0.5, 0.0, 0.0, 0.0],
...     [0.0, 1.0, 1.0, 0.5, 0.0, 0.0],
...     [1.0, 1.0, 1.0, 1.0, 0.5, 0.0],
...     [0.0, 1.0, 1.0, 1.0, 1.0, 0.5]
... ])
>>> triads_consistency(mej)
0.75

pymcdm.methods.partial

class pymcdm.methods.partial.PROMETHEE_I(preference_function, p=None, q=None)

Bases: MCDA_method

Preference Ranking Organization Method for Enrichment of Evaluations I (PROMETHEE I) method.

The PROMETHEE I method is based on a pairwise comparison of alternatives given a preference function [29].

Parameters:
  • preference_function (str) – Name of the preference function (‘usual’, ‘ushape’, ‘vshape’, ‘level’, ‘vshape_2’)

  • p (ndarray or list) – p values for each criterion. Can be either float values or function. If function, p value will be calculated based on difference table.

  • q (ndarray or list) – q values for each criterion. Can be either float values or function. If function, q value will be calculated based on difference table.

References

Examples

>>> import numpy as np
>>> from pymcdm.methods.partial import PROMETHEE_I
>>> body = PROMETHEE_I('usual')
>>> matrix =  np.array([[4, 3, 2],
...                     [3, 2, 4],
...                     [5, 1, 3]])
>>> weights = np.array([0.5, 0.3, 0.2])
>>> types = np.ones(3)
>>> body(matrix, weights, types)
(array([0.55, 0.35, 0.6 ]), array([0.45, 0.65, 0.4 ]))