本文整理汇总了Python中PyXMCDA.getCategoriesRank方法的典型用法代码示例。如果您正苦于以下问题:Python PyXMCDA.getCategoriesRank方法的具体用法?Python PyXMCDA.getCategoriesRank怎么用?Python PyXMCDA.getCategoriesRank使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyXMCDA
的用法示例。
在下文中一共展示了PyXMCDA.getCategoriesRank方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_input_data
# 需要导入模块: import PyXMCDA [as 别名]
# 或者: from PyXMCDA import getCategoriesRank [as 别名]
def get_input_data(input_dir):
file_names = (
'alternatives.xml',
'categories.xml',
'categoriesProfiles.xml',
'credibility.xml',
'method_parameters.xml',
)
trees = get_trees(input_dir, file_names)
alternatives = px.getAlternativesID(trees['alternatives'])
categories = px.getCategoriesID(trees['categories'])
categories_rank = px.getCategoriesRank(trees['categories'], categories)
categories_profiles = get_categories_profiles_central(trees['categoriesProfiles'])
credibility = getAlternativesComparisons(trees['credibility'], alternatives,
categories_profiles)
cut_threshold = px.getParameterByName(trees['method_parameters'], 'cut_threshold')
check_cut_threshold(cut_threshold)
ret = {
'alternatives': alternatives,
'categories_rank': categories_rank,
'categories_profiles': categories_profiles,
'credibility': credibility,
'cut_threshold': cut_threshold,
}
return ret
示例2: parse_xmcda_files
# 需要导入模块: import PyXMCDA [as 别名]
# 或者: from PyXMCDA import getCategoriesRank [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)
示例3: main
# 需要导入模块: import PyXMCDA [as 别名]
# 或者: from PyXMCDA import getCategoriesRank [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 lists for error and log messages
errorList = []
logList = []
# If some mandatory input files are missing
if not os.path.isfile (in_dir+"/alternatives.xml") or not os.path.isfile (in_dir+"/categories.xml") or not os.path.isfile (in_dir+"/categoriesProfiles.xml") or not os.path.isfile (in_dir+"/stabilityRelation.xml"):
errorList.append("Some input files are missing")
else :
if os.path.isfile (in_dir+"/sortingMode.xml") :
xmltree_mode = PyXMCDA.parseValidate(in_dir+"/sortingMode.xml")
if xmltree_mode == None :
errorList.append ("sortingMode file cannot be validated.")
else :
mode = PyXMCDA.getParameterByName (xmltree_mode, "sortingMode")
if not (mode == "pessimistic" or mode == "optimistic"):
errorList.append ("Value of parameter sortingMode should be 'pessimistic' or 'optimistic'.")
xmltree_alternatives = PyXMCDA.parseValidate(in_dir+"/alternatives.xml")
xmltree_categories = PyXMCDA.parseValidate(in_dir+"/categories.xml")
xmltree_profiles = PyXMCDA.parseValidate(in_dir+"/categoriesProfiles.xml")
xmltree_altStability = PyXMCDA.parseValidate(in_dir+"/stabilityRelation.xml")
if xmltree_alternatives == None :
errorList.append("The alternatives file cannot be validated.")
if xmltree_categories == None :
errorList.append("The categories file cannot be validated.")
if xmltree_profiles == None :
errorList.append("The categoriesProfiles file cannot be validated.")
if xmltree_altStability == None :
errorList.append("The alternatives comparisons file cannot be validated.")
if not errorList :
alternativesId = PyXMCDA.getAlternativesID(xmltree_alternatives, "ACTIVEREAL")
allalt = PyXMCDA.getAlternativesID(xmltree_alternatives, "ACTIVE")
categoriesId = PyXMCDA.getCategoriesID(xmltree_categories)
categoriesRank = PyXMCDA.getCategoriesRank(xmltree_categories, categoriesId)
altStability = PyXMCDA.getAlternativesComparisons (xmltree_altStability, allalt)
if not alternativesId:
errorList.append("No alternatives found.")
if not categoriesId:
errorList.append("No categories found.")
if not altStability :
errorList.append("No alternatives comparisons found.")
if not errorList :
catPro = PyXMCDA.getCategoriesProfiles(xmltree_profiles, categoriesId)
proCat = PyXMCDA.getProfilesCategories(xmltree_profiles, categoriesId)
profilesId = proCat.keys()
# On retourne la liste pour trier selon les rangs
rankCategories = {}
for i, j in categoriesRank.iteritems():
rankCategories[j] = i
ranks = rankCategories.keys()[:]
ranks.sort()
lowestRank = ranks.pop()
# Un tableau pour conserver les affectations
affectations = {}
if mode == "pessimistic":
# Electre tri pessimistic rule
for alt in alternativesId:
affectations[alt] = []
for rank in ranks:
profile = catPro[rankCategories[rank]]["lower"]
if altStability[alt][profile] >= -1 and altStability[alt][profile] <= 1:
# Surclassement instable, on ajoute les categories sup et inf
if affectations[alt].count(proCat[profile]["lower"]) == 0:
affectations[alt].append(proCat[profile]["lower"])
if affectations[alt].count(proCat[profile]["upper"]) == 0:
affectations[alt].append(proCat[profile]["upper"])
if altStability[alt][profile] > 1:
# Surclassement stable, on ajoute que sup et on arrete
if affectations[alt].count(proCat[profile]["upper"]) == 0:
affectations[alt].append(proCat[profile]["upper"])
break
if affectations[alt] == []:
#.........这里部分代码省略.........
示例4: get_input_data
# 需要导入模块: import PyXMCDA [as 别名]
# 或者: from PyXMCDA import getCategoriesRank [as 别名]
def get_input_data(input_dir, filenames, params, **kwargs):
trees = _get_trees(input_dir, filenames)
d = _create_data_object(params)
for p in params:
if p == 'alternatives':
d.alternatives = px.getAlternativesID(trees['alternatives'])
elif p == 'categories_profiles':
comparison_with = kwargs.get('comparison_with')
if comparison_with is None:
comparison_with = px.getParameterByName(trees['method_parameters'], 'comparison_with')
d.categories_profiles = _get_categories_profiles(trees.get('categories_profiles'),
comparison_with)
elif p == 'categories_rank':
categories = px.getCategoriesID(trees['categories'])
d.categories_rank = px.getCategoriesRank(trees['categories'], categories)
elif p == 'comparison_with':
d.comparison_with = px.getParameterByName(trees['method_parameters'], 'comparison_with')
elif p == 'concordance':
alternatives = px.getAlternativesID(trees['alternatives'])
comparison_with = px.getParameterByName(trees['method_parameters'], 'comparison_with')
if comparison_with in ('boundary_profiles', 'central_profiles'):
categories_profiles = _get_categories_profiles(trees['categories_profiles'],
comparison_with)
d.concordance = _get_alternatives_comparisons(trees['concordance'], alternatives,
categories_profiles)
else:
d.concordance = px.getAlternativesComparisons(trees['concordance'], alternatives)
elif p == 'credibility':
alternatives = px.getAlternativesID(trees['alternatives'])
comparison_with = kwargs.get('comparison_with')
if not comparison_with:
comparison_with = px.getParameterByName(trees['method_parameters'], 'comparison_with')
if comparison_with in ('boundary_profiles', 'central_profiles'):
categories_profiles = _get_categories_profiles(trees['categories_profiles'],
comparison_with)
else:
categories_profiles = None
eliminate_cycles_method = px.getParameterByName(trees.get('method_parameters'),
'eliminate_cycles_method')
tree = trees.get('credibility')
if eliminate_cycles_method == 'cut_weakest' and tree is None:
raise RuntimeError("'cut_weakest' option requires credibility as "
"an additional input (apart from outranking).")
d.credibility = _get_alternatives_comparisons(tree, alternatives,
categories_profiles=categories_profiles)
elif p == 'criteria':
d.criteria = px.getCriteriaID(trees['criteria'])
elif p == 'cut_threshold':
cut_threshold = px.getParameterByName(trees['method_parameters'], 'cut_threshold')
if cut_threshold is None or not (0 <= float(cut_threshold) <= 1):
raise RuntimeError(
"'cut_threshold' should be in range [0, 1] "
"(most commonly used values are 0.6 or 0.7)."
)
d.cut_threshold = cut_threshold
# 'cv_crossed' == 'counter-veto crossed'
elif p == 'cv_crossed':
alternatives = px.getAlternativesID(trees['alternatives'])
comparison_with = px.getParameterByName(trees['method_parameters'], 'comparison_with')
if comparison_with in ('boundary_profiles', 'central_profiles'):
categories_profiles = _get_categories_profiles(trees['categories_profiles'],
comparison_with)
else:
categories_profiles = None
d.cv_crossed = _get_alternatives_comparisons(trees['counter_veto_crossed'],
alternatives,
categories_profiles=categories_profiles,
use_partials=True,
mcda_concept='counterVetoCrossed')
elif p == 'discordance':
alternatives = px.getAlternativesID(trees['alternatives'])
comparison_with = px.getParameterByName(trees['method_parameters'], 'comparison_with')
if kwargs.get('use_partials') is not None:
use_partials = kwargs.get('use_partials')
else:
parameter = px.getParameterByName(trees['method_parameters'], 'use_partials')
use_partials = True if parameter == 'true' else False
if comparison_with in ('boundary_profiles', 'central_profiles'):
categories_profiles = _get_categories_profiles(trees['categories_profiles'],
comparison_with)
else:
categories_profiles = None
d.discordance = _get_alternatives_comparisons(trees['discordance'], alternatives,
categories_profiles=categories_profiles,
use_partials=use_partials)
elif p == 'eliminate_cycles_method':
d.eliminate_cycles_method = px.getParameterByName(trees['method_parameters'],
'eliminate_cycles_method')
elif p == 'interactions':
#.........这里部分代码省略.........
示例5: get_input_data
# 需要导入模块: import PyXMCDA [as 别名]
# 或者: from PyXMCDA import getCategoriesRank [as 别名]
def get_input_data(input_dir, filenames, params, **kwargs):
trees = _get_trees(input_dir, filenames)
d = _create_data_object(params)
for p in params:
if p == "alternatives":
d.alternatives = px.getAlternativesID(trees["alternatives"])
elif p == "profiles":
d.profiles = px.getProfilesID(trees["profiles"])
elif p == "categories_profiles":
comparison_with = kwargs.get("comparison_with")
if comparison_with is None:
comparison_with = px.getParameterByName(trees["method_parameters"], "comparison_with")
d.categories_profiles = _get_categories_profiles(trees.get("categories_profiles"), comparison_with)
elif p == "categories_rank":
categories = px.getCategoriesID(trees["categories"])
d.categories_rank = px.getCategoriesRank(trees["categories"], categories)
elif p == "comparison_with":
d.comparison_with = px.getParameterByName(trees["method_parameters"], "comparison_with")
elif p == "concordance":
alternatives = px.getAlternativesID(trees["alternatives"])
comparison_with = kwargs.get("comparison_with")
if trees.has_key("methos_parameters"):
comparison_with = px.getParameterByName(trees["method_parameters"], "comparison_with")
if kwargs.get("use_partials") is not None:
use_partials = kwargs.get("use_partials")
else:
if trees.has_key("methos_parameters"):
parameter = px.getParameterByName(trees["method_parameters"], "use_partials")
use_partials = True if parameter == "true" else False
categories_profiles = None
profiles = None
if comparison_with in ("boundary_profiles", "central_profiles"):
categories_profiles = _get_categories_profiles(trees["categories_profiles"], comparison_with)
if comparison_with == "profiles":
profiles = px.getProfilesID(trees["profiles"])
d.concordance = _get_alternatives_comparisons(
trees["concordance"],
alternatives,
profiles=profiles,
categories_profiles=categories_profiles,
use_partials=use_partials,
)
elif p == "crisp_concordance":
alternatives = px.getAlternativesID(trees["alternatives"])
comparison_with = kwargs.get("comparison_with")
if trees.has_key("methos_parameters"):
comparison_with = px.getParameterByName(trees["method_parameters"], "comparison_with")
if kwargs.get("use_partials") is not None:
use_partials = kwargs.get("use_partials")
else:
if trees.has_key("methos_parameters"):
parameter = px.getParameterByName(trees["method_parameters"], "use_partials")
use_partials = True if parameter == "true" else False
categories_profiles = None
profiles = None
if comparison_with in ("boundary_profiles", "central_profiles"):
categories_profiles = _get_categories_profiles(trees["categories_profiles"], comparison_with)
if comparison_with == "profiles":
profiles = px.getProfilesID(trees["profiles"])
d.concordance = _get_alternatives_comparisons(
trees["concordance"],
alternatives,
profiles=profiles,
categories_profiles=categories_profiles,
use_partials=use_partials,
use_value=False,
)
elif p == "credibility":
alternatives = px.getAlternativesID(trees["alternatives"])
comparison_with = kwargs.get("comparison_with")
if not comparison_with:
comparison_with = px.getParameterByName(trees["method_parameters"], "comparison_with")
if comparison_with in ("boundary_profiles", "central_profiles"):
categories_profiles = _get_categories_profiles(trees["categories_profiles"], comparison_with)
else:
categories_profiles = None
eliminate_cycles_method = px.getParameterByName(trees.get("method_parameters"), "eliminate_cycles_method")
tree = trees.get("credibility")
if eliminate_cycles_method == "cut_weakest" and tree is None:
raise RuntimeError(
#.........这里部分代码省略.........
示例6: get_categories_rank
# 需要导入模块: import PyXMCDA [as 别名]
# 或者: from PyXMCDA import getCategoriesRank [as 别名]
def get_categories_rank(*args, **kwargs):
categories = px.getCategoriesID(trees['categories'])
categories_rank = px.getCategoriesRank(trees['categories'], categories)
return categories_rank # dict