def create_hull_model(self): m = ConcreteModel() m.p = Var([1, 2], bounds=(0, 10)) m.time1 = Disjunction(expr=[m.p[1] >= 1, m.p[1] == 0]) m.on = Disjunct() m.on.above_min = Constraint(expr=m.p[2] >= 1) m.on.ramping = Constraint(expr=m.p[2] - m.p[1] <= 3) m.on.on_before = Constraint(expr=m.p[1] >= 1) m.startup = Disjunct() m.startup.startup_limit = Constraint(expr=(1, m.p[2], 2)) m.startup.off_before = Constraint(expr=m.p[1] == 0) m.off = Disjunct() m.off.off = Constraint(expr=m.p[2] == 0) m.time2 = Disjunction(expr=[m.on, m.startup, m.off]) m.obj = Objective(expr=m.p[1] + m.p[2]) hull = TransformationFactory('gdp.hull') hull.apply_to(m) disaggregatedVars = ComponentSet([ hull.get_disaggregated_var(m.p[1], m.time1.disjuncts[0]), hull.get_disaggregated_var(m.p[1], m.time1.disjuncts[1]), hull.get_disaggregated_var(m.p[1], m.on), hull.get_disaggregated_var(m.p[2], m.on), hull.get_disaggregated_var(m.p[1], m.startup), hull.get_disaggregated_var(m.p[2], m.startup), hull.get_disaggregated_var(m.p[1], m.off), hull.get_disaggregated_var(m.p[2], m.off) ]) return m, disaggregatedVars
def create_chull_model(self): m = ConcreteModel() m.p = Var([1, 2], bounds=(0, 10)) m.time1 = Disjunction(expr=[m.p[1] >= 1, m.p[1] == 0]) m.on = Disjunct() m.on.above_min = Constraint(expr=m.p[2] >= 1) m.on.ramping = Constraint(expr=m.p[2] - m.p[1] <= 3) m.on.on_before = Constraint(expr=m.p[1] >= 1) m.startup = Disjunct() m.startup.startup_limit = Constraint(expr=(1, m.p[2], 2)) m.startup.off_before = Constraint(expr=m.p[1] == 0) m.off = Disjunct() m.off.off = Constraint(expr=m.p[2] == 0) m.time2 = Disjunction(expr=[m.on, m.startup, m.off]) m.obj = Objective(expr=m.p[1] + m.p[2]) chull = TransformationFactory('gdp.chull') chull.apply_to(m) disaggregatedVars = ComponentSet([ chull.get_disaggregated_var(m.p[1], m.time1.disjuncts[0]), chull.get_disaggregated_var(m.p[1], m.time1.disjuncts[1]), chull.get_disaggregated_var(m.p[1], m.on), chull.get_disaggregated_var(m.p[2], m.on), chull.get_disaggregated_var(m.p[1], m.startup), chull.get_disaggregated_var(m.p[2], m.startup), chull.get_disaggregated_var(m.p[1], m.off), chull.get_disaggregated_var(m.p[2], m.off) ]) # from nose.tools import set_trace # set_trace() # disaggregatedVars = ComponentSet([relaxationBlocks[0].component("p[1]"), # relaxationBlocks[1].component("p[1]"), # relaxationBlocks[2].component("p[1]"), # relaxationBlocks[2].component("p[2]"), # relaxationBlocks[3].component("p[1]"), # relaxationBlocks[3].component("p[2]"), # relaxationBlocks[4].component("p[1]"), # relaxationBlocks[4].component("p[2]")]) return m, disaggregatedVars