Esempio n. 1
0
def main(*args):
    if len(args) != 1:
        print "process_results.py requires exactly one parameter ({} given).".format(
            len(args))
        exit(-1)

    glob_pattern = args[0]
    files = glob.glob(glob_pattern)
    if not files:
        return
    directory = os.path.split(
        os.path.commonprefix(files))[0]  # The lowest common directory

    column_headers = [[
        'm_value', 'total_time', 'init_time', 'search_time', 'assignments',
        'solution_freq', 'timeout_freq'
    ]]

    processed_data = column_headers + [process(file) for file in files]

    processed_data = rw.adjust_col_widths(processed_data)

    output_filepath = os.path.join(directory, 'all_processed_data.txt')
    output_str = '\n'.join('\t'.join(entry) for entry in processed_data)
    rw.write_file(output_filepath, output_str, rw.OVERWRITE)
Esempio n. 2
0
def main(*args):
    if len(args) != 1:
        print "process_results.py requires exactly one parameter ({} given).".format(len(args))
        exit(-1)

    glob_pattern = args[0]
    files = glob.glob(glob_pattern)
    if not files:
        return
    directory = os.path.split(os.path.commonprefix(files))[0]  # The lowest common directory

    column_headers = [['m_value', 'total_time', 'init_time', 'search_time',
                       'assignments', 'solution_freq', 'timeout_freq']]

    processed_data = column_headers + [process(file) for file in files]

    processed_data = rw.adjust_col_widths(processed_data)

    output_filepath = os.path.join(directory, 'all_processed_data.txt')
    output_str = '\n'.join('\t'.join(entry) for entry in processed_data)
    rw.write_file(output_filepath, output_str, rw.OVERWRITE)
Esempio n. 3
0
def gen_puzzles(n, p, q, m_list, how_many):
    """Output a set of files containing generated puzzles.
    The output file names will conform to the following spec:
    "trials2/gen_n{N_VALUE}_m{M_VALUE}_{HOW_MANY}.txt"
    eg, "trials2/gen_n9_m20_1000.txt" will contain 1000 9x9 puzzles where m = 20
    """
    for m in m_list:
        filename = f(n, m, how_many)
        board_list = set(generator.gen.generate_boards(n, p, q, m, how_many))
        board_str = '\n'.join(str(board) for board in board_list)

        rw.write_file(filename, board_str, rw.OVERWRITE)

        while len(board_list) < how_many:
            to_go = how_many - len(board_list)
            extras = set(generator.gen.generate_boards(n, p, q, m, to_go))
            board_list.update(extras)
            board_str = '\n'.join(str(board) for board in board_list)
            # Update output file after each time this step is completed.
            # Since generations that need more time usually need A LOT MORE time,
            # it's better to update the file semi regularly in case we end up quitting early
            # (ie if we get tired of waiting)
            rw.write_file(filename, board_str, rw.OVERWRITE)