Beispiel #1
0
def compare(size):


    tss_list = get_boosted_tss(size)
    fbt_list = get_boosted_fbt(size)

    combed_map = dict()



    error_list = []

    for k,t in enumerate(tss_list):
        print(k, 'before')
        util.print_array(t)

        if k % 1000 == 0:
            print('processed', k)

        b = comb(t)

        key =  str(b)
        if not key in combed_map:
            combed_map[key]  = [ t, ]
        else:
            print('REPEAT!!!!', k)
            combed_map[key].append(t)
            print(key, 'mapped from', combed_map[key])

        print('after')
        util.print_array(b)

        if not b in fbt_list:
            print('ERROR NOT IN FBT LIST!', k)
            error_list.append([t,b])
            print(t, 'mapped to', b)

        #print('======================')

    print('num errors', len(error_list))
    for x in error_list:
        print(x[0], x[1], util.get_column_sums(x[0]))


    print('missing')
    for b in fbt_list:
        if not str(b) in combed_map:
            print(b, util.get_column_sums(b))

    print('distinct', len(combed_map))
    for k in combed_map:
        x = combed_map[k]
        if len(x) > 1:
            print(k)
            for y in x:
                print('\t', y, util.get_column_sums(y))
Beispiel #2
0
def build_rsst(size):
    if not size in rsst_map:

        max_sums = [k for k in range(1,size+1)]

        first_row_list = util.get_increasing_binary_arrays(size)

        matrix_list = [[row, ] for row in first_row_list]

        for idx in range(1, size):
            row_list = [ [0] *  idx + row  for row in util.get_binary_arrays(size-idx)]

            new_matrix_list = []
            for new_row in row_list:
                for matrix in matrix_list:
                    print('-------')
                    sums = util.get_column_sums(matrix)
                    print('sums before:', sums)
                    sums = [x + y for x,y in zip(new_row, sums)]
                    print('sums after: ', sums)
                    # check still weakly decreasing and beneath max_sums
                    if all(sums[i] <= sums[i+1] for i in range(size-1)) \
                        and all(sums[i] <= max_sums[i] for i in range(size)):
                        new_matrix_list.append( matrix + [new_row])
                        print('\t', (matrix + [new_row]))
            matrix_list = new_matrix_list

        rsst_map[size] = matrix_list

    return rsst_map[size]
Beispiel #3
0
def get_ssyt_matrix(size):
    if not size in matrix_map:
        max_sums = [k for k in range(1,size)]

        first_row_list = util.get_increasing_binary_arrays(size-1)
        other_row_list = util.get_binary_arrays(size-1)

        matrix_list = [ [ row, ] for row in first_row_list]

        for idx in range(size-1):
            new_matrix_list = []
            for new_row in other_row_list:
                for matrix in matrix_list:
                    sums = util.get_column_sums(matrix)
                    sums = [x + y for x,y in zip(new_row, sums)]

                    # check still weakly decreasing and beneath max_sums
                    if all(sums[i] <= sums[i+1] for i in range(size-2)) \
                        and all(sums[i] <= max_sums[i] for i in range(size-1)):
                        new_matrix_list.append( matrix + [new_row])
            matrix_list = new_matrix_list

        ssyt_list = []
        for m in matrix_list:
            sums = util.get_column_sums(m)
            if all(sums[i] == max_sums[i] for i in range(size-1)):
                # it's easier to understand if we reverse index the rows
                ssyt_list.append([ [x for x in reversed(row)] for row in m])

        ssyt_list = get_sorted(ssyt_list)

        matrix_map[size] = ssyt_list




    return matrix_map[size]
Beispiel #4
0
def compare_two_rows(size, col_sums=()):

    # tss_list = get_boosted_tss(size)
    # fbt_list = get_boosted_fbt(size)
    #
    #
    #
    # tss_row_list = []
    #
    # for tss in tss_list:
    #     temp = [tss[0], tss[1]]
    #
    #     if not temp in tss_row_list:
    #         tss_row_list.append(temp)
    #
    # fbt_row_list = []
    #
    # for fbt in fbt_list:
    #     temp = [fbt[0], fbt[1]]
    #
    #     if not temp in fbt_row_list:
    #         fbt_row_list.append(temp)

    ###########

    # tss_row_list = [ [x[0], x[1]] for x in tss_list]
    # fbt_row_list = [ [x[0], x[1]] for x in fbt_list]

    #combed_row_list = [handle_row_with_col_max_v4(tss_rows, 1, size-1) for tss_rows in tss_row_list]

    #print(len(tss_row_list), len(fbt_row_list), len(combed_row_list))

    ###########

    tss_row_list2 = get_boosted_tss_trapezoid(size, 2)
    fbt_row_list2 = get_boosted_fbt_trapezoid(size, 2)

    tss_row_list = tss_row_list2
    fbt_row_list = fbt_row_list2

    fbt_match_list = [f for f in fbt_row_list if get_col_sums(f) == col_sums]

    combed_map = dict()

    error_list = []
    comb_match_list = []

    for k, t in enumerate(tss_row_list):
        print(k, 'before')
        util.print_array(t)

        tt = util.clone_array(t)

        if k % 1000 == 0:
            print('processed', k)

        #print("HANDLING ROW WITH COL MAX")
        #b = handle_row_with_col_max_v4(tt, 1, size-1)
        b = untangle(tt, 1, size - 1)

        key = str(b)
        if not key in combed_map:
            combed_map[key] = [
                t,
            ]
        else:
            print('REPEAT!!!!', k)
            combed_map[key].append(t)
            print(key, 'mapped from', combed_map[key])

        print('after')
        util.print_array(b)

        if not b in fbt_row_list:
            print('ERROR NOT IN FBT LIST!', k)
            error_list.append([t, b])
            print(t, 'mapped to', b)
        else:
            if get_col_sums(b) == col_sums:
                comb_match_list.append(b)

        #print('======================')

    print('num errors', len(error_list))
    for x in error_list:
        print(x[0], x[1], util.get_column_sums(x[0]))

    missing_count = 0
    print('missing')
    for b in fbt_row_list:
        if not str(b) in combed_map:
            missing_count += 1
            #print(b, util.get_column_sums(b))
    print(missing_count)

    rep_count = 0
    print('repeated')
    for k in combed_map:
        x = combed_map[k]
        if len(x) > 1:
            print(k)
            rep_count += 1
            for y in x:
                print('\t', y, util.get_column_sums(y))

    print('summary')
    print('tss=', len(tss_row_list), 'combed=', len(combed_map), 'fbt=',
          len(fbt_row_list), 'repeated=', rep_count, 'error=', len(error_list))

    # print('only tss 1')
    # for t in tss_row_list:
    #     if not t in tss_row_list2:
    #         print('\t', t)
    # print('only tss 2')
    # for t in tss_row_list2:
    #     if not t in tss_row_list:
    #         print('\t', t)
    #
    # print('only fbt 1')
    # for t in fbt_row_list:
    #     if not t in fbt_row_list2:
    #         print('\t', t)
    # print('only fbt 2')
    # for t in fbt_row_list2:
    #     if not t in fbt_row_list:
    #         print('\t', t)

    if not col_sums == ():
        print('missing fbt with col_sums', col_sums)
        for f in fbt_match_list:
            if not f in comb_match_list:
                print(f)