本文整理匯總了Python中PyXMCDA.getAlternativesComparisonsValues方法的典型用法代碼示例。如果您正苦於以下問題:Python PyXMCDA.getAlternativesComparisonsValues方法的具體用法?Python PyXMCDA.getAlternativesComparisonsValues怎麽用?Python PyXMCDA.getAlternativesComparisonsValues使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyXMCDA
的用法示例。
在下文中一共展示了PyXMCDA.getAlternativesComparisonsValues方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: import PyXMCDA [as 別名]
# 或者: from PyXMCDA import getAlternativesComparisonsValues [as 別名]
def main(argv=None):
if argv is None:
argv = sys.argv
parser = OptionParser()
parser.add_option("-i", "--in", dest="in_dir")
parser.add_option("-o", "--out", dest="out_dir")
(options, args) = parser.parse_args(argv[1:])
in_dir = options.in_dir
out_dir = options.out_dir
# Creating a list for error messages
errorList = []
if not in_dir:
errorList.append("option --in is missing")
if not out_dir:
errorList.append("option --out is missing")
if not errorList:
if not os.path.isfile (in_dir+"/alternatives.xml"):
errorList.append("alternatives.xml is missing")
if not os.path.isfile (in_dir+"/preferenceRelation.xml"):
errorList.append("preferenceRelation.xml is missing")
if not os.path.isfile (in_dir+"/alternativesAffectations.xml"):
errorList.append("alternativesAffectations.xml is missing")
if not os.path.isfile (in_dir+"/clustersRelations.xml"):
errorList.append("clustersRelations.xml is missing")
if not os.path.isfile (in_dir+"/clustersRelationsDetailed.xml"):
errorList.append("clustersRelationsDetailed.xml is missing")
if not errorList:
# We parse all the mandatory input files
xmltree_alternatives = PyXMCDA.parseValidate(in_dir+"/alternatives.xml")
xmltree_preferenceRelation = PyXMCDA.parseValidate(in_dir+"/preferenceRelation.xml")
xmltree_alternativesAffectations = PyXMCDA.parseValidate(in_dir+"/alternativesAffectations.xml")
xmltree_clustersRelations = PyXMCDA.parseValidate(in_dir+"/clustersRelations.xml")
xmltree_clustersRelationsDetailed = PyXMCDA.parseValidate(in_dir+"/clustersRelationsDetailed.xml")
# We check if all mandatory input files are valid
if xmltree_alternatives == None :
errorList.append("alternatives.xml can't be validated.")
if xmltree_preferenceRelation == None :
errorList.append("preferenceRelation.xml can't be validated.")
if xmltree_alternativesAffectations == None :
errorList.append("alternativesAffectations.xml can't be validated.")
if xmltree_clustersRelations == None :
errorList.append("clustersRelations.xml can't be validated.")
if xmltree_clustersRelationsDetailed == None :
errorList.append("clustersRelationsDetailed.xml can't be validated.")
if not errorList :
alternativesId = PyXMCDA.getAlternativesID(xmltree_alternatives)
alternativesRel = PyXMCDA.getAlternativesComparisonsValues(xmltree_preferenceRelation, alternativesId)
if not alternativesId :
errorList.append("No active alternatives found.")
if not alternativesRel :
errorList.append("Problems between relation and alternatives.")
missing_eval = False
for o in alternativesId:
if not (o in alternativesRel):
missing_eval = True
break
else:
for p in alternativesId:
if not (p in alternativesRel[o]):
missing_eval = True
break
else:
if not ('i' in alternativesRel[o][p]):
missing_eval = True
break
if not ('p+' in alternativesRel[o][p]):
missing_eval = True
break
if not ('p-' in alternativesRel[o][p]):
missing_eval = True
break
if not ('j' in alternativesRel[o][p]):
missing_eval = True
break
if missing_eval:
errorList.append("Not all alternatives from alternatives.xml contain evaluations in preferenceRelation.xml, or evaluations are incomplete. Possible inputs from different sources")
alternativesAffectations = PyXMCDA.getAlternativesAffectations(xmltree_alternativesAffectations)
Knames = []
for o in alternativesId:
clusterId = alternativesAffectations[o]
if not (clusterId in Knames):
Knames.append(clusterId)
if Knames == []:
errorList.append("No clusters found.")
#.........這裏部分代碼省略.........
示例2: main
# 需要導入模塊: import PyXMCDA [as 別名]
# 或者: from PyXMCDA import getAlternativesComparisonsValues [as 別名]
def main(argv=None):
if argv is None:
argv = sys.argv
parser = OptionParser()
parser.add_option("-i", "--in", dest="in_dir")
parser.add_option("-o", "--out", dest="out_dir")
(options, args) = parser.parse_args(argv[1:])
in_dir = options.in_dir
out_dir = options.out_dir
# Creating a list for error messages
errorList = []
if not in_dir:
errorList.append("option --in is missing")
if not out_dir:
errorList.append("option --out is missing")
# Creating a list for log messages
logList = []
if not errorList:
if not os.path.isfile (in_dir+"/alternatives.xml"):
errorList.append("alternatives.xml is missing")
if not os.path.isfile (in_dir+"/preferenceRelation.xml"):
errorList.append("preferenceRelation.xml is missing")
if not os.path.isfile (in_dir+"/alternativesAffectations.xml"):
errorList.append("alternativesAffectations.xml is missing")
if not os.path.isfile (in_dir+"/clustersRelations.xml"):
errorList.append("clustersRelations.xml is missing")
if not errorList:
# We parse all the mandatory input files
xmltree_alternatives = PyXMCDA.parseValidate(in_dir+"/alternatives.xml")
xmltree_preferenceRelation = PyXMCDA.parseValidate(in_dir+"/preferenceRelation.xml")
xmltree_alternativesAffectations = PyXMCDA.parseValidate(in_dir+"/alternativesAffectations.xml")
xmltree_clustersRelations = PyXMCDA.parseValidate(in_dir+"/clustersRelations.xml")
# We check if all mandatory input files are valid
if xmltree_alternatives == None :
errorList.append("alternatives.xml can't be validated.")
if xmltree_preferenceRelation == None :
errorList.append("preferenceRelation.xml can't be validated.")
if xmltree_alternativesAffectations == None :
errorList.append("alternativesAffectations.xml can't be validated.")
if xmltree_clustersRelations == None :
errorList.append("clustersRelations.xml can't be validated.")
if not errorList :
alternativesId = PyXMCDA.getAlternativesID(xmltree_alternatives)
alternativesRel = PyXMCDA.getAlternativesComparisonsValues(xmltree_preferenceRelation, alternativesId)
if not alternativesId :
errorList.append("No active alternatives found.")
if not alternativesRel :
errorList.append("Problems between relation and alternatives.")
missing_eval = False
for o in alternativesId:
if not (o in alternativesRel):
missing_eval = True
break
else:
for p in alternativesId:
if not (p in alternativesRel[o]):
missing_eval = True
break
else:
if not ('i' in alternativesRel[o][p]):
missing_eval = True
break
if not ('p+' in alternativesRel[o][p]):
missing_eval = True
break
if not ('p-' in alternativesRel[o][p]):
missing_eval = True
break
if not ('j' in alternativesRel[o][p]):
missing_eval = True
break
if missing_eval:
errorList.append("Not all alternatives from alternatives.xml contain evaluations in preferenceRelation.xml, or evaluations are incomplete. Possible inputs from different sources")
alternativesAffectations = PyXMCDA.getAlternativesAffectations(xmltree_alternativesAffectations)
Knames = []
for o in alternativesId:
clusterId = alternativesAffectations[o]
if not (clusterId in Knames):
Knames.append(clusterId)
if Knames == []:
errorList.append("No clusters found.")
K = {}
for clusterId in Knames:
K[clusterId] = []
#.........這裏部分代碼省略.........
示例3: main
# 需要導入模塊: import PyXMCDA [as 別名]
# 或者: from PyXMCDA import getAlternativesComparisonsValues [as 別名]
def main(argv=None):
if argv is None:
argv = sys.argv
parser = OptionParser()
parser.add_option("-i", "--in", dest="in_dir")
parser.add_option("-o", "--out", dest="out_dir")
(options, args) = parser.parse_args(argv[1:])
in_dir = options.in_dir
out_dir = options.out_dir
# Creating a list for error messages
errorList = []
if not in_dir:
errorList.append("option --in is missing")
if not out_dir:
errorList.append("option --out is missing")
if not errorList:
if not os.path.isfile (in_dir+"/alternatives.xml"):
errorList.append("alternatives.xml is missing")
if not os.path.isfile (in_dir+"/preferenceRelation.xml"):
errorList.append("preferenceRelation.xml is missing")
if not os.path.isfile (in_dir+"/alternativesAffectations.xml"):
errorList.append("alternativesAffectations.xml is missing")
if not errorList:
# We parse all the mandatory input files
xmltree_alternatives = PyXMCDA.parseValidate(in_dir+"/alternatives.xml")
xmltree_preferenceRelation = PyXMCDA.parseValidate(in_dir+"/preferenceRelation.xml")
xmltree_alternativesAffectations = PyXMCDA.parseValidate(in_dir+"/alternativesAffectations.xml")
# We check if all mandatory input files are valid
if xmltree_alternatives == None :
errorList.append("alternatives.xml can't be validated.")
if xmltree_preferenceRelation == None :
errorList.append("preferenceRelation.xml can't be validated.")
if xmltree_alternativesAffectations == None :
errorList.append("alternativesAffectations.xml can't be validated.")
if not errorList :
alternativesId = PyXMCDA.getAlternativesID(xmltree_alternatives)
alternativesRel = PyXMCDA.getAlternativesComparisonsValues(xmltree_preferenceRelation, alternativesId)
if not alternativesId :
errorList.append("No active alternatives found.")
if not alternativesRel :
errorList.append("Problems between relation and alternatives.")
missing_eval = False
for o in alternativesId:
if not (o in alternativesRel):
missing_eval = True
break
else:
for p in alternativesId:
if not (p in alternativesRel[o]):
missing_eval = True
break
else:
if not ('i' in alternativesRel[o][p]):
missing_eval = True
break
if not ('p+' in alternativesRel[o][p]):
missing_eval = True
break
if not ('p-' in alternativesRel[o][p]):
missing_eval = True
break
if not ('j' in alternativesRel[o][p]):
missing_eval = True
break
if missing_eval:
errorList.append("Not all alternatives from alternatives.xml contain evaluations in preferenceRelation.xml, or evaluations are incomplete. Possible inputs from different sources")
alternativesAffectations = PyXMCDA.getAlternativesAffectations(xmltree_alternativesAffectations)
Knames = []
for o in alternativesId:
clusterId = alternativesAffectations[o]
if not (clusterId in Knames):
Knames.append(clusterId)
if Knames == []:
errorList.append("No clusters found.")
K = {}
for clusterId in Knames:
K[clusterId] = []
for o in alternativesId:
K[alternativesAffectations[o]].append(o)
if not errorList :
CRS = ClustersRelationSummary(alternativesId, alternativesRel)
RKsum = CRS.RKSummary(K)
#.........這裏部分代碼省略.........
示例4: main
# 需要導入模塊: import PyXMCDA [as 別名]
# 或者: from PyXMCDA import getAlternativesComparisonsValues [as 別名]
def main(argv=None):
if argv is None:
argv = sys.argv
parser = OptionParser()
parser.add_option("-i", "--in", dest="in_dir")
parser.add_option("-o", "--out", dest="out_dir")
(options, args) = parser.parse_args(argv[1:])
in_dir = options.in_dir
out_dir = options.out_dir
# Creating a list for error messages
errorList = []
if not in_dir:
errorList.append("option --in is missing")
if not out_dir:
errorList.append("option --out is missing")
if not errorList:
if not os.path.isfile (in_dir+"/alternatives.xml"):
errorList.append("alternatives.xml is missing")
if not os.path.isfile (in_dir+"/preferenceRelation.xml"):
errorList.append("preferenceRelation.xml is missing")
if not os.path.isfile (in_dir+"/methodParameters.xml"):
errorList.append("methodParameters.xml is missing")
if not errorList:
# We parse all the mandatory input files
xmltree_alternatives = PyXMCDA.parseValidate(in_dir+"/alternatives.xml")
xmltree_preferenceRelation = PyXMCDA.parseValidate(in_dir+"/preferenceRelation.xml")
xmltree_methodParameters = PyXMCDA.parseValidate(in_dir+"/methodParameters.xml")
# We check if all mandatory input files are valid
if xmltree_alternatives == None :
errorList.append("alternatives.xml can't be validated.")
if xmltree_preferenceRelation == None :
errorList.append("preferenceRelation.xml can't be validated.")
if xmltree_methodParameters == None :
errorList.append("methodParameters.xml can't be validated.")
if not errorList :
alternativesId = PyXMCDA.getAlternativesID(xmltree_alternatives)
alternativesRel = PyXMCDA.getAlternativesComparisonsValues(xmltree_preferenceRelation, alternativesId)
method_type = PyXMCDA.getParameterByName(xmltree_methodParameters, "type")
if not alternativesId :
errorList.append("No active alternatives found.")
if not alternativesRel :
errorList.append("Problems between relation and alternatives.")
if not method_type:
errorList.append("No method type found.")
missing_eval = False
for o in alternativesId:
if not (o in alternativesRel):
missing_eval = True
break
else:
for p in alternativesId:
if not (p in alternativesRel[o]):
missing_eval = True
break
else:
if not ('i' in alternativesRel[o][p]):
missing_eval = True
break
if not ('p+' in alternativesRel[o][p]):
missing_eval = True
break
if not ('p-' in alternativesRel[o][p]):
missing_eval = True
break
if not ('j' in alternativesRel[o][p]):
missing_eval = True
break
if missing_eval:
errorList.append("Not all alternatives from alternatives.xml contain evaluations in preferenceRelation.xml, or evaluations are incomplete. Possible inputs from different sources")
if not errorList :
alg = Mcc(alternativesId, alternativesRel, method_type)
K, RK = alg.Run()
fo = open(out_dir+"/alternativesAffectations.xml",'w')
PyXMCDA.writeHeader(fo)
fo.write('<alternativesAffectations>\n')
for i in range(len(K)):
for o in K[i]:
fo.write('\t<alternativeAffectation>\n\t\t<alternativeID>'+o+'</alternativeID>\n\t\t<categoryID>'+'K'+str(i+1)+'</categoryID>\n\t</alternativeAffectation>\n')
fo.write('</alternativesAffectations>')
PyXMCDA.writeFooter(fo)
fo.close()
fo = open(out_dir+"/clustersRelations.xml",'w')
PyXMCDA.writeHeader(fo)
fo.write('<categoriesComparisons>\n')
#.........這裏部分代碼省略.........