Example #1
0
 def test_disjunct_not_in_disjunction(self):
     m = pe.ConcreteModel()
     m.x = pe.Var()
     m.d1 = gdp.Disjunct()
     m.d1.c = pe.Constraint(expr=m.x == 1)
     m.d2 = gdp.Disjunct()
     m.d2.c = pe.Constraint(expr=m.x == 0)
     pe.TransformationFactory('gdp.bigm').apply_to(m)
     log = StringIO()
     with LoggingIntercept(log, 'pyomo.gdp', logging.WARNING):
         check_model_algebraic(m)
     self.assertRegexpMatches(log.getvalue(),
                              '.*not found in any Disjunctions.*')
 def test_disjunct_not_in_active_disjunction(self):
     m = pyo.ConcreteModel()
     m.x = pyo.Var()
     m.d1 = Disjunct()
     m.d1.c = pyo.Constraint(expr=m.x == 1)
     m.d2 = Disjunct()
     m.d2.c = pyo.Constraint(expr=m.x == 0)
     m.disjunction = Disjunction(expr=[m.d1, m.d2])
     m.disjunction.deactivate()
     pyo.TransformationFactory('gdp.bigm').apply_to(m)
     log = StringIO()
     with LoggingIntercept(log, 'pyomo.gdp', logging.WARNING):
         check_model_algebraic(m)
     self.assertRegexpMatches(
         log.getvalue(), '.*While it participates in a Disjunction, '
         'that Disjunction is currently deactivated.*')