當前位置: 首頁>>代碼示例>>Python>>正文


Python ConcreteModel.third_stage方法代碼示例

本文整理匯總了Python中pyomo.core.ConcreteModel.third_stage方法的典型用法代碼示例。如果您正苦於以下問題:Python ConcreteModel.third_stage方法的具體用法?Python ConcreteModel.third_stage怎麽用?Python ConcreteModel.third_stage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pyomo.core.ConcreteModel的用法示例。


在下文中一共展示了ConcreteModel.third_stage方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: build_model

# 需要導入模塊: from pyomo.core import ConcreteModel [as 別名]
# 或者: from pyomo.core.ConcreteModel import third_stage [as 別名]
def build_model():
    """
    Base Model

    Optimal solution:
    Select units 1, 3, 8
    Objective value -36.62
    """
    m = ConcreteModel()
    m.streams = RangeSet(25)
    m.x = Var(m.streams, bounds=(0, 50), initialize=5)

    m.stage1_split = Constraint(expr=m.x[1] == m.x[2] + m.x[4])
    m.first_stage = Disjunction(expr=[
        [
            # Unit 1
            m.x[2] == exp(m.x[3]) - 1,
            m.x[4] == 0, m.x[5] == 0
        ],
        [
            # Unit 2
            m.x[5] == log(m.x[4] + 1),
            m.x[2] == 0, m.x[3] == 0
        ]
    ])
    m.stage1_mix = Constraint(expr=m.x[3] + m.x[5] == m.x[6])
    m.stage2_split = Constraint(expr=m.x[6] == sum(m.x[i] for i in (7, 9, 11, 13)))
    m.second_stage = Disjunction(expr=[
        [
            # Unit 3
            m.x[8] == 2 * log(m.x[7]) + 3,
            m.x[7] >= 0.2,
        ] + [m.x[i] == 0 for i in (9, 10, 11, 12, 14, 15)],
        [
            # Unit 4
            m.x[10] == 1.8 * log(m.x[9] + 4),
        ] + [m.x[i] == 0 for i in (7, 8, 11, 12, 14, 15)],
        [
            # Unit 5
            m.x[12] == 1.2 * log(m.x[11]) + 2,
            m.x[11] >= 0.001,
        ] + [m.x[i] == 0 for i in (7, 8, 9, 10, 14, 15)],
        [
            # Unit 6
            m.x[15] == sqrt(m.x[14] - 3) * m.x[23] + 1,
            m.x[14] >= 5, m.x[14] <= 20,
        ] + [m.x[i] == 0 for i in (7, 8, 9, 10, 11, 12)]
    ])
    m.stage2_special_mix = Constraint(expr=m.x[14] == m.x[13] + m.x[23])
    m.stage2_mix = Constraint(expr=sum(m.x[i] for i in (8, 10, 12, 15)) == m.x[16])
    m.stage3_split = Constraint(expr=m.x[16] == sum(m.x[i] for i in (17, 19, 21)))
    m.third_stage = Disjunction(expr=[
        [
            # Unit 7
            m.x[18] == m.x[17] * 0.9,
        ] + [m.x[i] == 0 for i in (19, 20, 21, 22)],
        [
            # Unit 8
            m.x[20] == log(m.x[19] ** 1.5) + 2,
            m.x[19] >= 1,
        ] + [m.x[i] == 0 for i in (17, 18, 21, 22)],
        [
            # Unit 9
            m.x[22] == log(m.x[21] + sqrt(m.x[21])) + 1,
            m.x[21] >= 4,
        ] + [m.x[i] == 0 for i in (17, 18, 19, 20)]
    ])
    m.stage3_special_split = Constraint(expr=m.x[22] == m.x[23] + m.x[24])
    m.stage3_mix = Constraint(expr=m.x[25] == sum(m.x[i] for i in (18, 20, 24)))

    m.obj = Objective(expr=-10 * m.x[25] + m.x[1])

    return m
開發者ID:Pyomo,項目名稱:pyomo,代碼行數:75,代碼來源:small_process.py


注:本文中的pyomo.core.ConcreteModel.third_stage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。