本文整理汇总了Python中PyXMCDA.getAlternativesID方法的典型用法代码示例。如果您正苦于以下问题:Python PyXMCDA.getAlternativesID方法的具体用法?Python PyXMCDA.getAlternativesID怎么用?Python PyXMCDA.getAlternativesID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyXMCDA
的用法示例。
在下文中一共展示了PyXMCDA.getAlternativesID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_credibility
# 需要导入模块: import PyXMCDA [as 别名]
# 或者: from PyXMCDA import getAlternativesID [as 别名]
def get_credibility(*args, **kwargs):
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 InputDataError(
"'cut_weakest' option requires credibility as an additional "
"input (apart from outranking)."
)
credibility = _get_alternatives_comparisons(
tree,
alternatives,
categories_profiles=categories_profiles,
)
return credibility # NoneType, Vividict
示例2: get_input_data
# 需要导入模块: import PyXMCDA [as 别名]
# 或者: from PyXMCDA import getAlternativesID [as 别名]
def get_input_data(input_dir):
file_names = (
'alternatives.xml',
'method_parameters.xml',
'outranking.xml',
)
trees = get_trees(input_dir, file_names)
alternatives = px.getAlternativesID(trees['alternatives'])
alternatives.sort()
outranking = get_intersection_distillation(trees['outranking'], alternatives)
if outranking == None:
outranking = px.getAlternativesComparisons(trees['outranking'], alternatives)
eliminate_cycles_method = px.getParameterByName(trees['method_parameters'],
'eliminate_cycles_method')
if eliminate_cycles_method not in ['aggregate', 'cut_weakest']:
raise RuntimeError("Invalid/missing method for cycle elimination.")
cut_threshold = px.getParameterByName(trees['method_parameters'], 'cut_threshold')
check_cut_threshold(cut_threshold)
ret = {
'alternatives': alternatives,
'cut_threshold': cut_threshold,
'eliminate_cycles_method': eliminate_cycles_method,
'outranking': outranking,
}
return ret
示例3: parse_xmcda_files
# 需要导入模块: import PyXMCDA [as 别名]
# 或者: from PyXMCDA import getAlternativesID [as 别名]
def parse_xmcda_files(in_weights, in_hierarchy, in_concorlevel, in_criteria, in_alternatives, in_performances):
xml_crit = px.parseValidate(in_criteria)
xml_alt = px.parseValidate(in_alternatives)
xml_pt = px.parseValidate(in_performances)
xml_weight = px.parseValidate(in_weights)
xml_hierarchy = px.parseValidate(in_hierarchy)
xml_concordance = px.parseValidate(in_concorlevel)
if xml_crit == None:
raise ValueError, ["Invalid criteria file"]
if xml_alt == None:
raise ValueError, ["Invalid alternative file"]
if xml_pt == None:
raise ValueError, ["Invalid performance table file"]
if xml_weight == None:
raise ValueError, ["Invalid weight file"]
if xml_hierarchy == None:
raise ValueError, ["Invalid assignment file"]
if xml_concordance == None:
raise ValueError, ["Invalid concordance file"]
try:
alternatives_ids = px.getAlternativesID(xml_alt)
criteria_ids = px.getCriteriaID(xml_crit)
performance_table = px.getPerformanceTable(xml_pt, alternatives_ids, criteria_ids)
criteriaWeight = px.getCriterionValue(xml_weight, criteria_ids, 'Importance')
preferenceDirections = px.getCriteriaPreferenceDirections(xml_crit, criteria_ids)
hierarchyArray = get_hierarchy_array(xml_hierarchy)
criteria_thresholds = px.getConstantThresholds(xml_crit, criteria_ids)
concordanceCutLev = get_criterion_concordance_cutting_level_value(xml_concordance, 'Concordance')
except:
raise ValueError, ["Failed to parse one or more file"]
return
return alternatives_ids, criteria_ids, performance_table, criteriaWeight, preferenceDirections, hierarchyArray, criteria_thresholds, concordanceCutLev
示例4: get_input_data
# 需要导入模块: import PyXMCDA [as 别名]
# 或者: from PyXMCDA import getAlternativesID [as 别名]
def get_input_data(input_dir):
file_names = (
'alternatives.xml',
'categoriesProfiles.xml',
'criteria.xml',
'performanceTable.xml',
'profilesPerformanceTable.xml',
)
trees = get_trees(input_dir, file_names)
alternatives = px.getAlternativesID(trees['alternatives'])
criteria = px.getCriteriaID(trees['criteria'])
pref_directions = px.getCriteriaPreferenceDirections(trees['criteria'], criteria)
thresholds = px.getConstantThresholds(trees['criteria'], criteria)
performances = px.getPerformanceTable(trees['performanceTable'], None, None)
categories_profiles = get_categories_profiles_central(trees['categoriesProfiles'])
profiles_performance_table = px.getPerformanceTable(
trees['profilesPerformanceTable'], None, None
)
ret = {
'alternatives': alternatives,
'categories_profiles': categories_profiles,
'criteria': criteria,
'performances': performances,
'pref_directions': pref_directions,
'profiles_performance_table': profiles_performance_table,
'thresholds': thresholds,
}
return ret
示例5: makeDistilation
# 需要导入模块: import PyXMCDA [as 别名]
# 或者: from PyXMCDA import getAlternativesID [as 别名]
def makeDistilation(
in_selected, in_alternatives, in_credibility, out_descending, out_ascending, out_medianPreorder, out_final
):
xml_alternatives = px.parseValidate(in_alternatives)
xml_selected = px.parseValidate(in_selected)
xml_alternatives = px.parseValidate(in_alternatives)
xml_credibility = px.parseValidate(in_credibility)
if xml_selected == None:
raise ValueError, "Invalid selected file"
if xml_alternatives == None:
raise ValueError, "Invalid alternative file"
if xml_credibility == None:
raise ValueError, "Invalid credibility file"
onCriterion = px.getParameterByName(xml_selected, "selectedCriterion")
alternativesID = px.getAlternativesID(xml_alternatives)
alternativesComparisions = getAlternativesComparisonsAtCriteria(xml_credibility, alternativesID)
if not alternativesComparisions.has_key(onCriterion):
raise ValueError, "Invalid selected criterion"
distillation = Distillation(alternativesID, alternativesComparisions[onCriterion])
output_distillation(out_ascending, distillation.downwards(), "downward distillation", onCriterion)
output_distillation(out_descending, distillation.upwards(), "upward distillation", onCriterion)
output_distillation(out_medianPreorder, distillation.medianPreorder(), "median Preorder", onCriterion)
writeAlternativeComparision(out_final, distillation.intersectionUpDowns, "outranks", onCriterion)
示例6: get_discordance
# 需要导入模块: import PyXMCDA [as 别名]
# 或者: from PyXMCDA import getAlternativesID [as 别名]
def get_discordance(*args, **kwargs):
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
discordance = _get_alternatives_comparisons(
trees['discordance'],
alternatives,
categories_profiles=categories_profiles,
use_partials=use_partials,
)
return discordance # Vividict
示例7: get_input_data
# 需要导入模块: import PyXMCDA [as 别名]
# 或者: from PyXMCDA import getAlternativesID [as 别名]
def get_input_data(input_dir):
file_names = (
'alternatives.xml',
'performanceTable.xml',
'categoriesProfiles.xml',
'criteria.xml',
'profilesPerformanceTable.xml',
)
trees = get_trees(input_dir, file_names)
alternatives = px.getAlternativesID(trees['alternatives'])
criteria = px.getCriteriaID(trees['criteria'])
pref_directions = px.getCriteriaPreferenceDirections(trees['criteria'], criteria)
thresholds = px.getConstantThresholds(trees['criteria'], criteria)
performances = px.getPerformanceTable(trees['performanceTable'], None, None)
profiles_performance_table = px.getPerformanceTable(trees['profilesPerformanceTable'], None, None)
cp_tree = trees['categoriesProfiles']
# we need only categories profiles' names
categories_profiles = [p for p in cp_tree.xpath('//categoriesProfiles//alternativeID/text()')]
ret = {
'alternatives': alternatives,
'categories_profiles': categories_profiles,
'criteria': criteria,
'performances': performances,
'pref_directions': pref_directions,
'profiles_performance_table': profiles_performance_table,
'thresholds': thresholds,
}
return ret
示例8: get_input_data
# 需要导入模块: import PyXMCDA [as 别名]
# 或者: from PyXMCDA import getAlternativesID [as 别名]
def get_input_data(input_dir):
file_names = (
'alternatives.xml',
'concordance.xml',
'method_parameters.xml',
'discordance_binary.xml',
)
trees = get_trees(input_dir, file_names)
alternatives = px.getAlternativesID(trees['alternatives'])
# we can also get alternatives from 'concordance.xml', therefore 'alternatives.xml'
# can be optional - like here:
# alternatives = list(set([i.text for i in trees['concordance'].findall(".//alternativeID")]))
concordance = px.getAlternativesComparisons(trees['concordance'], alternatives)
discordance_binary = px.getAlternativesComparisons(trees['discordance_binary'], alternatives)
cut_threshold = px.getParameterByName(trees['method_parameters'], 'cut_threshold')
check_cut_threshold(cut_threshold)
ret = {
'alternatives': alternatives,
'concordance': concordance,
'cut_threshold': cut_threshold,
'discordance_binary': discordance_binary,
}
return ret
示例9: get_input_data
# 需要导入模块: import PyXMCDA [as 别名]
# 或者: from PyXMCDA import getAlternativesID [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
示例10: get_input_data
# 需要导入模块: import PyXMCDA [as 别名]
# 或者: from PyXMCDA import getAlternativesID [as 别名]
def get_input_data(input_dir):
file_names = (
'alternatives.xml',
'criteria.xml',
'interactions.xml',
'method_parameters.xml',
'performance_table.xml',
'weights.xml',
)
trees = get_trees(input_dir, file_names)
alternatives = px.getAlternativesID(trees['alternatives'])
criteria = px.getCriteriaID(trees['criteria'])
pref_directions = px.getCriteriaPreferenceDirections(trees['criteria'], criteria)
thresholds = px.getConstantThresholds(trees['criteria'], criteria)
weights = px.getCriterionValue(trees['weights'], criteria)
performances = px.getPerformanceTable(trees['performance_table'], 1, 1)
interactions = get_criteria_interactions(trees['interactions'], criteria)
check_net_balance(interactions, weights)
z_function = px.getParameterByName(trees['method_parameters'], 'z_function')
ret = {
'alternatives': alternatives,
'criteria': criteria,
'interactions': interactions,
'performances': performances,
'pref_directions': pref_directions,
'thresholds': thresholds,
'weights': weights,
'z_function': z_function,
}
return ret
示例11: get_input_data
# 需要导入模块: import PyXMCDA [as 别名]
# 或者: from PyXMCDA import getAlternativesID [as 别名]
def get_input_data(input_dir):
file_names = (
'alternatives.xml',
'performanceTable.xml',
'categoriesProfiles.xml',
'criteria.xml',
'profilesPerformanceTable.xml',
'weights.xml',
)
trees = get_trees(input_dir, file_names)
alternatives = px.getAlternativesID(trees['alternatives'])
criteria = px.getCriteriaID(trees['criteria'])
pref_directions = px.getCriteriaPreferenceDirections(trees['criteria'], criteria)
thresholds = px.getConstantThresholds(trees['criteria'], criteria)
weights = px.getCriterionValue(trees['weights'], criteria)
performances = px.getPerformanceTable(trees['performanceTable'], 1, 1)
# we can't assume that categories will be always available as a separate
# input file, therefore it's better to extract them from categoriesProfiles
cp_tree = trees['categoriesProfiles']
categories = list(set(cp_tree.xpath('//categoriesProfiles//limits//categoryID/text()')))
# since we just need names of categories profiles, it's better to get them like below
# - otherwise, to get 'full' categories profiles, we should use this:
# categories_profiles = px.getCategoriesProfiles(trees['categoriesProfiles'], categories)
categories_profiles = [p for p in cp_tree.xpath('//categoriesProfiles//alternativeID/text()')]
# last two args to getPerformanceTable are not used at all anyway...
profiles_performance_table = px.getPerformanceTable(trees['profilesPerformanceTable'], None, None)
ret = {
'alternatives': alternatives,
'categories_profiles': categories_profiles,
'criteria': criteria,
'performances': performances,
'pref_directions': pref_directions,
'profiles_performance_table': profiles_performance_table,
'thresholds': thresholds,
'weights': weights,
}
return ret
示例12: get_concordance
# 需要导入模块: import PyXMCDA [as 别名]
# 或者: from PyXMCDA import getAlternativesID [as 别名]
def get_concordance(*args, **kwargs):
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,
)
concordance = _get_alternatives_comparisons(
trees['concordance'],
alternatives,
categories_profiles,
)
else:
concordance = px.getAlternativesComparisons(
trees['concordance'],
alternatives,
)
return concordance # Vividict, dict
示例13: get_cv_crossed
# 需要导入模块: import PyXMCDA [as 别名]
# 或者: from PyXMCDA import getAlternativesID [as 别名]
def get_cv_crossed(*args, **kwargs):
# 'cv_crossed' stands for 'counter-veto 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
cv_crossed = _get_alternatives_comparisons(
trees['counter_veto_crossed'],
alternatives,
categories_profiles=categories_profiles,
use_partials=True,
mcda_concept='counterVetoCrossed',
)
return cv_crossed # Vividict
示例14: get_input_data
# 需要导入模块: import PyXMCDA [as 别名]
# 或者: from PyXMCDA import getAlternativesID [as 别名]
def get_input_data(input_dir):
file_names = (
'alternatives.xml',
'categoriesProfiles.xml',
'concordance.xml',
'discordances.xml',
)
trees = get_trees(input_dir, file_names)
alternatives = px.getAlternativesID(trees['alternatives'])
cp_tree = trees['categoriesProfiles']
# we need only categories profiles' names
categories_profiles = [p for p in cp_tree.xpath('//categoriesProfiles//alternativeID/text()')]
concordance = getAlternativesComparisons(trees['concordance'], alternatives, categories_profiles)
discordances = getAlternativesComparisons(trees['discordances'], alternatives, categories_profiles, partials=True)
ret = {
'alternatives': alternatives,
'categories_profiles': categories_profiles,
'concordance': concordance,
'discordances': discordances,
}
return ret
示例15: get_input_data
# 需要导入模块: import PyXMCDA [as 别名]
# 或者: from PyXMCDA import getAlternativesID [as 别名]
def get_input_data(input_dir):
file_names = (
'alternatives.xml',
'categoriesProfiles.xml',
'concordance.xml',
'discordances.xml',
)
trees = get_trees(input_dir, file_names)
alternatives = px.getAlternativesID(trees['alternatives'])
categories_profiles = get_categories_profiles_central(trees['categoriesProfiles'])
concordance = getAlternativesComparisons(trees['concordance'], alternatives,
categories_profiles)
discordances = getAlternativesComparisons(trees['discordances'], alternatives,
categories_profiles, partials=True)
ret = {
'alternatives': alternatives,
'categories_profiles': categories_profiles,
'concordance': concordance,
'discordances': discordances,
}
return ret