本文整理匯總了Python中PyXMCDA.getAlternativesAffectations方法的典型用法代碼示例。如果您正苦於以下問題:Python PyXMCDA.getAlternativesAffectations方法的具體用法?Python PyXMCDA.getAlternativesAffectations怎麽用?Python PyXMCDA.getAlternativesAffectations使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyXMCDA
的用法示例。
在下文中一共展示了PyXMCDA.getAlternativesAffectations方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: parse_xmcda_files
# 需要導入模塊: import PyXMCDA [as 別名]
# 或者: from PyXMCDA import getAlternativesAffectations [as 別名]
def parse_xmcda_files(in_dir):
xml_crit = PyXMCDA.parseValidate(in_dir+"/criteria.xml")
xml_alt = PyXMCDA.parseValidate(in_dir+"/alternatives.xml")
xml_pt = PyXMCDA.parseValidate(in_dir+"/perfs_table.xml")
xml_assign = PyXMCDA.parseValidate(in_dir+"/assign.xml")
xml_cat = PyXMCDA.parseValidate(in_dir+"/categories.xml")
if xml_crit == None:
error_list.append("Invalid criteria file")
return
if xml_alt == None:
error_list.append("Invalid alternative file")
return
if xml_pt == None:
error_list.append("Invalid performance table file")
return
if xml_assign == None:
error_list.append("Invalid assignment file")
return
if xml_cat == None:
error_list.append("Invalid categories file")
return
try:
alt_id = PyXMCDA.getAlternativesID(xml_alt)
crit_id = PyXMCDA.getCriteriaID(xml_crit)
pt = PyXMCDA.getPerformanceTable(xml_pt, alt_id, crit_id)
cat_id = PyXMCDA.getCategoriesID(xml_cat)
cat_rank = PyXMCDA.getCategoriesRank(xml_cat, cat_id)
assign = PyXMCDA.getAlternativesAffectations(xml_assign)
pref_dir = PyXMCDA.getCriteriaPreferenceDirections(xml_crit, crit_id)
except:
error_list.append("Failed to parse one or more file")
return
return (alt_id, crit_id, pt, cat_id, cat_rank, assign, pref_dir)
示例2: main
# 需要導入模塊: import PyXMCDA [as 別名]
# 或者: from PyXMCDA import getAlternativesAffectations [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.")
#.........這裏部分代碼省略.........
示例3: main
# 需要導入模塊: import PyXMCDA [as 別名]
# 或者: from PyXMCDA import getAlternativesAffectations [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 getAlternativesAffectations [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] = []
#.........這裏部分代碼省略.........