Exemplo n.º 1
0
# perm_bound    = 7
# # inp_dag       = permstruct.dag.len_3_pairs(perm_prop, perm_bound)
# inp_dag       = permstruct.dag.N_P_X1_mon(perm_prop, perm_bound)
# max_rule_size = (3, 3)
# max_non_empty = 3
# max_rules     = 100
# ignored       = 1

#------------------------------------------------#

if not overlays:
    permstruct.exhaustive(perm_prop,
                          perm_bound,
                          inp_dag,
                          max_rule_size,
                          max_non_empty,
                          max_rules,
                          ignore_first=ignored)

else:
    permstruct.exhaustive_with_overlays(perm_prop,
                                        perm_bound,
                                        inp_dag,
                                        max_rule_size,
                                        max_non_empty,
                                        max_rules,
                                        overlay_dag,
                                        max_overlay_cnt,
                                        max_overlay_size,
                                        min_rule_size=(1, 1))
Exemplo n.º 2
0
# inp_dag = permstruct.dag.len_3_pairs(perm_prop, perm_bound)

# max_rule_size = (1, 1)
# max_non_empty = 4
# max_rules     = 100
# ignored       = 0

# For exhaustive_with_overlays
# overlay_dag = permstruct.dag.x_dag(perm_prop, perm_bound)
# max_overlay_cnt = 1
# max_overlay_size = (1, 3)

# overlays = False

if not overlays:
    permstruct.exhaustive(perm_prop, perm_bound, inp_dag, max_rule_size, max_non_empty, max_rules, ignore_first=ignored)

else:
    permstruct.exhaustive_with_overlays(
        perm_prop,
        perm_bound,
        inp_dag,
        max_rule_size,
        max_non_empty,
        max_rules,
        overlay_dag,
        max_overlay_cnt,
        max_overlay_size,
        min_rule_size=(1, 1),
    )
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
perm_bound = 7

# inp_dag = permstruct.dag.N_P_X_mon(perm_prop, perm_bound)
# inp_dag = permstruct.dag.classic_avoiders_length_3(perm_prop, perm_bound)
# inp_dag = permstruct.dag.N_P_X1_mon1_taylored_for_av_4213_2143(perm_prop, perm_bound)
# inp_dag = permstruct.dag.N_P_X_mon1_taylored_for_av_132_4321(perm_prop, perm_bound)
# inp_dag = permstruct.dag.taylor_dag([Permutation([1,3,2]), Permutation([4,3,2,1])], perm_bound)
# inp_dag = permstruct.dag.N_P_X_mon1_taylored_for_av_132_4321(perm_prop, perm_bound)
# inp_dag = permstruct.dag.taylor_dag(patts, perm_bound, remove=True, upper_bound=3)
inp_dag = permstruct.dag.taylor_dag(patts, perm_bound, remove=True, upper_bound=3)
for el in inp_dag.elements:
    print(el.description if el is not None else 'None')

# sol_iter = permstruct.exhaustive(perm_prop, perm_bound, inp_dag, (2,3), 3, 5, lower_bound=0.2)
# sol_iter = permstruct.exhaustive(perm_prop, perm_bound, inp_dag, (3,3), 3, 100)
sol_iter = permstruct.exhaustive(perm_prop, perm_bound, inp_dag, (3,3), 3, is_classical=True)


# perm_bound    = 7
# # inp_dag       = permstruct.dag.len_3_pairs(perm_prop, perm_bound)
# inp_dag       = permstruct.dag.N_P_X_mon1_taylored_for_av_132_4321(perm_prop, perm_bound)
# max_rule_size = (3, 3)
# max_non_empty = 3
# max_rules     = 100
# ignored       = 1

for sol in sol_iter:

    print('====================================')
    print("")
    for rule in sol:
Exemplo n.º 5
0
# Found 19525 rules, 93 of which are valid, 82 of which are distinct
# Found 15217 rules, 93 of which are valid, 82 of which are distinct

# Found 724411 rules, 86 of which are valid, 72 of which are distinct
# Found 184507 rules, 86 of which are valid, 72 of which are distinct
# Found 30727 rules, 86 of which are valid, 72 of which are distinct

# for k, v in permstruct.find_allowed_neighbors(inp_dag.elements).items():
#     print('------------------------')
#     print(k)
#     for x in v:
#         print(x)
#
#
# sys.exit(0)

# sol_iter = permstruct.exhaustive(perm_prop, perm_bound, inp_dag, (3,3), 3, 6, ignore_first=0)
permstruct.exhaustive(perm_prop, perm_bound, inp_dag, (5, 5), 5, 6)

