def test_equality_constraints_on_disjuncts_with_fme(self): m = models.oneVarDisj_2pts() m.obj.expr = m.x + m.disj1.indicator_var m.obj.sense = maximize TransformationFactory('gdp.cuttingplane').apply_to( m, create_cuts=create_cuts_fme, post_process_cut=None, verbose=True, solver='gurobi', # don't actually need this, but taking the excuse to set solver # options solver_options={'FeasibilityTol': 1e-8}, cuts_name="cuts", bigM=5) # rBigM first iteration solve will give (x = 3, Y = 0.6). If we don't # catch equality constraints, we don't get a cut. But we need to get # x + Y <= 1. (Where Y is the indicator that x = 0). self.assertEqual(len(m.cuts), 1) cut = m.cuts[0] self.assertEqual(cut.lower, 0) self.assertIsNone(cut.upper) repn = generate_standard_repn(cut.body) self.assertTrue(repn.is_linear()) self.assertEqual(len(repn.linear_vars), 2) self.assertIs(repn.linear_vars[0], m.disj1.indicator_var) self.assertEqual(repn.linear_coefs[0], 1) self.assertIs(repn.linear_vars[1], m.x) self.assertEqual(repn.linear_coefs[1], -1)
def test_no_cuts_for_optimal_m_inf_norm(self): m = models.oneVarDisj_2pts() TransformationFactory('gdp.cuttingplane').apply_to( m, norm=float('inf'), post_process_cut=None ) self.check_no_cuts_for_optimal_m(m)
def test_no_cuts_for_optimal_m_fme(self): m = models.oneVarDisj_2pts() TransformationFactory('gdp.cuttingplane').apply_to( m, create_cuts=create_cuts_fme, post_process_cut=None ) self.check_no_cuts_for_optimal_m(m)
def test_no_cuts_for_optimal_m(self): m = models.oneVarDisj_2pts() TransformationFactory('gdp.cuttingplane').apply_to(m) self.check_no_cuts_for_optimal_m(m)