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 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 #3
0
    #         tss[j + 1] = small_row
    #     print(tss)

    for i in range(1, len(tss)):
        print('i=', i)
        for j in reversed(range(1, i + 1)):
            tss = handle_row(tss, j)
        print(tss)

    return tss


n = 4

tss_list = tss.build_tss(n)
bt_list = bt.build_bt(n)

tss_str_list = set([str(t) for t in tss_list])
bt_str_list = set([str(t) for t in bt_list])

#temp = sorted([1, 2, 4, 132, 8, 266, 14, 16, 272, 24, 28, 32, 160, 164, 424, 48, 688, 436, 56, 1720, 712, 80, 2640, 1112, 96])
#print(temp)

#compare_diag_counts(tss_list, bt_list)

count = 0
print('>>>>>>>> tss only')
for t in tss_list:
    if t not in bt_list:
        count += 1
    # print_array(t)
Example #4
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)

    combed_list = []
    combed_str_set = set()

    fail_list = []

    print('total', len(tss_list))

    #tss_list = tss_list[0:1000]

    print('========= TSS')
    for count,tss in enumerate(tss_list):

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

        #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 bt_list:
            fail_list.append([tss, tri])
            print('fail', count, tss, '\t', tri)

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


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


    for f in fail_list:
        util.print_array(f[0])
        util.print_array(f[1])
        print('************')
    print('num failures', len(fail_list))

    # 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/missing_bt.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/repeat_tss.txt', 'w')
    repeat_bt_file = open('/Users/abeverid/PycharmProjects/asm/data/tss/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

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

    repeat_tss_file.close()
    repeat_bt_file.close()

    print('repcount', rep_count)
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]]