本文整理匯總了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