def test_eisenstat(self): for n in range(6, 20, 2): builder = TotJacBuilder.eisenstat(n) builder.color('auto', stream=None) tot_size, tot_colors, fwd_solves, rev_solves, pct = _solves_info( builder.coloring) if tot_colors == n // 2 + 3: raise unittest.SkipTest( "Current bicoloring algorithm requires n/2 + 3 solves, so skipping for now." ) self.assertLessEqual( tot_colors, n // 2 + 2, "Eisenstat's example of size %d required %d colors but shouldn't " "need more than %d." % (n, tot_colors, n // 2 + 2)) builder_fwd = TotJacBuilder.eisenstat(n) builder_fwd.color('fwd', stream=None) tot_size, tot_colors, fwd_solves, rev_solves, pct = _solves_info( builder_fwd.coloring) # The columns of Eisenstat's example are pairwise nonorthogonal, so fwd coloring # should require n colors. self.assertEqual( n, tot_colors, "Eisenstat's example of size %d was not constructed properly. " "fwd coloring required only %d colors but should have required " "%d" % (n, tot_colors, n))
def test_arrowhead(self): for n in range(5, 50, 55): builder = TotJacBuilder(n, n) builder.add_row(0) builder.add_col(0) builder.add_block_diag([(1,1)] * (n-1), 1, 1) builder.color('auto', stream=None) tot_size, tot_colors, fwd_solves, rev_solves, pct = _solves_info(builder.coloring) self.assertEqual(tot_colors, 3)
def test_arrowhead(self): for n in [55, 50, 5]: builder = TotJacBuilder(n, n) builder.add_row(0) builder.add_col(0) builder.add_block_diag([(1, 1)] * (n - 1), 1, 1) builder.color('auto') tot_size, tot_colors, fwd_solves, rev_solves, pct = builder.coloring._solves_info( ) self.assertEqual(tot_colors, 3)
def test_eisenstat(self): for n in range(6, 20, 2): builder = TotJacBuilder.eisenstat(n) builder.color('auto', stream=None) tot_size, tot_colors, fwd_solves, rev_solves, pct = _solves_info(builder.coloring) if tot_colors == n // 2 + 3: raise unittest.SkipTest("Current bicoloring algorithm requires n/2 + 3 solves, so skipping for now.") self.assertLessEqual(tot_colors, n // 2 + 2, "Eisenstat's example of size %d required %d colors but shouldn't " "need more than %d." % (n, tot_colors, n // 2 + 2)) builder_fwd = TotJacBuilder.eisenstat(n) builder_fwd.color('fwd', stream=None) tot_size, tot_colors, fwd_solves, rev_solves, pct = _solves_info(builder_fwd.coloring) # The columns of Eisenstat's example are pairwise nonorthogonal, so fwd coloring # should require n colors. self.assertEqual(n, tot_colors, "Eisenstat's example of size %d was not constructed properly. " "fwd coloring required only %d colors but should have required " "%d" % (n, tot_colors, n))