pyfdm 1.0.1__zip

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. Program Files/Lib/site-packages/pyfdm/__init__.py +4 -0
  2. Program Files/Lib/site-packages/pyfdm/__pycache__/__init__.cpython-310.pyc +0 -0
  3. Program Files/Lib/site-packages/pyfdm/__pycache__/correlations.cpython-310.pyc +0 -0
  4. Program Files/Lib/site-packages/pyfdm/__pycache__/helpers.cpython-310.pyc +0 -0
  5. Program Files/Lib/site-packages/pyfdm/__pycache__/weights.cpython-310.pyc +0 -0
  6. Program Files/Lib/site-packages/pyfdm/correlations.py +92 -0
  7. Program Files/Lib/site-packages/pyfdm/helpers.py +62 -0
  8. Program Files/Lib/site-packages/pyfdm/methods/__init__.py +11 -0
  9. Program Files/Lib/site-packages/pyfdm/methods/__pycache__/__init__.cpython-310.pyc +0 -0
  10. Program Files/Lib/site-packages/pyfdm/methods/__pycache__/f_aras.cpython-310.pyc +0 -0
  11. Program Files/Lib/site-packages/pyfdm/methods/__pycache__/f_codas.cpython-310.pyc +0 -0
  12. Program Files/Lib/site-packages/pyfdm/methods/__pycache__/f_copras.cpython-310.pyc +0 -0
  13. Program Files/Lib/site-packages/pyfdm/methods/__pycache__/f_edas.cpython-310.pyc +0 -0
  14. Program Files/Lib/site-packages/pyfdm/methods/__pycache__/f_mabac.cpython-310.pyc +0 -0
  15. Program Files/Lib/site-packages/pyfdm/methods/__pycache__/f_mairca.cpython-310.pyc +0 -0
  16. Program Files/Lib/site-packages/pyfdm/methods/__pycache__/f_moora.cpython-310.pyc +0 -0
  17. Program Files/Lib/site-packages/pyfdm/methods/__pycache__/f_ocra.cpython-310.pyc +0 -0
  18. Program Files/Lib/site-packages/pyfdm/methods/__pycache__/f_topsis.cpython-310.pyc +0 -0
  19. Program Files/Lib/site-packages/pyfdm/methods/__pycache__/f_vikor.cpython-310.pyc +0 -0
  20. Program Files/Lib/site-packages/pyfdm/methods/__pycache__/validator.cpython-310.pyc +0 -0
  21. Program Files/Lib/site-packages/pyfdm/methods/aras/__init__.py +1 -0
  22. Program Files/Lib/site-packages/pyfdm/methods/aras/__pycache__/__init__.cpython-310.pyc +0 -0
  23. Program Files/Lib/site-packages/pyfdm/methods/aras/__pycache__/fuzzy.cpython-310.pyc +0 -0
  24. Program Files/Lib/site-packages/pyfdm/methods/aras/fuzzy.py +50 -0
  25. Program Files/Lib/site-packages/pyfdm/methods/codas/__init__.py +1 -0
  26. Program Files/Lib/site-packages/pyfdm/methods/codas/__pycache__/__init__.cpython-310.pyc +0 -0
  27. Program Files/Lib/site-packages/pyfdm/methods/codas/__pycache__/fuzzy.cpython-310.pyc +0 -0
  28. Program Files/Lib/site-packages/pyfdm/methods/codas/fuzzy.py +92 -0
  29. Program Files/Lib/site-packages/pyfdm/methods/copras/__init__.py +1 -0
  30. Program Files/Lib/site-packages/pyfdm/methods/copras/__pycache__/__init__.cpython-310.pyc +0 -0
  31. Program Files/Lib/site-packages/pyfdm/methods/copras/__pycache__/fuzzy.cpython-310.pyc +0 -0
  32. Program Files/Lib/site-packages/pyfdm/methods/copras/fuzzy.py +54 -0
  33. Program Files/Lib/site-packages/pyfdm/methods/edas/__init__.py +1 -0
  34. Program Files/Lib/site-packages/pyfdm/methods/edas/__pycache__/__init__.cpython-310.pyc +0 -0
  35. Program Files/Lib/site-packages/pyfdm/methods/edas/__pycache__/fuzzy.cpython-310.pyc +0 -0
  36. Program Files/Lib/site-packages/pyfdm/methods/edas/fuzzy.py +80 -0
  37. Program Files/Lib/site-packages/pyfdm/methods/f_aras.py +47 -0
  38. Program Files/Lib/site-packages/pyfdm/methods/f_codas.py +59 -0
  39. Program Files/Lib/site-packages/pyfdm/methods/f_copras.py +47 -0
  40. Program Files/Lib/site-packages/pyfdm/methods/f_edas.py +47 -0
  41. Program Files/Lib/site-packages/pyfdm/methods/f_mabac.py +52 -0
  42. Program Files/Lib/site-packages/pyfdm/methods/f_mairca.py +52 -0
  43. Program Files/Lib/site-packages/pyfdm/methods/f_moora.py +47 -0
  44. Program Files/Lib/site-packages/pyfdm/methods/f_ocra.py +47 -0
  45. Program Files/Lib/site-packages/pyfdm/methods/f_topsis.py +52 -0
  46. Program Files/Lib/site-packages/pyfdm/methods/f_vikor.py +51 -0
  47. Program Files/Lib/site-packages/pyfdm/methods/fuzzy_sets/__init__.py +1 -0
  48. Program Files/Lib/site-packages/pyfdm/methods/fuzzy_sets/__pycache__/__init__.cpython-310.pyc +0 -0
  49. Program Files/Lib/site-packages/pyfdm/methods/fuzzy_sets/tfn/__init__.py +3 -0
  50. Program Files/Lib/site-packages/pyfdm/methods/fuzzy_sets/tfn/__pycache__/__init__.cpython-310.pyc +0 -0
  51. Program Files/Lib/site-packages/pyfdm/methods/fuzzy_sets/tfn/__pycache__/defuzzifications.cpython-310.pyc +0 -0
  52. Program Files/Lib/site-packages/pyfdm/methods/fuzzy_sets/tfn/__pycache__/distances.cpython-310.pyc +0 -0
  53. Program Files/Lib/site-packages/pyfdm/methods/fuzzy_sets/tfn/__pycache__/normalizations.cpython-310.pyc +0 -0
  54. Program Files/Lib/site-packages/pyfdm/methods/fuzzy_sets/tfn/defuzzifications.py +86 -0
  55. Program Files/Lib/site-packages/pyfdm/methods/fuzzy_sets/tfn/distances.py +173 -0
  56. Program Files/Lib/site-packages/pyfdm/methods/fuzzy_sets/tfn/normalizations.py +188 -0
  57. Program Files/Lib/site-packages/pyfdm/methods/mabac/__init__.py +1 -0
  58. Program Files/Lib/site-packages/pyfdm/methods/mabac/__pycache__/__init__.cpython-310.pyc +0 -0
  59. Program Files/Lib/site-packages/pyfdm/methods/mabac/__pycache__/fuzzy.cpython-310.pyc +0 -0
  60. Program Files/Lib/site-packages/pyfdm/methods/mabac/fuzzy.py +51 -0
  61. Program Files/Lib/site-packages/pyfdm/methods/mairca/__init__.py +1 -0
  62. Program Files/Lib/site-packages/pyfdm/methods/mairca/__pycache__/__init__.cpython-310.pyc +0 -0
  63. Program Files/Lib/site-packages/pyfdm/methods/mairca/__pycache__/fuzzy.cpython-310.pyc +0 -0
  64. Program Files/Lib/site-packages/pyfdm/methods/mairca/fuzzy.py +57 -0
  65. Program Files/Lib/site-packages/pyfdm/methods/moora/__init__.py +1 -0
  66. Program Files/Lib/site-packages/pyfdm/methods/moora/__pycache__/__init__.cpython-310.pyc +0 -0
  67. Program Files/Lib/site-packages/pyfdm/methods/moora/__pycache__/fuzzy.cpython-310.pyc +0 -0
  68. Program Files/Lib/site-packages/pyfdm/methods/moora/fuzzy.py +47 -0
  69. Program Files/Lib/site-packages/pyfdm/methods/ocra/__init__.py +1 -0
  70. Program Files/Lib/site-packages/pyfdm/methods/ocra/__pycache__/__init__.cpython-310.pyc +0 -0
  71. Program Files/Lib/site-packages/pyfdm/methods/ocra/__pycache__/fuzzy.cpython-310.pyc +0 -0
  72. Program Files/Lib/site-packages/pyfdm/methods/ocra/fuzzy.py +52 -0
  73. Program Files/Lib/site-packages/pyfdm/methods/topsis/__init__.py +1 -0
  74. Program Files/Lib/site-packages/pyfdm/methods/topsis/__pycache__/__init__.cpython-310.pyc +0 -0
  75. Program Files/Lib/site-packages/pyfdm/methods/topsis/__pycache__/fuzzy.cpython-310.pyc +0 -0
  76. Program Files/Lib/site-packages/pyfdm/methods/topsis/fuzzy.py +56 -0
  77. Program Files/Lib/site-packages/pyfdm/methods/validator.py +133 -0
  78. Program Files/Lib/site-packages/pyfdm/methods/vikor/__init__.py +1 -0
  79. Program Files/Lib/site-packages/pyfdm/methods/vikor/__pycache__/__init__.cpython-310.pyc +0 -0
  80. Program Files/Lib/site-packages/pyfdm/methods/vikor/__pycache__/fuzzy.cpython-310.pyc +0 -0
  81. Program Files/Lib/site-packages/pyfdm/methods/vikor/fuzzy.py +77 -0
  82. Program Files/Lib/site-packages/pyfdm/weights.py +100 -0
  83. Program Files/Lib/site-packages/pyfdm-1.0.1-py3.10.egg-info/PKG-INFO +196 -0
  84. Program Files/Lib/site-packages/pyfdm-1.0.1-py3.10.egg-info/SOURCES.txt +49 -0
  85. Program Files/Lib/site-packages/pyfdm-1.0.1-py3.10.egg-info/dependency_links.txt +1 -0
  86. Program Files/Lib/site-packages/pyfdm-1.0.1-py3.10.egg-info/requires.txt +2 -0
  87. Program Files/Lib/site-packages/pyfdm-1.0.1-py3.10.egg-info/top_level.txt +1 -0
