本文整理汇总了Python中common.Common.evalForNum方法的典型用法代码示例。如果您正苦于以下问题:Python Common.evalForNum方法的具体用法?Python Common.evalForNum怎么用?Python Common.evalForNum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common.Common
的用法示例。
在下文中一共展示了Common.evalForNum方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ConstraintNotDominatedByX
# 需要导入模块: from common import Common [as 别名]
# 或者: from common.Common import evalForNum [as 别名]
def ConstraintNotDominatedByX(self, model):
"""
Creates a constraint preventing search in dominated regions.
"""
DisjunctionOrLessMetrics = list()
for i in range(len(self.metrics_variables)):
if self.metrics_objective_direction[i] == Common.METRICS_MAXIMIZE:
DisjunctionOrLessMetrics.append(
SMTLib.SMT_GT(
self.metrics_variables[i],
SMTLib.SMT_IntConst(
Common.evalForNum(model, self.metrics_variables[i].convert(self.cfr.solver.converter))
),
)
) # model[self.metrics_variables[i]])
else:
DisjunctionOrLessMetrics.append(
SMTLib.SMT_LT(
self.metrics_variables[i],
SMTLib.SMT_IntConst(
Common.evalForNum(model, self.metrics_variables[i].convert(self.cfr.solver.converter))
),
)
) # model[self.metrics_variables[i]])
return SMTLib.SMT_Or(*DisjunctionOrLessMetrics)
示例2: ConstraintMustDominatesX
# 需要导入模块: from common import Common [as 别名]
# 或者: from common.Common import evalForNum [as 别名]
def ConstraintMustDominatesX(self, model):
"""
Returns a constraint that a new instance has to be better than the instance represented by model in at least one dimension,
and better or equal in all the other ones.
"""
dominationDisjunction = []
i = 0
for dominatedByMetric in self.metrics_variables:
dominationConjunction = []
j = 0
if self.metrics_objective_direction[i] == Common.METRICS_MAXIMIZE:
dominationConjunction.append(
SMTLib.SMT_GT(
dominatedByMetric,
SMTLib.SMT_IntConst(
Common.evalForNum(model, dominatedByMetric.convert(self.cfr.solver.converter))
),
)
)
else:
dominationConjunction.append(
SMTLib.SMT_LT(
dominatedByMetric,
SMTLib.SMT_IntConst(
Common.evalForNum(model, dominatedByMetric.convert(self.cfr.solver.converter))
),
)
)
for AtLeastEqualInOtherMetric in self.metrics_variables:
if j != i:
if self.metrics_objective_direction[j] == Common.METRICS_MAXIMIZE:
dominationConjunction.append(
SMTLib.SMT_GE(
AtLeastEqualInOtherMetric,
SMTLib.SMT_IntConst(
Common.evalForNum(
model, AtLeastEqualInOtherMetric.convert(self.cfr.solver.converter)
)
),
)
)
else:
dominationConjunction.append(
SMTLib.SMT_LE(
AtLeastEqualInOtherMetric,
SMTLib.SMT_IntConst(
Common.evalForNum(
model, AtLeastEqualInOtherMetric.convert(self.cfr.solver.converter)
)
),
)
)
j = 1 + j
i = 1 + i
dominationDisjunction.append(SMTLib.SMT_And(*dominationConjunction))
constraintDominateX = SMTLib.SMT_Or(*dominationDisjunction)
return constraintDominateX
示例3: ConstraintEqualToX
# 需要导入模块: from common import Common [as 别名]
# 或者: from common.Common import evalForNum [as 别名]
def ConstraintEqualToX(self, model):
"""
Returns a Constraint that a new instance, can't be dominated by the instance represented by model.
(it can't be worst in any objective).
"""
EqualMetrics = list()
for i in range(len(self.metrics_variables)):
EqualMetrics.append(
SMTLib.SMT_EQ(self.metrics_variables[i], Common.evalForNum(model, self.metrics_variables[i]))
)
return SMTLib.SMT_And(EqualMetrics)