本文整理汇总了Python中PyXMCDA.getVetos方法的典型用法代码示例。如果您正苦于以下问题:Python PyXMCDA.getVetos方法的具体用法?Python PyXMCDA.getVetos怎么用?Python PyXMCDA.getVetos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyXMCDA
的用法示例。
在下文中一共展示了PyXMCDA.getVetos方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import PyXMCDA [as 别名]
# 或者: from PyXMCDA import getVetos [as 别名]
#.........这里部分代码省略.........
except:
errorList.append("There is no defined weight for criterion " + crit + ".")
if not errorList:
# We recover the criteria preference directions
# criteriaDir = PyXMCDA.getCriteriaPreferenceDirections (xmltree_criteria, criteriaId)
# Plus necessaire
# We compute the alternative comparisons values
fileAltValues = open(out_dir + "/alternativesComparisons.xml", "w")
PyXMCDA.writeHeader(fileAltValues)
# We write some information about the generated file
fileAltValues.write(
"\t<projectReference>\n\t\t<title>Rubis outranking relation</title>\n\t\t<version>"
+ VERSION
+ "</version>\n\t\t<author>ws_PyXMCDA suite (TV)</author>\n\t</projectReference>\n\n"
)
fileAltValues.write("\t<alternativesComparisons>\n\t\t<pairs>\n")
# ATTENTION Solution rustine
# On retourne ici le tableau de perf pour les criteres a minimiser
# Devra etre fait par le getRubisElementaryOutranking
criteriaDir = PyXMCDA.getCriteriaPreferenceDirections(xmltree_criteria, criteriaId)
for crit in criteriaId:
if criteriaDir[crit] == "min":
for alt in alternativesId:
perfTable[alt][crit] = -perfTable[alt][crit]
ElemOut = PyXMCDA.getRubisElementaryOutranking(alternativesId, criteriaId, perfTable, thresholds)
tabVetos = PyXMCDA.getVetos(alternativesId, criteriaId, perfTable, thresholds)
for alt1 in alternativesId:
for alt2 in alternativesId:
fileAltValues.write(
"\t\t\t<pair>\n\t\t\t\t<initial><alternativeID>"
+ alt1
+ "</alternativeID></initial>\n\t\t\t\t<terminal><alternativeID>"
+ alt2
+ "</alternativeID></terminal>\n"
)
# Verifier s'il manque des valeurs !!! try expect
# fileAltValues.write ("\t\t\t\t<value><NA>not available</NA></value>\n\t\t\t</pair>\n")
sum = 0.0
isVeto = 0
isWeakVeto = 0
for crit in criteriaId:
sum += ElemOut[alt1][alt2][crit] * weights[crit]
# On verifie si un veto est leve
if (
tabVetos.has_key(alt1)
and tabVetos[alt1].has_key(alt2)
and tabVetos[alt1][alt2].has_key(crit)
and tabVetos[alt1][alt2][crit] == 1
):
isVeto = 1
# On verifie si un veto faible est leve
示例2: create_ampl_reverse_data
# 需要导入模块: import PyXMCDA [as 别名]
# 或者: from PyXMCDA import getVetos [as 别名]
def create_ampl_reverse_data (file, altId, critId, perfTable, altComparisons, thresholds, maxWeight, criComparisons, criLB, criUB, criIndLB, criIndUB, criPreLB, criPreUB) :
#Les contraintes du style g_i > g_j
for crit in critId :
file.write('set cr_'+crit+' := {"'+crit+'"};\n')
#Un compteur pour numeroter les contraintes et les ensembles
count = 1
for comp in criComparisons :
# On ecrit l'ensemble des neuds initiaux
file.write('\nset crs_init_'+str(count)+' := {')
file.write(PyXMCDA.getListOnString (comp["initial"], '"', '"', ', '))
file.write('};\n')
# On ecrit l'ensemble des noeuds terminaux
file.write('set crs_term_'+str(count)+' := {')
file.write(PyXMCDA.getListOnString (comp["terminal"], '"', '"', ', '))
file.write('};\n')
file.write("s.t. ct_comp_"+str(count)+" : sum{init in crs_init_"+str(count)+"} sum {k in WEIGHTUNIT} Accumulator[init,k] >= sum{term in crs_term_"+str(count)+"} sum {k in WEIGHTUNIT} Accumulator[term,k] +1;\n")
count = count + 1
#Les contraintes du style g_i > lower_bound_i
file.write("\n")
for crit in criLB.keys() :
file.write("s.t. ct_LB_"+crit+"{j in cr_"+crit+"} : sum {k in WEIGHTUNIT} Accumulator[j,k] >= "+str(criLB[crit])+";\n")
#Les contraintes du style g_i < upper_bound_i
file.write("\n")
for crit in criUB.keys() :
file.write("s.t. ct_UB_"+crit+"{j in cr_"+crit+"} : sum {k in WEIGHTUNIT} Accumulator[j,k] <= "+str(criUB[crit])+";\n")
#Les contraintes du style q_i > lower_bound_i
file.write("\n")
for crit in criIndLB.keys() :
file.write("s.t. ct_q_LB_"+crit+"{j in cr_"+crit+"} : " + str(criIndLB[crit]) + " <= q[j];\n")
#Les contraintes du style q_i < upper_bound_i
file.write("\n")
for crit in criIndUB.keys() :
file.write("s.t. ct_q_UB_"+crit+"{j in cr_"+crit+"} : q[j] <= " + str(criIndUB[crit]) + ";\n")
#Les contraintes du style p_i > lower_bound_i
file.write("\n")
for crit in criPreLB.keys() :
file.write("s.t. ct_p_LB_"+crit+"{j in cr_"+crit+"} : " + str(criPreLB[crit]) + " <= p[j];\n")
#Les contraintes du style p_i < upper_bound_i
file.write("\n")
for crit in criPreUB.keys() :
file.write("s.t. ct_p_UB_"+crit+"{j in cr_"+crit+"} : p[j] <= " + str(criPreUB[crit]) + ";\n")
file.write ("\n\n\ndata;\n\n")
file.write ("set CRITERIA := ")
for c in critId :
file.write (c+" ")
file.write(";\n\n")
pairs2 = []
pairsm2 = []
pairs1 = []
pairsm1 = []
tabVeto = PyXMCDA.getVetos (altId, critId, perfTable, thresholds)
for init in altComparisons.keys() :
for term in altComparisons[init].keys() :
if tabVeto.has_key(init) and tabVeto[init].has_key(term) and not tabVeto[init][term] is None :
# Veto situation
continue
if init != term :
val = altComparisons[init][term]
if val == 2 :
pairs2.append (""+init+term)
elif val == -2 :
pairsm2.append (""+init+term)
elif val == 1 :
pairs1.append (""+init+term)
elif val == -1 :
pairsm1.append (""+init+term)
else:
# On met une valeur pour dire que l'on n'a pas pris en compte cette valeur
altComparisons[init][term] = 0
file.write ("set ROBUSTPREFPAIRS :=\n")
count = 0
for pair in pairs2 :
count = count + 1
file.write (pair+" ")
if count == 10 :
count = 0
file.write ("\n")
file.write (";\n\nset ROBUSTnotPREFPAIRS :=\n")
count = 0
for pair in pairsm2 :
#.........这里部分代码省略.........
示例3: create_ampl_reverse_data
# 需要导入模块: import PyXMCDA [as 别名]
# 或者: from PyXMCDA import getVetos [as 别名]
def create_ampl_reverse_data (file, altId, critId, perfTable, altComparisons, thresholds, maxWeight, criComparisons, criLB, criUB) :
#Les contraintes du style g_i > g_j
for crit in critId :
file.write('set cr_'+crit+' := {"'+crit+'"};\n')
#Un compteur pour numeroter les contraintes et les ensembles
count = 1
for comp in criComparisons :
# On ecrit l'ensemble des neuds initiaux
file.write('\nset crs_init_'+str(count)+' := {')
file.write(PyXMCDA.getListOnString (comp["initial"], '"', '"', ', '))
file.write('};\n')
# On ecrit l'ensemble des noeuds terminaux
file.write('set crs_term_'+str(count)+' := {')
file.write(PyXMCDA.getListOnString (comp["terminal"], '"', '"', ', '))
file.write('};\n')
file.write("s.t. ct_comp_"+str(count)+" : sum{init in crs_init_"+str(count)+"} sum {k in WEIGHTUNIT} Accumulator[init,k] >= sum{term in crs_term_"+str(count)+"} sum {k in WEIGHTUNIT} Accumulator[term,k] +1;\n")
count = count + 1
#Les contraintes du style g_i > lower_bound_i
file.write("\n")
for crit in criLB.keys() :
file.write("s.t. ct_LB_"+crit+"{i in cr_"+crit+"} : sum {k in WEIGHTUNIT} Accumulator[i,k] >= "+str(criLB[crit])+";\n")
#Les contraintes du style g_i < upper_bound_i
file.write("\n")
for crit in criUB.keys() :
file.write("s.t. ct_UB_"+crit+"{i in cr_"+crit+"} : sum {k in WEIGHTUNIT} Accumulator[i,k] <= "+str(criUB[crit])+";\n")
file.write ("\n\n\ndata;\n\n")
file.write ("set CRITERIA := ")
for c in critId :
file.write (c+" ")
file.write(";\n\nset ALLPAIRS :=\n")
for a1 in altId :
for a2 in altId :
file.write (a1+a2+" ")
file.write ("\n")
file.write (";\n\n")
pairs2 = []
pairsm2 = []
pairs1 = []
pairsm1 = []
tabVeto = PyXMCDA.getVetos (altId, critId, perfTable, thresholds)
for init in altComparisons.keys() :
for term in altComparisons[init].keys() :
if tabVeto.has_key(init) and tabVeto[init].has_key(term) and not tabVeto[init][term] is None :
# Veto situation
continue
if init != term :
val = altComparisons[init][term]
if val == 2 :
pairs2.append (""+init+term)
elif val == -2 :
pairsm2.append (""+init+term)
elif val == 1 :
pairs1.append (""+init+term)
elif val == -1 :
pairsm1.append (""+init+term)
file.write ("set ROBUSTPREFPAIRS :=\n")
count = 0
for pair in pairs2 :
count = count + 1
file.write (pair+" ")
if count == 10 :
count = 0
file.write ("\n")
file.write (";\n\nset ROBUSTnotPREFPAIRS :=\n")
count = 0
for pair in pairsm2 :
count = count + 1
file.write (pair+" ")
if count == 10 :
count = 0
file.write ("\n")
file.write (";\n\nset SIMPLEPREFPAIRS :=\n")
count = 0
for pair in pairs1 :
count = count + 1
file.write (pair+" ")
if count == 10 :
count = 0
file.write ("\n")
file.write (";\n\nset SIMPLEnotPREFPAIRS :=\n")
count = 0
for pair in pairsm1 :
count = count + 1
file.write (pair+" ")
if count == 10 :
count = 0
#.........这里部分代码省略.........