本文整理汇总了Python中pyomo.environ.ConcreteModel.x2方法的典型用法代码示例。如果您正苦于以下问题:Python ConcreteModel.x2方法的具体用法?Python ConcreteModel.x2怎么用?Python ConcreteModel.x2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyomo.environ.ConcreteModel
的用法示例。
在下文中一共展示了ConcreteModel.x2方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_model
# 需要导入模块: from pyomo.environ import ConcreteModel [as 别名]
# 或者: from pyomo.environ.ConcreteModel import x2 [as 别名]
def build_model():
"""Simple non-convex model with many local minima"""
model = ConcreteModel()
model.x1 = Var(initialize=1, bounds=(0, 100))
model.x2 = Var(initialize=5, bounds=(5, 6))
model.x2.fix(5)
model.objtv = Objective(expr=model.x1 * sin(model.x1), sense=maximize)
return model
示例2: test_disjunction_unsat
# 需要导入模块: from pyomo.environ import ConcreteModel [as 别名]
# 或者: from pyomo.environ.ConcreteModel import x2 [as 别名]
def test_disjunction_unsat(self):
m = ConcreteModel()
m.x1 = Var(bounds=(0, 8))
m.x2 = Var(bounds=(0, 8))
m.obj = Objective(expr=m.x1 + m.x2, sense=minimize)
m.y1 = Disjunct()
m.y2 = Disjunct()
m.y1.c1 = Constraint(expr=m.x1 >= 9)
m.y1.c2 = Constraint(expr=m.x2 >= 2)
m.y2.c1 = Constraint(expr=m.x1 >= 3)
m.y2.c2 = Constraint(expr=m.x2 >= 9)
m.djn = Disjunction(expr=[m.y1, m.y2])
self.assertFalse(satisfiable(m))
示例3: build_model
# 需要导入模块: from pyomo.environ import ConcreteModel [as 别名]
# 或者: from pyomo.environ.ConcreteModel import x2 [as 别名]
def build_model():
m = ConcreteModel()
m.x1 = Var(domain=NonNegativeReals, bounds=(0, 8))
m.x2 = Var(domain=NonNegativeReals, bounds=(0, 8))
m.c = Var(domain=NonNegativeReals, bounds=(1, 3))
m.y1 = Disjunct()
m.y2 = Disjunct()
m.y3 = Disjunct()
m.y1.constr1 = Constraint(expr=m.x1**2 + m.x2**2 - 1 <= 0)
m.y1.constr2 = Constraint(expr=m.c == 2)
m.y2.constr1 = Constraint(expr=(m.x1 - 4)**2 + (m.x2 - 1)**2 - 1 <= 0)
m.y2.constr2 = Constraint(expr=m.c == 1)
m.y3.constr1 = Constraint(expr=(m.x1 - 2)**2 + (m.x2 - 4)**2 - 1 <= 0)
m.y3.constr2 = Constraint(expr=m.c == 3)
m.GPD123 = Disjunction(expr=[m.y1, m.y2, m.y3])
m.obj = Objective(expr=(m.x1 - 3)**2 + (m.x2 - 2)**2 + m.c, sense=minimize)
return m
示例4: test_multiple_disjunctions_sat
# 需要导入模块: from pyomo.environ import ConcreteModel [as 别名]
# 或者: from pyomo.environ.ConcreteModel import x2 [as 别名]
def test_multiple_disjunctions_sat(self):
m = ConcreteModel()
m.x1 = Var(bounds=(0, 8))
m.x2 = Var(bounds=(0, 8))
m.obj = Objective(expr=m.x1 + m.x2, sense=minimize)
m.y1 = Disjunct()
m.y2 = Disjunct()
m.y1.c1 = Constraint(expr=m.x1 >= 2)
m.y1.c2 = Constraint(expr=m.x2 >= 2)
m.y2.c1 = Constraint(expr=m.x1 >= 1)
m.y2.c2 = Constraint(expr=m.x2 >= 1)
m.djn1 = Disjunction(expr=[m.y1, m.y2])
m.z1 = Disjunct()
m.z2 = Disjunct()
m.z1.c1 = Constraint(expr=m.x1 <= 1)
m.z1.c2 = Constraint(expr=m.x2 <= 1)
m.z2.c1 = Constraint(expr=m.x1 <= 0)
m.z2.c2 = Constraint(expr=m.x2 <= 0)
m.djn2 = Disjunction(expr=[m.z1, m.z2])
self.assertTrue(satisfiable(m))