Example #1
0
def test_layer_triangle(size):
    tss_list = btss.build_tss(size)

    bt_list  = bbt.build_bt(size)

    after_map = dict()

    error_count = 0
    for t in tss_list:
        tlayer = get_layer_triangle(t)
        s = util.flip_triangle2(tlayer)
        #print(t, s)
        print('before')
        util.print_array(t)
        print('after')
        util.print_array(s)
        key =  str(s)
        if not key in after_map:
            after_map[key] = [ t,]
        else:
            after_map[key].append(t)

        # if not s in bt_list:
        #     error_count+=1
        #     print('start tss')
        #     print(t)
        #     print('after')
        #     util.print_array(s)

    #print('errors', error_count)

    print('tss size', len(tss_list))
    print('after size', len(after_map))

    rep_count = 0
    for key in after_map:
        key_list = after_map[key]
        if len(key_list) > 1:
            rep_count += 1
            print('repeated', key)
            print('AFTER')
            util.print_array(ast.literal_eval(key))
            print('BEFORE')
            for x in key_list:
                util.print_array(x)


    print('>>>>>>>>>>>>>>>>missing')
    missing_count = 0
    for b in  bt_list:
        if not str(b) in after_map:
            print('missing', b)
            util.print_array(b)
            missing_count += 1


    print('before', len(tss_list))
    print('after', len(after_map))
    print('repeated', rep_count)
    print('missing', missing_count)
Example #2
0
def check_diagonal_sum(diag_sum):
    q_tss = 'SELECT name FROM FIVE_TSS WHERE diag1=%s and diag2=%s and diag3=%s and diag4=%s and diag5=%s' % diag_sum
    q_bt = 'SELECT name FROM FIVE_BT WHERE diag1=%s and diag2=%s and diag3=%s and diag4=%s and diag5=%s' % diag_sum

    tss_list = get_list_from_db(q_tss)
    bt_list = get_list_from_db(q_bt)
    fbt_list = [ util.flip_triangle2(b) for b in bt_list]
    combed_list = []

    print('combing FBT')
    for t in fbt_list:
        combed = comb_with_col_max(t, False)
        if not combed in tss_list:
            print('>>>>>>>>>FAIL!')
            util.print_array(t)
            util.print_array(combed)
            print('fail:', t, combed)
        elif combed in combed_list:
            print('>>>>>>>>> REPEAT!')
            util.print_array(t)
            util.print_array(combed)
        else:
            combed_list.append(combed)
            print('>>>passed!')
            util.print_array(t)
            util.print_array(combed)

    print('*********************  missing TSS')
    for t in tss_list:
        if not t in combed_list:
            util.print_array(t)
Example #3
0
def get_boosted_fbt(size):
    bt_list = bbt.build_bt(size)

    boosted_list = [boost(util.flip_triangle2(t)) for t in bt_list]

    return boosted_list
Example #4
0
    out_file.writelines(["%s\n" % item for item in lines])

    #for x in lines:
    #    print(x)





#print(get_layers_from_bottom([[0],[0,1],[0,0,1]]))


size = 4
bin_list = binary_comb.get_binary_triangle(size)
sst_list = bbt.get_stack_set(size)
sst_list = [util.flip_triangle2(s) for s in sst_list]
sst_list = [[row for row in reversed(s)] for s in sst_list]

#bin_list = [ [row for row in reversed(t)] for t in bin_list]

#suffix = 'top'
#layer_list = get_binary_layers(size)
#layer_list = get_binary_layers_from_bottom(size)



suffix = 'perm_top'
layer_list = get_layers_as_permutations(size)


