本文整理匯總了Python中PyXMCDA.getCriteriaUpperBounds方法的典型用法代碼示例。如果您正苦於以下問題:Python PyXMCDA.getCriteriaUpperBounds方法的具體用法?Python PyXMCDA.getCriteriaUpperBounds怎麽用?Python PyXMCDA.getCriteriaUpperBounds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyXMCDA
的用法示例。
在下文中一共展示了PyXMCDA.getCriteriaUpperBounds方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: import PyXMCDA [as 別名]
# 或者: from PyXMCDA import getCriteriaUpperBounds [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
#.........這裏部分代碼省略.........