当前位置: 首页>>代码示例>>Python>>正文


Python PyXMCDA.getCriteriaLowerBounds方法代码示例

本文整理汇总了Python中PyXMCDA.getCriteriaLowerBounds方法的典型用法代码示例。如果您正苦于以下问题:Python PyXMCDA.getCriteriaLowerBounds方法的具体用法?Python PyXMCDA.getCriteriaLowerBounds怎么用?Python PyXMCDA.getCriteriaLowerBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyXMCDA的用法示例。


在下文中一共展示了PyXMCDA.getCriteriaLowerBounds方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: import PyXMCDA [as 别名]
# 或者: from PyXMCDA import getCriteriaLowerBounds [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
	
	critAverage = {}
	critNormalSD = {}
	critTriangSD = {}
	
	# Creating a list for error messages
	errorList = []
	
	# If some mandatory input files are missing
	if not os.path.isfile (in_dir+"/alternatives.xml") or not os.path.isfile (in_dir+"/criteria.xml") :
		errorList.append("Some input files are missing")
	
	else :
		
		# We parse all the mandatory input files
		xmltree_alternatives = PyXMCDA.parseValidate(in_dir+"/alternatives.xml")
		xmltree_criteria = PyXMCDA.parseValidate(in_dir+"/criteria.xml")
		
		# We check if all madatory input files are valid
		if xmltree_alternatives == None :
			errorList.append("The alternatives file can't be validated.")
		if xmltree_criteria == None :
			errorList.append("The criteria file can't be validated.")
	
		if not errorList :
		
			alternativesId = PyXMCDA.getAlternativesID(xmltree_alternatives)
			criteriaId = PyXMCDA.getCriteriaID(xmltree_criteria)
			
			if not alternativesId :
				errorList.append("No alternatives found. Is your alternatives file correct ?")
			if not criteriaId :
				errorList.append("No criteria found. Is your criteria file correct ?")
	
	if not errorList :
	
		# We check if parameters for criteria distribution profile have been provided
		if os.path.isfile (in_dir+"/criteriaProfiles.xml") :
			xmltree_CritProfile = PyXMCDA.parseValidate(in_dir+"/criteriaProfiles.xml")
			if xmltree_CritProfile == None :
				errorList.append ("criteriaProfiles file can't be validated.")
			else :
				critAverage = PyXMCDA.getNamedParametersByName (xmltree_CritProfile, "distributionAverage")
				critNormalSD = PyXMCDA.getNamedParametersByName (xmltree_CritProfile, "normalDistributionStandardDeviation")
				critTriangSD = PyXMCDA.getNamedParametersByName (xmltree_CritProfile, "triangularDistributionStandardDeviation")
				# ...
				
	if not errorList :
	
		# We check if a seed is provided for the random generation
		if os.path.isfile (in_dir+"/seed.xml") :
			xmltree_seed = PyXMCDA.parseValidate(in_dir+"/seed.xml")
			if xmltree_seed == None :
				errorList.append ("seed file can't be validated.")
			else :
				seed = PyXMCDA.getParameterByName (xmltree_seed, "seed")
				if not isinstance(seed,int) :
					errorList.append ("seed value should be a strictly positive integer")
				else :
					if seed <= 0 :
						errorList.append ("seed should be a strictly positive integer")
					else:
						# We initialize the random generator
						random.seed(seed)
						
	if not errorList :
	
		for i in range(20):
			print random.random()
	
		# We recover criteria scale information
		criteriaTypes = PyXMCDA.getCriteriaScalesTypes (xmltree_criteria, criteriaId)
		criteriaDir = PyXMCDA.getCriteriaPreferenceDirections (xmltree_criteria, criteriaId)
		criteriaUB = PyXMCDA.getCriteriaUpperBounds (xmltree_criteria, criteriaId)
		criteriaLB = PyXMCDA.getCriteriaLowerBounds (xmltree_criteria, criteriaId)
		criteriaRL = PyXMCDA.getCriteriaRankedLabel (xmltree_criteria, criteriaId)
		
		# We add some default lower and upper bounds
		for crit in criteriaId :
			if not criteriaLB.has_key (crit) or criteriaLB[crit] == None :
				if criteriaTypes[crit] == "quantitative" :
					criteriaLB[crit] = 0.0
				else :
					criteriaLB[crit] = 1
			if not criteriaUB.has_key (crit) or criteriaUB[crit] == None :
				if criteriaTypes[crit] == "quantitative" :
					criteriaUB[crit] = 100.0
#.........这里部分代码省略.........
开发者ID:quiewbee,项目名称:ws-PyXMCDA,代码行数:103,代码来源:randomPerformanceTable.py


注:本文中的PyXMCDA.getCriteriaLowerBounds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。