@@ -0,0 +1,47 @@
1
+ # Copyright (c) 2022 Jakub Więckowski
2
+
3
+ from .edas.fuzzy import fuzzy
4
+ from .fuzzy_sets.tfn.defuzzifications import mean_defuzzification
5
+
6
+ from .validator import Validator
7
+
8
+
9
+ class fEDAS():
10
+ def __init__(self, defuzzify=mean_defuzzification):
11
+ """
12
+ Create fuzzy EDAS method object with mean defuzification function
13
+
14
+ Parameters
15
+ ----------
16
+ defuzzify: callable
17
+ Function used to defuzzify the TFN into crisp value
18
+
19
+ """
20
+
21
+ self.defuzzify = defuzzify
22
+
23
+ def __call__(self, matrix, weights, types):
24
+ """
25
+ Calculates the alternatives preferences
26
+
27
+ Parameters
28
+ ----------
29
+ matrix : ndarray
30
+ Decision matrix / alternatives data.
31
+ Alternatives are in rows and Criteria are in columns.
32
+
33
+ weights : ndarray
34
+ Vector of criteria weights in a crisp form
35
+
36
+ types : ndarray
37
+ Types of criteria, 1 profit, -1 cost
38
+
39
+ Returns
40
+ ----------
41
+ ndarray:
42
+ Preference calculated for alternatives. Greater values are placed higher in ranking
43
+ """
44
+ # validate data
45
+ Validator.fuzzy_validation(matrix, weights)
46
+
47
+ return fuzzy(matrix, weights, types, self.defuzzify).astype(float)
@@ -0,0 +1,52 @@
1
+ # Copyright (c) 2022 Jakub Więckowski
2
+
3
+ from .mabac.fuzzy import fuzzy
4
+ from .fuzzy_sets.tfn.defuzzifications import mean_defuzzification
5
+ from .fuzzy_sets.tfn.normalizations import minmax_normalization
6
+
7
+ from .validator import Validator
8
+
9
+
10
+ class fMABAC():
11
+ def __init__(self, normalization=minmax_normalization, defuzzify=mean_defuzzification):
12
+ """
13
+ Create fuzzy MAIRCA method object with minmax normalization and mean defuzzification functions
14
+
15
+ Parameters
16
+ ----------
17
+ normalization: callable
18
+ Function used to normalize the decision matrix
19
+
20
+ defuzzify: callable
21
+ Function used to defuzzify the TFN into crisp value
22
+
23
+ """
24
+
25
+ self.normalization = normalization
26
+ self.defuzzify = defuzzify
27
+
28
+ def __call__(self, matrix, weights, types):
29
+ """
30
+ Calculates the alternatives preferences
31
+
32
+ Parameters
33
+ ----------
34
+ matrix : ndarray
35
+ Decision matrix / alternatives data.
36
+ Alternatives are in rows and Criteria are in columns.
37
+
38
+ weights : ndarray
39
+ Vector of criteria weights in a crisp form
40
+
41
+ types : ndarray
42
+ Types of criteria, 1 profit, -1 cost
43
+
44
+ Returns
45
+ ----------
46
+ ndarray:
47
+ Preference calculated for alternatives. Greater values are placed higher in ranking
48
+ """
49
+ # validate data
50
+ Validator.fuzzy_validation(matrix, weights)
51
+
52
+ return fuzzy(matrix, weights, types, self.normalization, self.defuzzify).astype(float)
@@ -0,0 +1,52 @@
1
+ # Copyright (c) 2022 Jakub Więckowski
2
+
3
+ from .mairca.fuzzy import fuzzy
4
+ from .fuzzy_sets.tfn.normalizations import vector_normalization
5
+ from .fuzzy_sets.tfn.distances import vertex_distance
6
+
7
+ from .validator import Validator
8
+
9
+
10
+ class fMAIRCA():
11
+ def __init__(self, normalization=vector_normalization, distance=vertex_distance):
12
+ """
13
+ Create fuzzy MAIRCA method object with vector normalization and vertex distance functions
14
+
15
+ Parameters
16
+ ----------
17
+ normalization: callable
18
+ Function used to normalize the decision matrix
19
+
20
+ distance: callable
21
+ Function used to calculate distance between two Triangular Fuzzy Numbers
22
+
23
+ """
24
+
25
+ self.normalization = normalization
26
+ self.distance = distance
27
+
28
+ def __call__(self, matrix, weights, types):
29
+ """
30
+ Calculates the alternatives preferences
31
+
32
+ Parameters
33
+ ----------
34
+ matrix : ndarray
35
+ Decision matrix / alternatives data.
36
+ Alternatives are in rows and Criteria are in columns.
37
+
38
+ weights : ndarray
39
+ Vector of criteria weights in a crisp form
40
+
41
+ types : ndarray
42
+ Types of criteria, 1 profit, -1 cost
43
+
44
+ Returns
45
+ ----------
46
+ ndarray:
47
+ Preference calculated for alternatives. Greater values are placed higher in ranking
48
+ """
49
+ # validate data
50
+ Validator.fuzzy_validation(matrix, weights)
51
+
52
+ return fuzzy(matrix, weights, types, self.normalization, self.distance).astype(float)
@@ -0,0 +1,47 @@
1
+ # Copyright (c) 2022 Jakub Więckowski
2
+
3
+ from .moora.fuzzy import fuzzy
4
+ from .fuzzy_sets.tfn.normalizations import vector_normalization
5
+
6
+ from .validator import Validator
7
+
8
+
9
+ class fMOORA():
10
+ def __init__(self, normalization=vector_normalization):
11
+ """
12
+ Create fuzzy MOORA method object with vector normalization function
13
+
14
+ Parameters
15
+ ----------
16
+ normalization: callable
17
+ Function used to normalize the decision matrix
18
+
19
+ """
20
+
21
+ self.normalization = normalization
22
+
23
+ def __call__(self, matrix, weights, types):
24
+ """
25
+ Calculates the alternatives preferences
26
+
27
+ Parameters
28
+ ----------
29
+ matrix : ndarray
30
+ Decision matrix / alternatives data.
31
+ Alternatives are in rows and Criteria are in columns.
32
+
33
+ weights : ndarray
34
+ Vector of criteria weights in a crisp form
35
+
36
+ types : ndarray
37
+ Types of criteria, 1 profit, -1 cost
38
+
39
+ Returns
40
+ ----------
41
+ ndarray:
42
+ Preference calculated for alternatives. Greater values are placed higher in ranking
43
+ """
44
+ # validate data
45
+ Validator.fuzzy_validation(matrix, weights, types)
46
+
47
+ return fuzzy(matrix, weights, types, self.normalization).astype(float)
@@ -0,0 +1,47 @@
1
+ # Copyright (c) 2022 Jakub Więckowski
2
+
3
+ from .ocra.fuzzy import fuzzy
4
+ from .fuzzy_sets.tfn.defuzzifications import mean_defuzzification
5
+
6
+ from .validator import Validator
7
+
8
+
9
+ class fOCRA():
10
+ def __init__(self, defuzzify=mean_defuzzification):
11
+ """
12
+ Creates fuzzy OCRA method object with mean defuzzification function
13
+
14
+ Parameters
15
+ ----------
16
+ defuzzify: callable
17
+ Function used to defuzzify the TFN into crisp value
18
+
19
+ """
20
+
21
+ self.defuzzify = defuzzify
22
+
23
+ def __call__(self, matrix, weights, types):
24
+ """
25
+ Calculates the alternatives preferences
26
+
27
+ Parameters
28
+ ----------
29
+ matrix : ndarray
30
+ Decision matrix / alternatives data.
31
+ Alternatives are in rows and Criteria are in columns.
32
+
33
+ weights : ndarray
34
+ Vector of criteria weights in a crisp form
35
+
36
+ types : ndarray
37
+ Types of criteria, 1 profit, -1 cost
38
+
39
+ Returns
40
+ ----------
41
+ ndarray:
42
+ Preference calculated for alternatives. Greater values are placed higher in ranking
43
+ """
44
+ # validate data
45
+ Validator.fuzzy_validation(matrix, weights, types)
46
+
47
+ return fuzzy(matrix, weights, types, self.defuzzify).astype(float)
@@ -0,0 +1,52 @@
1
+ # Copyright (c) 2022 Jakub Więckowski
2
+
3
+ from .topsis.fuzzy import fuzzy
4
+ from .fuzzy_sets.tfn.normalizations import linear_normalization
5
+ from .fuzzy_sets.tfn.distances import vertex_distance
6
+
7
+ from .validator import Validator
8
+
9
+
10
+ class fTOPSIS():
11
+ def __init__(self, normalization=linear_normalization, distance=vertex_distance):
12
+ """
13
+ Creates fuzzy TOPSIS method object with linear normalization and vertex distance function
14
+
15
+ Parameters
16
+ ----------
17
+ normalization: callable
18
+ Function used to normalize the decision matrix
19
+
20
+ distance: callable
21
+ Function used to calculate distance from fuzzy negative solution
22
+
23
+ """
24
+
25
+ self.normalization = normalization
26
+ self.distance = distance
27
+
28
+ def __call__(self, matrix, weights, types):
29
+ """
30
+ Calculates the alternatives preferences
31
+
32
+ Parameters
33
+ ----------
34
+ matrix : ndarray
35
+ Decision matrix / alternatives data.
36
+ Alternatives are in rows and Criteria are in columns.
37
+
38
+ weights : ndarray
39
+ Vector of criteria weights in a crisp form
40
+
41
+ types : ndarray
42
+ Types of criteria, 1 profit, -1 cost
43
+
44
+ Returns
45
+ ----------
46
+ ndarray:
47
+ Preference calculated for alternatives. Greater values are placed higher in ranking
48
+ """
49
+ # validate data
50
+ Validator.fuzzy_validation(matrix, weights)
51
+
52
+ return fuzzy(matrix, weights, types, self.normalization, self.distance).astype(float)
@@ -0,0 +1,51 @@
1
+ # Copyright (c) 2022 Jakub Więckowski
2
+
3
+ from .vikor.fuzzy import fuzzy
4
+ from .fuzzy_sets.tfn.defuzzifications import mean_area_defuzzification
5
+
6
+ from .validator import Validator
7
+
8
+
9
+ class fVIKOR():
10
+ def __init__(self, defuzzify=mean_area_defuzzification):
11
+ """
12
+ Creates fuzzy VIKOR method object with mean area defuzzification function
13
+
14
+ Parameters
15
+ ----------
16
+ defuzzify: callable
17
+ Function used to defuzzify the TFN into crisp value
18
+
19
+ """
20
+
21
+ self.defuzzify = defuzzify
22
+
23
+ def __call__(self, matrix, weights, types, v=0.5):
24
+ """
25
+ Calculates the alternatives preferences
26
+
27
+ Parameters
28
+ ----------
29
+ matrix : ndarray
30
+ Decision matrix / alternatives data.
31
+ Alternatives are in rows and Criteria are in columns.
32
+
33
+ weights : ndarray
34
+ Vector of criteria weights in a crisp form
35
+
36
+ types : ndarray
37
+ Types of criteria, 1 profit, -1 cost
38
+
39
+ v : float
40
+ Weight of the strategy (see VIKOR algorithm explanation).
41
+
42
+ Returns
43
+ ----------
44
+ ndarray:
45
+ Preference calculated for alternatives. Lower values are placed higher in ranking
46
+ """
47
+ # validate data
48
+ Validator.fuzzy_validation(matrix, weights)
49
+
50
+ return fuzzy(matrix, weights, types, self.defuzzify, v)
51
+
@@ -0,0 +1,3 @@
1
+ from . import defuzzifications
2
+ from . import distances
3
+ from . import normalizations
@@ -0,0 +1,86 @@
1
+ # Copyright (c) 2022 Jakub Więckowski
2
+
3
+ __all__ = [
4
+ 'mean_defuzzification',
5
+ 'mean_area_defuzzification',
6
+ 'graded_mean_average_defuzzification',
7
+ 'weighted_mean_defuzzification'
8
+ ]
9
+
10
+
11
+ def mean_defuzzification(a):
12
+ """
13
+ Defuzzify the Triangular Fuzzy Number into crisp value.
14
+ Uses a formula 1/3 * (l + m + r)
15
+
16
+ Parameters
17
+ ----------
18
+ a : ndarray
19
+ Triangular Fuzzy Number
20
+
21
+ Returns
22
+ -------
23
+ float
24
+ Crisp value
25
+ """
26
+
27
+ return 1/3 * (a[0] + a[1] + a[2])
28
+
29
+
30
+ def mean_area_defuzzification(a):
31
+ """
32
+ Defuzzify the Triangular Fuzzy Number into crisp value.
33
+ Uses a formula 1/4 * (l + 2m + r)
34
+
35
+ Parameters
36
+ ----------
37
+ a : ndarray
38
+ Triangular Fuzzy Number
39
+
40
+ Returns
41
+ -------
42
+ float
43
+ Crisp value
44
+ """
45
+
46
+ return 1/4 * (a[0] + 2 * a[1] + a[2])
47
+
48
+
49
+ def graded_mean_average_defuzzification(a):
50
+ """
51
+ Defuzzify the Triangular Fuzzy Number into crisp value.
52
+ Uses a formula 1/6 * (l + 4m + r)
53
+
54
+ Parameters
55
+ ----------
56
+ a : ndarray
57
+ Triangular Fuzzy Number
58
+
59
+ Returns
60
+ -------
61
+ float
62
+ Crisp value
63
+ """
64
+
65
+ return 1/6 * (a[0] + 4 * a[1] + a[2])
66
+
67
+
68
+ def weighted_mean_defuzzification(a, k=2):
69
+ """
70
+ Defuzzify the Triangular Fuzzy Number into crisp value.
71
+ Uses a formula (m + (r - m) - (m - l)) / (k + 2)
72
+
73
+ Parameters
74
+ ----------
75
+ a : ndarray
76
+ Triangular Fuzzy Number
77
+
78
+ k : int
79
+ weight factor
80
+
81
+ Returns
82
+ -------
83
+ float
84
+ Crisp value
85
+ """
86
+ return a[1] + ((a[2] - a[1]) - (a[1] - a[0])) / (k + 2)
@@ -0,0 +1,173 @@
1
+ # Copyright (c) 2022 Jakub Więckowski
2
+
3
+ import numpy as np
4
+
5
+ __all__ = [
6
+ 'euclidean_distance',
7
+ 'weighted_euclidean_distance',
8
+ 'hamming_distance',
9
+ 'weighted_hamming_distance',
10
+ 'vertex_distance',
11
+ 'tran_duckstein_distance',
12
+ 'lr_distance',
13
+ 'mahdavi_distance',
14
+ ]
15
+
16
+
17
+ def euclidean_distance(a, b):
18
+ """
19
+ Calculates the distance between two Triangular Fuzzy Numbers using Euclidean distance
20
+
21
+ Parameters
22
+ ----------
23
+ a : ndarray
24
+ Triangular Fuzzy Number
25
+
26
+ b : ndarray
27
+ Triangular Fuzzy Number
28
+
29
+ Returns
30
+ -------
31
+ float
32
+ Crisp value representing distance
33
+ """
34
+ return np.sqrt(((a[0] - b[0])**2 + (a[1] - b[1])**2 + (a[2] - b[2])**2))
35
+
36
+
37
+ def weighted_euclidean_distance(a, b):
38
+ """
39
+ Calculates the distance between two Triangular Fuzzy Numbers using weighted Euclidean distance
40
+
41
+ Parameters
42
+ ----------
43
+ a : ndarray
44
+ Triangular Fuzzy Number
45
+
46
+ b : ndarray
47
+ Triangular Fuzzy Number
48
+
49
+ Returns
50
+ -------
51
+ float
52
+ Crisp value representing distance
53
+ """
54
+ return np.sqrt(((a[0] - b[0])**2 + 2*(a[1] - b[1])**2 + (a[2] - b[2])**2) / 4)
55
+
56
+
57
+ def hamming_distance(a, b):
58
+ """
59
+ Calculates the distance between two Triangular Fuzzy Numbers using Hamming distance
60
+
61
+ Parameters
62
+ ----------
63
+ a : ndarray
64
+ Triangular Fuzzy Number
65
+
66
+ b : ndarray
67
+ Triangular Fuzzy Number
68
+
69
+ Returns
70
+ -------
71
+ float
72
+ Crisp value representing distance
73
+ """
74
+ return np.abs(a[0] - b[0]) + np.abs(a[1] - b[1]) + np.abs(a[2] - b[2])
75
+
76
+
77
+ def weighted_hamming_distance(a, b):
78
+ """
79
+ Calculates the distance between two Triangular Fuzzy Numbers using weighted Hamming distance
80
+
81
+ Parameters
82
+ ----------
83
+ a : ndarray
84
+ Triangular Fuzzy Number
85
+
86
+ b : ndarray
87
+ Triangular Fuzzy Number
88
+
89
+ Returns
90
+ -------
91
+ float
92
+ Crisp value representing distance
93
+ """
94
+ return (np.abs(a[0] - b[0]) + 2*np.abs(a[1] - b[1]) + np.abs(a[2] - b[2])) / 4
95
+
96
+ def vertex_distance(a, b):
97
+ """
98
+ Calculates the distance between two Triangular Fuzzy Numbers using Vertex distance
99
+
100
+ Parameters
101
+ ----------
102
+ a : ndarray
103
+ Triangular Fuzzy Number
104
+
105
+ b : ndarray
106
+ Triangular Fuzzy Number
107
+
108
+ Returns
109
+ -------
110
+ float
111
+ Crisp value representing distance
112
+ """
113
+ return np.sqrt(((a[0] - b[0])**2 + (a[1] - b[1])**2 + (a[2] - b[2])**2) / 3)
114
+
115
+
116
+ def tran_duckstein_distance(a, b):
117
+ """
118
+ Calculates the distance between two Triangular Fuzzy Numbers using Tran Duckstein distance
119
+
120
+ Parameters
121
+ ----------
122
+ a : ndarray
123
+ Triangular Fuzzy Number
124
+
125
+ b : ndarray
126
+ Triangular Fuzzy Number
127
+
128
+ Returns
129
+ -------
130
+ float
131
+ Crisp value representing distance
132
+ """
133
+ return (a[1] - b[1])**2 + 0.5 * (a[1] - b[1]) * ((a[2] - b[0]) - (b[2] - b[0])) + 1/9 * ((a[2]-a[1])**2 + (a[1]-a[0])**2 + (b[2]-b[1])**2 + (b[1]-b[0])**2) - 1/9 * ((a[1]-a[0]) * (a[2]-a[1]) + (b[1]-b[0]) * (b[2]-b[1])) + 1/6 * (2 * a[1] - a[0] - a[2]) * (2 * b[1] - b[0] - b[2])
134
+
135
+
136
+ def lr_distance(a, b, r=0.5):
137
+ """
138
+ Calculates the distance between two Triangular Fuzzy Numbers using L-R distance
139
+
140
+ Parameters
141
+ ----------
142
+ a : ndarray
143
+ Triangular Fuzzy Number
144
+
145
+ b : ndarray
146
+ Triangular Fuzzy Number
147
+
148
+ Returns
149
+ -------
150
+ float
151
+ Crisp value representing distance
152
+ """
153
+ return (a[1] - b[1])**2 + ((a[1] - r * a[0]) - (b[1] - r * b[0]))**2 + ((a[1] + r * a[2]) - (b[1] + r * b[2]))**2
154
+
155
+
156
+ def mahdavi_distance(a, b):
157
+ """
158
+ Calculates the distance between two Triangular Fuzzy Numbers using Mahdavi distance
159
+
160
+ Parameters
161
+ ----------
162
+ a : ndarray
163
+ Triangular Fuzzy Number
164
+
165
+ b : ndarray
166
+ Triangular Fuzzy Number
167
+
168
+ Returns
169
+ -------
170
+ float
171
+ Crisp value representing distance
172
+ """
173
+ return np.sqrt(1/6 * ( np.sum([ (b[i] - a[i])**2 for i in range(3)]) + (b[1] - a[1])**2 + np.sum([(b[i] - a[i]) * (b[i+1] - a[i+1]) for i in range(2)]) ))