コード例 #1
0
    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)
コード例 #2
0
    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)
コード例 #3
0
ファイル: b7.py プロジェクト: PermutaTriangle/PermStruct
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)
コード例 #4
0
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)
コード例 #5
0
ファイル: main.py プロジェクト: PermutaTriangle/PermStruct
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)
コード例 #6
0
ファイル: main.py プロジェクト: PermutaTriangle/PermStruct
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)