def test_improper_basic_step_simpleConstraint(self): m = models.makeTwoTermDisj() m.simple = Constraint(expr=m.x <= m.a + 1) m.basic_step = apply_basic_step([m.disjunction, m.simple]) self.check_after_improper_basic_step(m) self.assertFalse(m.simple.active) self.assertFalse(m.disjunction.active)
def test_improper_basic_step_constraintData(self): m = models.makeTwoTermDisj() @m.Constraint([1, 2]) def indexed(m, i): return m.x <= m.a + i m.basic_step = apply_basic_step([m.disjunction, m.indexed[1]]) self.check_after_improper_basic_step(m) self.assertFalse(m.indexed[1].active) self.assertTrue(m.indexed[2].active) self.assertFalse(m.disjunction.active)
def test_indicator_var_references(self): m = models.makeTwoTermDisj() m.simple = Constraint(expr=m.x <= m.a + 1) m.basic_step = apply_basic_step([m.disjunction, m.simple]) refs = [ v for v in m.basic_step.component_data_objects( BooleanVar, sort=SortComponents.deterministic) ] self.assertEqual(len(refs), 2) self.assertIs(refs[0][None], m.d[0].indicator_var) self.assertIs(refs[1][None], m.d[1].indicator_var)
def test_improper_basic_step_indexedConstraint(self): m = models.makeTwoTermDisj() @m.Constraint([1, 2]) def indexed(m, i): return m.x <= m.a + i m.basic_step = apply_basic_step([m.disjunction, m.indexed]) for disj in m.basic_step.disjuncts.values(): self.assertEqual(len(disj.improper_constraints), 2) cons = disj.improper_constraints[1] self.check_constraint_body(m, cons, -1) cons = disj.improper_constraints[2] self.check_constraint_body(m, cons, -2)