本文整理匯總了Python中pyomo.core.ConcreteModel.d1方法的典型用法代碼示例。如果您正苦於以下問題:Python ConcreteModel.d1方法的具體用法?Python ConcreteModel.d1怎麽用?Python ConcreteModel.d1使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyomo.core.ConcreteModel
的用法示例。
在下文中一共展示了ConcreteModel.d1方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_active_parent_block
# 需要導入模塊: from pyomo.core import ConcreteModel [as 別名]
# 或者: from pyomo.core.ConcreteModel import d1 [as 別名]
def test_active_parent_block(self):
m = ConcreteModel()
m.d1 = Block()
m.d1.sub1 = Disjunct()
m.d1.sub2 = Disjunct()
m.d1.disj = Disjunction(expr=[m.d1.sub1, m.d1.sub2])
with self.assertRaises(GDP_Error):
TransformationFactory('gdp.reclassify').apply_to(m)
示例2: makeDisjunctWithRangeSet
# 需要導入模塊: from pyomo.core import ConcreteModel [as 別名]
# 或者: from pyomo.core.ConcreteModel import d1 [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
示例3: test_deactivated_parent_block
# 需要導入模塊: from pyomo.core import ConcreteModel [as 別名]
# 或者: from pyomo.core.ConcreteModel import d1 [as 別名]
def test_deactivated_parent_block(self):
m = ConcreteModel()
m.d1 = Block()
m.d1.sub1 = Disjunct()
m.d1.sub2 = Disjunct()
m.d1.disj = Disjunction(expr=[m.d1.sub1, m.d1.sub2])
m.d1.deactivate()
TransformationFactory('gdp.reclassify').apply_to(m)
self.assertIs(m.d1.type(), Block)
self.assertIs(m.d1.sub1.type(), Block)
self.assertIs(m.d1.sub2.type(), Block)
示例4: test_active_parent_disjunct_target
# 需要導入模塊: from pyomo.core import ConcreteModel [as 別名]
# 或者: from pyomo.core.ConcreteModel import d1 [as 別名]
def test_active_parent_disjunct_target(self):
m = ConcreteModel()
m.d1 = Disjunct()
m.d1.sub1 = Disjunct()
m.d1.sub2 = Disjunct()
m.d1.disj = Disjunction(expr=[m.d1.sub1, m.d1.sub2])
TransformationFactory('gdp.bigm').apply_to(m, targets=m.d1.disj)
m.d1.indicator_var.fix(1)
TransformationFactory('gdp.reclassify').apply_to(m)
self.assertIs(m.d1.type(), Block)
self.assertIs(m.d1.sub1.type(), Block)
self.assertIs(m.d1.sub2.type(), Block)
示例5: test_deactivate_nested_disjunction
# 需要導入模塊: from pyomo.core import ConcreteModel [as 別名]
# 或者: from pyomo.core.ConcreteModel import d1 [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))
示例6: makeNestedDisjunctions_NestedDisjuncts
# 需要導入模塊: from pyomo.core import ConcreteModel [as 別名]
# 或者: from pyomo.core.ConcreteModel import d1 [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