本文整理汇总了Python中pyomo.core.ConcreteModel.simpledisjunct方法的典型用法代码示例。如果您正苦于以下问题:Python ConcreteModel.simpledisjunct方法的具体用法?Python ConcreteModel.simpledisjunct怎么用?Python ConcreteModel.simpledisjunct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyomo.core.ConcreteModel
的用法示例。
在下文中一共展示了ConcreteModel.simpledisjunct方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: makeNestedDisjunctions
# 需要导入模块: from pyomo.core import ConcreteModel [as 别名]
# 或者: from pyomo.core.ConcreteModel import simpledisjunct [as 别名]
def makeNestedDisjunctions():
m = ConcreteModel()
m.x = Var(bounds=(-9, 9))
m.z = Var(bounds=(0, 10))
m.a = Var(bounds=(0, 23))
def disjunct_rule(disjunct, flag):
m = disjunct.model()
if flag:
def innerdisj_rule(disjunct, flag):
m = disjunct.model()
if flag:
disjunct.c = Constraint(expr=m.z >= 5)
else:
disjunct.c = Constraint(expr=m.z == 0)
disjunct.innerdisjunct = Disjunct([0, 1], rule=innerdisj_rule)
@disjunct.Disjunction([0])
def innerdisjunction(b, i):
return [b.innerdisjunct[0], b.innerdisjunct[1]]
disjunct.c = Constraint(expr=m.a <= 2)
else:
disjunct.c = Constraint(expr=m.x == 2)
m.disjunct = Disjunct([0, 1], rule=disjunct_rule)
# I want a SimpleDisjunct with a disjunction in it too
def simpledisj_rule(disjunct):
m = disjunct.model()
@disjunct.Disjunct()
def innerdisjunct0(disjunct):
disjunct.c = Constraint(expr=m.x <= 2)
@disjunct.Disjunct()
def innerdisjunct1(disjunct):
disjunct.c = Constraint(expr=m.x >= 4)
disjunct.innerdisjunction = Disjunction(
expr=[disjunct.innerdisjunct0, disjunct.innerdisjunct1])
m.simpledisjunct = Disjunct(rule=simpledisj_rule)
m.disjunction = Disjunction(
expr=[m.simpledisjunct, m.disjunct[0], m.disjunct[1]])
return m