def test_nested_disjunctions_max_binary(self): m = models.makeNestedNonlinearModel() SolverFactory('gdpopt').solve(m, strategy='LOA', mip_solver=mip_solver, nlp_solver=nlp_solver, init_strategy='max_binary') self.assertAlmostEqual(value(m.x), sqrt(2)/2) self.assertAlmostEqual(value(m.y), sqrt(2)/2)
def test_nested_disjunctions_set_covering(self): # This test triggers the InfeasibleConstraintException in # deactivate_trivial_constraints in one of the subproblem solves during # initialization. This makes sure we get the correct answer anyway, as # there is a feasible solution. m = models.makeNestedNonlinearModel() SolverFactory('gdpopt').solve(m, strategy='LOA', mip_solver=mip_solver, nlp_solver=nlp_solver, init_strategy='set_covering') self.assertAlmostEqual(value(m.x), sqrt(2)/2) self.assertAlmostEqual(value(m.y), sqrt(2)/2) self.assertTrue(value(m.disj.disjuncts[1].indicator_var)) self.assertFalse(value(m.disj.disjuncts[0].indicator_var)) self.assertTrue(value(m.d1.indicator_var)) self.assertFalse(value(m.d2.indicator_var))