def test_taylor(self): settings = StructSettings(perm_bound=7, max_rule_size=(3, 3), max_non_empty=3) patts = [Permutation([1, 2, 3]), Permutation([3, 2, 1])] settings.set_input(StructInput.from_avoidance(settings, patts)) res = taylor_dag(settings, remove=False) self.check([], res) patts = [Permutation([1, 2, 3]), Permutation([3, 2, 1])] settings.set_input(StructInput.from_avoidance(settings, patts)) res = taylor_dag(settings, remove=False, remove_finite=False) self.check([ [Permutation([1, 2]), Permutation([2, 1])], [Permutation([1, 2, 3]), Permutation([2, 1])], [Permutation([1, 2]), Permutation([3, 2, 1])], ], res) patts = [ Permutation([1, 2, 3]), Permutation([3, 2, 1]), ] settings.set_input(StructInput.from_avoidance(settings, patts)) res = taylor_dag(settings, upper_bound=1, remove=False, remove_finite=False) self.check([], res) patts = [ Permutation([1, 2, 3]), Permutation([3, 2, 1]), ] settings.set_input(StructInput.from_avoidance(settings, patts)) res = taylor_dag(settings, max_len_patt=2, remove=False, remove_finite=False) self.check([ [Permutation([1, 2]), Permutation([2, 1])], ], res)
def test_taylor(self): settings = StructSettings( perm_bound=7, max_rule_size=(3,3), max_non_empty=3) patts = [Permutation([1,2,3]), Permutation([3,2,1])] settings.set_input(StructInput.from_avoidance(settings, patts)) res = taylor_dag(settings, remove=False) self.check([ ], res) patts = [Permutation([1,2,3]), Permutation([3,2,1])] settings.set_input(StructInput.from_avoidance(settings, patts)) res = taylor_dag(settings, remove=False, remove_finite=False) self.check([ [Permutation([1,2]), Permutation([2,1])], [Permutation([1,2,3]), Permutation([2,1])], [Permutation([1,2]), Permutation([3,2,1])], ], res) patts = [ Permutation([1,2,3]), Permutation([3,2,1]), ] settings.set_input(StructInput.from_avoidance(settings, patts)) res = taylor_dag(settings, upper_bound=1, remove=False, remove_finite=False) self.check([ ], res) patts = [ Permutation([1,2,3]), Permutation([3,2,1]), ] settings.set_input(StructInput.from_avoidance(settings, patts)) res = taylor_dag(settings, max_len_patt=2, remove=False, remove_finite=False) self.check([ [Permutation([1,2]), Permutation([2,1])], ], res)
ignored = 0 # The dag max_len_patt = 3 upper_bound = None remove = False # Grids max_rule_size = (5, 5) max_non_empty = 5 max_rules = None # ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------ settings = StructSettings( perm_bound=perm_bound, verify_bound=verify_bound, max_rule_size=max_rule_size, max_non_empty=max_non_empty, max_rules=max_rules, verbosity=StructLogger.INFO) # settings.set_input(StructInput.from_avoidance(settings, patts)) settings.set_input(AvoiderInput(settings, patts)) settings.set_dag(taylor_dag(settings, max_len_patt=max_len_patt, remove=remove, upper_bound=upper_bound)) exhaustive(settings)
verify_bound = 12 ignored = 0 # The dag max_len_patt = 2 # None does not help with smaller grids upper_bound = 1 # None does not help with smaller grids remove = False #True with (4, 4) 4 works # Grids max_rule_size = (5, 5) max_non_empty = 5 max_rules = None # ------------------------------------------------------------------------------ settings = StructSettings(perm_bound=perm_bound, verify_bound=verify_bound, max_rule_size=max_rule_size, max_non_empty=max_non_empty, max_rules=max_rules, verbosity=StructLogger.INFO) # settings.set_input(StructInput.from_avoidance(settings, patts)) settings.set_input(AvoiderInput(settings, patts)) settings.set_dag( taylor_dag(settings, max_len_patt=max_len_patt, remove=remove, upper_bound=upper_bound)) exhaustive(settings)
def struct(patts, size=None, perm_bound=None, verify_bound=None, subpatts_len=None, subpatts_num=None, subpatts_type=SubPatternType.EVERY, ask_verify_higher=True): """ INPUT: - ``patts'' - the patterns in the basis. - ``size'' - the maximum size of the rules to try. - ``perm_bound'' - the longest permutations to use from Av(patts). - ``verify_bound'' - the longest permutations from Av(patts) to use to verify the cover found. - ``subpatts_len'' - the longest subpattern to use from the basis. - ``subpatts_num'' - the maximum number of subpatterns to use from the basis. - ``subpatts_type'' - the type of subpattern to use from the basis. - ``ask_verify_higher'' - whether to ask about verifying with longer permutations. """ k = 1 if len(patts) == 0 else max(len(p) for p in patts) # Grids if size is not None: max_rule_size = (size, size) max_non_empty = size else: max_rule_size = (k + 1, k + 1) max_non_empty = k + 1 max_rules = None # Perms if size is None: perm_bound = k + 2 if perm_bound is None else perm_bound else: perm_bound = max(size + 1, k + 2 if perm_bound is None else perm_bound) # perm_bound = k+2 if perm_bound is None else perm_bound verify_bound = perm_bound + 2 if verify_bound is None else verify_bound # The dag max_len_patt = subpatts_len upper_bound = subpatts_num remove = False settings = StructSettings(perm_bound=perm_bound, verify_bound=verify_bound, max_rule_size=max_rule_size, max_non_empty=max_non_empty, max_rules=max_rules, verbosity=StructLogger.INFO, ask_verify_higher=ask_verify_higher) settings.set_input(AvoiderInput(settings, patts)) settings.set_dag( taylor_dag(settings, max_len_patt=max_len_patt, remove=remove, upper_bound=upper_bound, subpattern_type=subpatts_type)) exhaustive(settings)
def struct(patts, size=None, perm_bound=None, verify_bound=None, subpatts_len=None, subpatts_num=None, subpatts_type=SubPatternType.EVERY, ask_verify_higher=True): """ INPUT: - ``patts'' - the patterns in the basis. - ``size'' - the maximum size of the rules to try. - ``perm_bound'' - the longest permutations to use from Av(patts). - ``verify_bound'' - the longest permutations from Av(patts) to use to verify the cover found. - ``subpatts_len'' - the longest subpattern to use from the basis. - ``subpatts_num'' - the maximum number of subpatterns to use from the basis. - ``subpatts_type'' - the type of subpattern to use from the basis. - ``ask_verify_higher'' - whether to ask about verifying with longer permutations. """ k = 1 if len(patts) == 0 else max( len(p) for p in patts ) # Grids if size is not None: max_rule_size = (size,size) max_non_empty = size else: max_rule_size = (k+1, k+1) max_non_empty = k+1 max_rules = None # Perms if size is None: perm_bound = k+2 if perm_bound is None else perm_bound else: perm_bound = max(size+1, k+2 if perm_bound is None else perm_bound) # perm_bound = k+2 if perm_bound is None else perm_bound verify_bound = perm_bound+2 if verify_bound is None else verify_bound # The dag max_len_patt = subpatts_len upper_bound = subpatts_num remove = False settings = StructSettings( perm_bound=perm_bound, verify_bound=verify_bound, max_rule_size=max_rule_size, max_non_empty=max_non_empty, max_rules=max_rules, verbosity=StructLogger.INFO, ask_verify_higher=ask_verify_higher) settings.set_input(AvoiderInput(settings, patts)) settings.set_dag(taylor_dag(settings, max_len_patt=max_len_patt, remove=remove, upper_bound=upper_bound, subpattern_type=subpatts_type)) exhaustive(settings)