count = 0
Example #5
0
def compare(size):

    # rows decr by at most 1
    tss_list = btss.build_tss(size)

    # row weak decr
    # col weak incr or decr by 1
    bt_list = bbt.build_bt(size)

    fbt_list = [ util.flip_triangle2(b) for b in bt_list]

    combed_list = []
    combed_str_set = set()

    fail_list = []

    print('total', len(tss_list))

    #tss_list = tss_list[0:1000]

    print('========= FBT')
    for count,fbt in enumerate(fbt_list):

        if count % 1000 == 0:
            print(count)
        #print('handling TSS')
        #util.print_array(tss)
        #tri = comb(tss, True)
        tri = comb_with_col_max(fbt, False)

        if not get_diag_sums(fbt) == get_diag_sums(tri):
            print('*******ERRROR diag sum', fbt, tri)


        #tri = comb(tri)
        #tri = comb(tri)
        combed_list.append(tri)
        combed_str_set.add(str(tri))
        #util.print_array(tri)
        #print('=================')
        if not tri in tss_list:
            fail_list.append([fbt, tri])
            print('fail', count, fbt, '\t', tri)

        combed_key = str(tri)
        if not combed_key in combed_map:
            combed_map[combed_key] = [fbt,]
        else:
            combed_map[combed_key].append(fbt)


    missing_list = []
    # # print('========= BT')
    for tss in tss_list:
        if not tss in combed_list:
            missing_list.append(tss)
    # #     util.print_array(bt)


    fail_file = open('/Users/abeverid/PycharmProjects/asm/data/tss/flip_fail_bt.txt', 'w')


    for f in fail_list:
        util.print_array(f[0])
        util.print_array(f[1])
        fail_file.write(str(f[0]) + ' fails to' + str(f[1]))
        fail_file.write('\n')
        print('************')
    print('num failures', len(fail_list))

    fail_file.close()

    # t = [[2, 2, 1], [0, 0], [0]]
    #
    # util.print_array(t)
    # util.print_array(comb(t))
    #
    print('MISSING')

    missing_file = open('/Users/abeverid/PycharmProjects/asm/data/tss/flip_missing_tss.txt', 'w')
    for b in missing_list:
        missing_file.write(str(b))
        missing_file.write('\n')
    missing_file.close()
    #   util.print_array(b)
    print('num missing:', len(missing_list))


    print('combed tri size', len(combed_list))
    print('combed str size', len(combed_str_set))



    bad_list = [ x[0] for  x in fail_list]

    print(bad_list)

    print('repeats!!!!')
    rep_count = 0

    repeat_tss_file = open('/Users/abeverid/PycharmProjects/asm/data/tss/flip_repeat_tss.txt', 'w')
    repeat_bt_file = open('/Users/abeverid/PycharmProjects/asm/data/tss/flip_repeat_bt.txt', 'w')

    for key in combed_map:
        if len(combed_map[key]) > 1:
            print(key, len(combed_map[key]), combed_map[key])
            rep_count +=1

            key_tri = ast.literal_eval(key)
            key_diags = get_diag_sums(key_tri)

            repeat_tss_file.write(key)
            repeat_tss_file.write('\n')
            rep_list = combed_map[key]
            for rep in rep_list:
                repeat_bt_file.write(str(rep))
                repeat_bt_file.write('\n')

                rep_diags  = get_diag_sums(rep)

                if not key_diags == rep_diags:
                    print('MEGA ERROR!!!!!!!!', key_diags, rep_diags)



    repeat_tss_file.close()
    repeat_bt_file.close()

    print('repcount', rep_count)
Example #6
0
    tri = [[x for x in reversed(row)] for row in reversed(layer_tri)]

    return tri





#util.print_array(bad5_list[0])

#util.print_array(comb(bad5_list[0], True))


bt_list = bbt.build_bt(5)
fbt_list = [ util.flip_triangle2(b) for b in bt_list]


t1 = [[2, 3, 3, 2, 1], [1, 3, 2, 1], [0, 2, 1], [0, 1], [0]]
t2 = [[2, 4, 3, 2, 1], [0, 3, 2, 1], [0, 2, 1], [0, 1], [0]]
t3 = [[1, 2, 3, 2, 1], [0, 0, 0, 0], [0, 0, 0], [0, 0], [0]]


t5_29162 = fbt_list[29162]
t5_19075 = fbt_list[19075]
t5_19076 = fbt_list[19076]

