本文整理汇总了Python中pyomo.core.ConcreteModel.disj方法的典型用法代码示例。如果您正苦于以下问题:Python ConcreteModel.disj方法的具体用法?Python ConcreteModel.disj怎么用?Python ConcreteModel.disj使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyomo.core.ConcreteModel
的用法示例。
在下文中一共展示了ConcreteModel.disj方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: makeDisjunctWithRangeSet
# 需要导入模块: from pyomo.core import ConcreteModel [as 别名]
# 或者: from pyomo.core.ConcreteModel import disj [as 别名]
def makeDisjunctWithRangeSet():
m = ConcreteModel()
m.x = Var(bounds=(0, 1))
m.d1 = Disjunct()
m.d1.s = RangeSet(1)
m.d1.c = Constraint(rule=lambda _: m.x == 1)
m.d2 = Disjunct()
m.disj = Disjunction(expr=[m.d1, m.d2])
return m
示例2: test_deactivate_nested_disjunction
# 需要导入模块: from pyomo.core import ConcreteModel [as 别名]
# 或者: from pyomo.core.ConcreteModel import disj [as 别名]
def test_deactivate_nested_disjunction(self):
m = ConcreteModel()
m.d1 = Disjunct()
m.d1.d1 = Disjunct()
m.d1.d2 = Disjunct()
m.d1.disj = Disjunction(expr=[m.d1.d1, m.d1.d2])
m.d2 = Disjunct()
m.disj = Disjunction(expr=[m.d1, m.d2])
m.d1.deactivate()
TransformationFactory('gdp.bigm').apply_to(m)
# for disj in m.component_data_objects(Disjunction, active=True):
# print(disj.name)
# There should be no active Disjunction objects.
self.assertIsNone(
next(m.component_data_objects(Disjunction, active=True), None))
示例3: makeNestedDisjunctions_NestedDisjuncts
# 需要导入模块: from pyomo.core import ConcreteModel [as 别名]
# 或者: from pyomo.core.ConcreteModel import disj [as 别名]
def makeNestedDisjunctions_NestedDisjuncts():
m = ConcreteModel()
m.x = Var(bounds=(0, 2))
m.obj = Objective(expr=m.x)
m.d1 = Disjunct()
m.d1.c = Constraint(expr=m.x >= 1)
m.d2 = Disjunct()
m.d2.c = Constraint(expr=m.x >= 1.1)
m.d1.d3 = Disjunct()
m.d1.d3.c = Constraint(expr=m.x >= 1.2)
m.d1.d4 = Disjunct()
m.d1.d4.c = Constraint(expr=m.x >= 1.3)
m.disj = Disjunction(expr=[m.d1, m.d2])
m.d1.disj2 = Disjunction(expr=[m.d1.d3, m.d1.d4])
return m