Professional Documents
Culture Documents
com)
# To use this class you need to pass as argument to the constructor a file that contains
the decision matrix, weights and cost/benefit information.
# [1] C.L. Hwang & K.P. Yoon, Multiple Attributes Decision Making Methods and Applications,
Springer-Verlag, Berlin, 1981.
# [2] Krohling, Renato A., Andre GC Pacheco, and Andre LT Siviero. IF-TODIM: An intuitionistic
fuzzy TODIM to multi-criteria decision making. Knowledge-Based Systems 53 (2013): 142-146.
#############################################################
import numpy as np
'''
Attributes:
dPos and dNeg - The distance of each rating to the ideal value positive and negative
'''
def __init__ (self,fileName):
try:
except ValueError:
print 'ERROR: The number of the weights value or cost and benefits values must
be the same of the number of the criteria'
self.weights = data[0,:]
if self.weights.sum() != 1.0:
raise ValueError
self.costBen = data[1,:].astype(int)
self.matrixD = data[2:,:]
size = self.matrixD.shape
m = self.matrixD **2
m = np.sqrt(m.sum(axis=0))
for i in range(self.nAlt):
for j in range(self.nCri):
mx = self.normMatrixD.max(axis=0)
mi = self.normMatrixD.min(axis=0)
for j in range(self.nCri):
if self.costBen[j] == 1:
self.idealPos[j] =mi[j]
self.idealNeg[j] = mx[j]
elif self.costBen[j] == 0:
self.idealPos[j] = mx[j]
self.idealNeg[j] = mi[j]
else:
print 'ERROR: The values of the cost and benefit must be 1 or 0'
raise ValueError
for i in range(self.nAlt):
for j in range(self.nCri):
self.dPos[i] = np.sqrt(self.dPos[i])
self.dNeg[i] = np.sqrt(self.dNeg[i])
for i in range(self.nAlt):
sns.set_style("whitegrid")
a.set_ylabel("Ranking")
plt.show()
return (a-b)**2
A = TOPSIS ('matrizDecisao.txt')
A.normalizeMatrix()
A.introWeights()
A.getIdealSolutions()
A.distanceToIdeal()
A.relativeCloseness()
A.plotRankBar(Alternatives)