t5a = [[[2, 1, 2, 2, 1], [2, 1, 0, 0], [0, 0, 0], [0, 0], [0]], [[2, 3, 3, 2, 1], [0, 0, 0, 0], [0, 0, 0], [0, 0], [0]]]

t5b = [[2, 1, 2, 2, 1], [2, 1, 0, 0], [0, 0, 0], [0, 0], [0]]
t5c = [[2, 3, 3, 2, 1], [0, 0, 0, 0], [0, 0, 0], [0, 0], [0]]
Example #7
0
def compare_to_binary(size):

    file_name = '/Users/abeverid/PycharmProjects/asm/data/ssyt/bin-ssyt' + str(size) + '.tex'

    out_file = open(file_name, 'w')


    lines = ['\\documentclass[12pt]{article}', '\\usepackage{amsmath}', '\\usepackage{ytableau}',
             '\\usepackage{tikz}', '\\begin{document}']

    matrix_list = get_ssyt_matrix(size)
    #triangle_list = binary_triangle.get_binary_triangle_with_subset_order(size-1)
    triangle_list = bin_tri_reordered


    # bin_tri_list

    # matrix_list = [
    #     [[1, 1], [1, 0], [0, 0]],
    #     [[1, 0], [1, 1], [0, 0]],
    #     [[1, 0], [1, 0], [0, 1]],
    #     [[1, 1], [0, 0], [1, 0]],
    #     [[1, 0], [0, 1], [1, 0]],
    #     [[1, 0], [0, 0], [1, 1]],
    #     [[0, 0], [1, 1], [1, 0]],
    #     [[0, 0], [1, 0], [1, 1]]
    # ]
    #
    # triangle_list = [
    #     [[0], [0, 0]],
    #     [[0], [0, 1]],
    #     [[0], [1, 0]],
    #     [[1], [0, 0]],
    #     [[0], [1, 1]],
    #     [[1], [0, 1]],
    #     [[1], [1, 0]],
    #     [[1], [1, 1]]
    # ]


    count = -1
    for t,m in zip(triangle_list, matrix_list):
        count = count+1
        size = len(triangle_list[0])
        t_B, t_D = binary_comb.comb(t)
        t_cliff_omega = binary_comb.get_omega_for_cliff(t)
        t_combed_omega = binary_comb.get_omega(t_B, t_D)

        m_B, m_D = matrix_to_BD(m)
        m_omega = binary_comb.get_omega(m_B,m_D)

        t_invert = [ [ 1 -x for x in row ] for row in reversed(t)]

        #print(t, t_invert)


        lines.append('\\begin{tikzpicture}[scale=.5]')

        lines.append('\\node at (0,' + str(size/2) + ') {')
        lines.append(util.to_tex_ytableau(t_invert))
        lines.append('};')

        lines.append('\\begin{scope}[shift={(' + str(1 * size -1) + ',1)}]')
        lines.append(binary_comb.to_tangle2(t_cliff_omega))
        lines.append('\\end{scope}')

        lines.append('\\begin{scope}[shift={(' + str(2.5*size -1) + ',1)}]')
        lines.append(binary_comb.to_tangle2(t_combed_omega))
        lines.append('\\end{scope}')

        lines.append('\\node at (' +  str(4 * size) + ',' + str(size/2) + ') {')
        lines.append(util.to_tex_ytableau(util.flip_triangle2(matrix_to_ssyt(m))))
        lines.append('};')


        lines.append('\\node at (' +  str(5.5 * size) + ',' + str(size/2) + ') {')
        lines.append(util.to_tex_ytableau(m))
        lines.append('};')




        lines.append('\\begin{scope}[shift={( ' + str(6.5 * size) + ',0)}]')
        lines.append(binary_comb.to_tangle(m_omega))
        lines.append('\\end{scope}')

        lines.append('\\node at (' + str(7.5 * size) + ',0) {' + str(count) + '};')

        lines.append('\\end{tikzpicture}')
        lines.append('')

    lines.append('\\end{document}')

    out_file.writelines(["%s\n" % item for item in lines])