# sol_iter = permstruct.exhaustive(perm_prop, perm_bound, inp_dag, (4, 4), 6, 6, ignore_first=1)
# sol_iter = permstruct.exhaustive(perm_prop, perm_bound, inp_dag, (4, 4), 4, 6, ignore_first=1)
# sol_iter = permstruct.construct_rule(perm_prop, perm_bound, inp_dag, (3, 3), 4, 100)
# sol_iter = permstruct.exhaustive(perm_prop, perm_bound, inp_dag, (3, 3), 3, 100)
# sol_iter = permstruct.construct_rule(perm_prop, perm_bound, inp_dag, (3, 3), 4, 100)
# sol_iter = permstruct.exhaustive(perm_prop, perm_bound, inp_dag, (3, 3), 4, 100)
# sol_iter = permstruct.exhaustive_with_overlays(perm_prop, perm_bound, inp_dag, (2, 3), 4, 4, overlay_dag, 1, (1, 3), min_rule_size=(2,3))
# sol_iter = permstruct.exhaustive_with_overlays(perm_prop, perm_bound, inp_dag, (2, 3), 4, 5, overlay_dag, 1, (1, 3), min_rule_size=(2,3))

# permstruct.exhaustive(perm_prop, perm_bound, dag, (3, 3), 4, 5)
Exemplo n.º 6
0
# inp_dag = permstruct.dag.N_P_X_mon1_taylored_for_av_132_4321(perm_prop, perm_bound)
# inp_dag = permstruct.dag.taylor_dag([Permutation([1,3,2]), Permutation([4,3,2,1])], perm_bound)
# inp_dag = permstruct.dag.N_P_X_mon1_taylored_for_av_132_4321(perm_prop, perm_bound)
# inp_dag = permstruct.dag.taylor_dag(patts, perm_bound, remove=True, upper_bound=3)
inp_dag = permstruct.dag.taylor_dag(patts,
                                    perm_bound,
                                    remove=True,
                                    upper_bound=3)
for el in inp_dag.elements:
    print(el.description if el is not None else 'None')

# sol_iter = permstruct.exhaustive(perm_prop, perm_bound, inp_dag, (2,3), 3, 5, lower_bound=0.2)
# sol_iter = permstruct.exhaustive(perm_prop, perm_bound, inp_dag, (3,3), 3, 100)
sol_iter = permstruct.exhaustive(perm_prop,
                                 perm_bound,
                                 inp_dag, (3, 3),
                                 3,
                                 is_classical=True)

# perm_bound    = 7
# # inp_dag       = permstruct.dag.len_3_pairs(perm_prop, perm_bound)
# inp_dag       = permstruct.dag.N_P_X_mon1_taylored_for_av_132_4321(perm_prop, perm_bound)
# max_rule_size = (3, 3)
# max_non_empty = 3
# max_rules     = 100
# ignored       = 1

for sol in sol_iter:

    print('====================================')
    print("")
Exemplo n.º 7
0
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)
Exemplo n.º 8
0
# Found 724411 rules, 86 of which are valid, 72 of which are distinct
# Found 184507 rules, 86 of which are valid, 72 of which are distinct
# Found 30727 rules, 86 of which are valid, 72 of which are distinct


# for k, v in permstruct.find_allowed_neighbors(inp_dag.elements).items():
#     print('------------------------')
#     print(k)
#     for x in v:
#         print(x)
# 
# 
# sys.exit(0)


# sol_iter = permstruct.exhaustive(perm_prop, perm_bound, inp_dag, (3,3), 3, 6, ignore_first=0)
permstruct.exhaustive(perm_prop, perm_bound, inp_dag, (5,5), 5, 6)

# sol_iter = permstruct.exhaustive(perm_prop, perm_bound, inp_dag, (4, 4), 6, 6, ignore_first=1)
# sol_iter = permstruct.exhaustive(perm_prop, perm_bound, inp_dag, (4, 4), 4, 6, ignore_first=1)
# sol_iter = permstruct.construct_rule(perm_prop, perm_bound, inp_dag, (3, 3), 4, 100)
# sol_iter = permstruct.exhaustive(perm_prop, perm_bound, inp_dag, (3, 3), 3, 100)
# sol_iter = permstruct.construct_rule(perm_prop, perm_bound, inp_dag, (3, 3), 4, 100)
# sol_iter = permstruct.exhaustive(perm_prop, perm_bound, inp_dag, (3, 3), 4, 100)
# sol_iter = permstruct.exhaustive_with_overlays(perm_prop, perm_bound, inp_dag, (2, 3), 4, 4, overlay_dag, 1, (1, 3), min_rule_size=(2,3))
# sol_iter = permstruct.exhaustive_with_overlays(perm_prop, perm_bound, inp_dag, (2, 3), 4, 5, overlay_dag, 1, (1, 3), min_rule_size=(2,3))

# permstruct.exhaustive(perm_prop, perm_bound, dag, (3, 3), 4, 5)