pymcdm.methods package

pymcdm.methods.aras

class pymcdm.methods.aras.ARAS(normalization_function=<function sum_normalization>)

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.

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]
__call__(matrix, weights, types, *args, **kwargs)

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.

  • *args (is necessary for methods which reqiure some additional data.) –

  • **kwargs (is necessary for methods which reqiure some additional data.) –

Returns:

Preference values for alternatives. Better alternatives have higher values.

Return type:

ndarray

pymcdm.methods.cocoso

class pymcdm.methods.cocoso.COCOSO(normalization_function=<function minmax_normalization>)

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 [1].

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]
__call__(matrix, weights, types, l=0.5, *args, **kwargs)

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.

  • l (value) – The value of balanced compromise. It must be from the interval [0, 1].

  • *args (is necessary for methods which reqiure some additional data.) –

  • **kwargs (is necessary for methods which reqiure some additional data.) –

Returns:

Preference values for alternatives. Better alternatives have higher values.

Return type:

ndarray

pymcdm.methods.codas

class pymcdm.methods.codas.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 [1].

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]
__call__(matrix, weights, types, *args, **kwargs)

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.

  • *args (is necessary for methods which reqiure some additional data.) –

  • **kwargs (is necessary for methods which reqiure some additional data.) –

Returns:

Preference values for alternatives. Better alternatives have higher values.

Return type:

ndarray

pymcdm.methods.comet

class pymcdm.methods.comet.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 [1]. 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.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__(alts, *args, **kwargs)

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

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

  • *args (is necessary for methods which reqiure some additional data.) –

  • **kwargs (is necessary for methods which reqiure some additional data.) –

Returns:

Preference values for alternatives. Better alternatives have higher values.

Return type:

ndarray

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.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])

pymcdm.methods.copras

class pymcdm.methods.copras.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 [1].

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)]
[1, 0.9167, 0.8675, 0.9084, 0.9315, 0.9486]
__call__(matrix, weights, types, *args, **kwargs)

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.

  • *args (is necessary for methods which reqiure some additional data.) –

  • **kwargs (is necessary for methods which reqiure some additional data.) –

Returns:

Preference values for alternatives. Better alternatives have higher values.

Return type:

ndarray

pymcdm.methods.edas

class pymcdm.methods.edas.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 [1].

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]
__call__(matrix, weights, types, *args, **kwargs)

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.

  • *args (is necessary for methods which reqiure some additional data.) –

  • **kwargs (is necessary for methods which reqiure some additional data.) –

Returns:

Preference values for alternatives. Better alternatives have higher values.

Return type:

ndarray

pymcdm.methods.ervd

class pymcdm.methods.ervd.ERVD(ref_point=None, lam=2.25, alpha=0.88)

Bases: MCDA_method

Election based on Relative Value Distances method.

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.]
__call__(matrix, weights, types, *args, **kwargs)

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.

  • *args (is necessary for methods which reqiure some additional data.) –

  • **kwargs (is necessary for methods which reqiure some additional data.) –

Returns:

Preference values for alternatives. Better alternatives have higher values.

Return type:

ndarray

pymcdm.methods.mabac

class pymcdm.methods.mabac.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).

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]
__call__(matrix, weights, types, *args, **kwargs)

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.

  • *args (is necessary for methods which reqiure some additional data.) –

  • **kwargs (is necessary for methods which reqiure some additional data.) –

Returns:

Preference values for alternatives. Better alternatives have higher values.

Return type:

ndarray

pymcdm.methods.mairca

class pymcdm.methods.mairca.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. 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]
__call__(matrix, weights, types, *args, **kwargs)

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.

  • *args (is necessary for methods which reqiure some additional data.) –

  • **kwargs (is necessary for methods which reqiure some additional data.) –

Returns:

Preference values for alternatives. Better alternatives have higher values.

Return type:

ndarray

reverse_ranking = False

pymcdm.methods.marcos

class pymcdm.methods.marcos.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 [1].

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]
__call__(matrix, weights, types, *args, **kwargs)

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.

  • *args (is necessary for methods which reqiure some additional data.) –

  • **kwargs (is necessary for methods which reqiure some additional data.) –

Returns:

Preference values for alternatives. Better alternatives have higher values.

Return type:

ndarray

pymcdm.methods.mcda_method

class pymcdm.methods.mcda_method.MCDA_method

Bases: ABC

__call__(matrix, weights, types, *args, **kwargs)

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.

  • *args (is necessary for methods which reqiure some additional data.) –

  • **kwargs (is necessary for methods which reqiure some additional data.) –

rank(a)
reverse_ranking = True

pymcdm.methods.moora

class pymcdm.methods.moora.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.

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]
__call__(matrix, weights, types, *args, **kwargs)

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.

  • *args (is necessary for methods which reqiure some additional data.) –

  • **kwargs (is necessary for methods which reqiure some additional data.) –

Returns:

Preference values for alternatives. Better alternatives have higher values.

Return type:

ndarray

pymcdm.methods.ocra

class pymcdm.methods.ocra.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 [1].

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]
__call__(matrix, weights, types, *args, **kwargs)

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.

  • *args (is necessary for methods which reqiure some additional data.) –

  • **kwargs (is necessary for methods which reqiure some additional data.) –

Returns:

Preference values for alternatives. Better alternatives have higher values.

Return type:

ndarray

pymcdm.methods.probid

class pymcdm.methods.probid.PROBID(sPROBID=False)

Bases: MCDA_method

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

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]
__call__(matrix, weights, types, *args, **kwargs)

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.

  • *args (is necessary for methods which reqiure some additional data.) –

  • **kwargs (is necessary for methods which reqiure some additional data.) –

Returns:

Preference values for alternatives. Better alternatives have higher values.

Return type:

ndarray

pymcdm.methods.promethee

class pymcdm.methods.promethee.PROMETHEE_II(preference_function)

Bases: MCDA_method

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 [1].

Parameters:

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

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]
__call__(matrix, weights, types, *args, p=None, q=None, promethee_I=False, **kwargs)

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.

  • p (ndarray) – p values for each criterion

  • q (ndarray) – q values for each criterion

  • promethee_I (bool) – If True then returns F+ and F- (like in promethee I).

  • *args (is necessary for methods which reqiure some additional data.) –

  • **kwargs (is necessary for methods which reqiure some additional data.) –

Returns:

  • If promethee_I is True

  • ndarray – Positive flow

  • ndarray – Negative flow

  • If promethee_I is False

  • ndarray – Preference values of alternatives. Better alternatives have higher values.

pymcdm.methods.rim

class pymcdm.methods.rim.RIM(bounds, ref_ideal=None)

Bases: MCDA_method

Reference Ideal Method

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.]
__call__(matrix, weights, types, *args, **kwargs)

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.

  • *args (is necessary for methods which reqiure some additional data.) –

  • **kwargs (is necessary for methods which reqiure some additional data.) –

Returns:

Preference values for alternatives. Better alternatives have higher values.

Return type:

ndarray

get_ideal_from_bounds(bounds, types)

pymcdm.methods.spotis

class pymcdm.methods.spotis.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. [1].

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]
__call__(matrix, weights, types, *args, **kwargs)

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.

  • *args (is necessary for methods which reqiure some additional data.) –

  • **kwargs (is necessary for methods which reqiure some additional data.) –

Returns:

Preference values for alternatives. Better alternatives have smaller values.

Return type:

ndarray

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])
reverse_ranking = False

pymcdm.methods.topsis

class pymcdm.methods.topsis.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 [1].

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]
__call__(matrix, weights, types, *args, **kwargs)

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.

  • *args (is necessary for methods which reqiure some additional data.) –

  • **kwargs (is necessary for methods which reqiure some additional data.) –

Returns:

Preference values for alternatives. Better alternatives have higher values.

Return type:

ndarray

pymcdm.methods.vikor

class pymcdm.methods.vikor.VIKOR(normalization_function=None)

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 [1].

Parameters:

normalization_function – 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.

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]
__call__(matrix, weights, types, *args, v=0.5, return_all=False, **kwargs)

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.

  • v (float) – Weight of the strategy (see VIKOR algorithm explanation).

  • return_all (bool) – If True, all three ranking (S, R, Q) would be returned.

  • *args (is necessary for methods which reqiure some additional data.) –

  • **kwargs (is necessary for methods which reqiure some additional data.) –

Returns:

  • if return_all is False

  • ndarray – Q preference values for alternatives. Better alternatives have smaller values.

  • if reeturn_all is True

  • ndarray, ndarray, ndarray – S, R, Q preference values (see VIKOR algorithm explanation).

reverse_ranking = False

pymcdm.methods.waspas

class pymcdm.methods.waspas.WASPAS(normalization_function=<function linear_normalization>)

Bases: MCDA_method

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

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

aggregated sum product assessment. Elektronika ir elektrotechnika, 122(6), 3-6.

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]
__call__(matrix, weights, types, l=0.5, *args, **kwargs)

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.

  • l (value) – Dominance parameter: if the value used is 0 the model obtained is a WPM model, if the value used is 1 the model obtained is a WSM model.

  • *args (is necessary for methods which reqiure some additional data.) –

  • **kwargs (is necessary for methods which reqiure some additional data.) –

Returns:

Preference values for alternatives. Better alternatives have higher values.

Return type:

ndarray

pymcdm.methods.wpm

class pymcdm.methods.wpm.WPM(normalization_function=<function sum_normalization>)

Bases: MCDA_method

Weighted Product Model (WPM) [1].

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

estimation errors: A reexamination. Operations Research, 16(2), 254-267.

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]
__call__(matrix, weights, types, *args, **kwargs)

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.

  • *args (is necessary for methods which reqiure some additional data.) –

  • **kwargs (is necessary for methods which reqiure some additional data.) –

Returns:

Preference values for alternatives. Better alternatives have higher values.

Return type:

ndarray

pymcdm.methods.wsm

class pymcdm.methods.wsm.WSM(normalization_function=<function sum_normalization>)

Bases: MCDA_method

Weighted Sum Model (WSM) [1].

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

estimation errors: A reexamination. Operations Research, 16(2), 254-267.

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]
__call__(matrix, weights, types, *args, **kwargs)

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.

  • *args (is necessary for methods which reqiure some additional data.) –

  • **kwargs (is necessary for methods which reqiure some additional data.) –

Returns:

Preference values for alternatives. Better alternatives have higher values.

Return type:

ndarray