def cut_and_solve_extension(kpp): max_cliques = kpp.G.maximal_cliques() k = kpp.k k2 = kpp.k2 kpp.add_separator(YCliqueSeparator(max_cliques, 4, k)) kpp.add_separator(YCliqueSeparator(max_cliques, 5, k)) kpp.cut() kpp.sep_algs.clear() kpp.add_z_variables() kpp.add_separator(YZCliqueSeparator(max_cliques, 7, k, k2)) kpp.add_separator(ZCliqueSeparator(max_cliques, 8, k, k2)) kpp.cut() kpp.solve()
def test_cuts(self): print("\ttest_cuts...") cuts_kpp = KPPExtension(self.G, k, k2, verbosity=0) y_sep_alg_1 = YCliqueSeparator(self.max_cliques, k + 1, k) yz_sep_alg = YZCliqueSeparator(self.max_cliques, k2 * k + 1, k, k2) z_sep_alg = ZCliqueSeparator(self.max_cliques, k2 * k + 2, k, k2) cuts_kpp.add_separator(y_sep_alg_1) cuts_kpp.cut() cuts_kpp.sep_algs = [] cuts_kpp.add_z_variables() cuts_kpp.add_separator(yz_sep_alg) cuts_kpp.add_separator(z_sep_alg) cuts_kpp.cut() cuts_kpp.solve() cuts_obj_val = cuts_kpp.model.objVal self.assertAlmostEqual(self.obj_val, cuts_obj_val)
def test_cuts_and_break_symmetry(self): print("\ttest_cuts_and_break_symmetry...") kpp = KPPExtension(self.G, k, k2, verbosity=0) y_sep_alg_1 = YCliqueSeparator(self.max_cliques, k + 1, k) y_sep_alg_2 = YCliqueSeparator(self.max_cliques, k + 2, k) yz_sep_alg = YZCliqueSeparator(self.max_cliques, k * k2 + 1, k, k2) z_sep_alg = ZCliqueSeparator(self.max_cliques, k * k2 + 2, k, k2) kpp.add_separator(y_sep_alg_1) kpp.add_separator(y_sep_alg_2) kpp.cut() kpp.sep_algs = [] kpp.add_z_variables() kpp.add_separator(yz_sep_alg) kpp.add_separator(z_sep_alg) kpp.cut() kpp.break_symmetry() kpp.solve() obj_val = kpp.model.objVal self.assertAlmostEqual(self.obj_val, obj_val)