本文整理匯總了Python中pyomo.core.ConcreteModel.ubs方法的典型用法代碼示例。如果您正苦於以下問題:Python ConcreteModel.ubs方法的具體用法?Python ConcreteModel.ubs怎麽用?Python ConcreteModel.ubs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyomo.core.ConcreteModel
的用法示例。
在下文中一共展示了ConcreteModel.ubs方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: makeTwoTermDisj_IndexedConstraints_BoundedVars
# 需要導入模塊: from pyomo.core import ConcreteModel [as 別名]
# 或者: from pyomo.core.ConcreteModel import ubs [as 別名]
def makeTwoTermDisj_IndexedConstraints_BoundedVars():
# same concept as above, but bounded variables
m = ConcreteModel()
m.s = Set(initialize=[1, 2])
m.lbs = Param(m.s, initialize={1: 2, 2: 4})
m.ubs = Param(m.s, initialize={1: 7, 2: 6})
def bounds_rule(m, s):
return (m.lbs[s], m.ubs[s])
m.a = Var(m.s, bounds=bounds_rule)
def d_rule(disjunct, flag):
m = disjunct.model()
def true_rule(d, s):
return m.a[s] == 0
def false_rule(d, s):
return m.a[s] >= 5
if flag:
disjunct.c = Constraint(m.s, rule=true_rule)
else:
disjunct.c = Constraint(m.s, rule=false_rule)
m.disjunct = Disjunct([0, 1], rule=d_rule)
m.disjunction = Disjunction(expr=[m.disjunct[0], m.disjunct[1]])
return m