def main():
    import argparse
    import sys
    import json
    parser = argparse.ArgumentParser()
    parser.add_argument('dirs', nargs='*')
    parser.add_argument('-i', '--include')
    args = parser.parse_args()

    if len(args.dirs) == 0:
        exit(1)

    summaries, configs = get_summaries_and_configs(
        args.dirs, summaryname="generation_summary.json")

    summary = merge_summary(*summaries)

    if args.include is not None:
        select(args.include, summary)

    summary_avg_generations = avg_generations(summary)

    id_name_map = id_name_map_from_configs(configs)

    output = {
        'avg_generations': summary_avg_generations,
        'id_name_map': id_name_map
    }

    json.dump(output, sys.stdout)
Exemple #2
0
def main():
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument('files', nargs='*')
    args = parser.parse_args()

    data = []
    for f in args.files:
        with open(f, 'r') as f:
            data.append(json.load(f))

    merged = merge_summary(*data)
    json.dump(merged, sys.stdout)
Exemple #3
0
def main():
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument('dirs', nargs='*')
    args = parser.parse_args()

    if len(args.dirs) == 0:
        exit(1)

    summaries, configs = get_summaries_and_configs(args.dirs)

    summary = merge_summary(*summaries)

    id_name_map = id_name_map_from_configs(configs)

    max_id = max(id_name_map.keys())

    table_begin = [r'\begin{longtable}{l | '
                   ] + ['c' for i in range(max_id + 1)] + ['}']
    table_begin = ' '.join(table_begin)
    print(table_begin)
    print('\hline')
    print(r'\endhead')

    for instance, algos in sorted(summary.items(), key=lambda x: x[0]):
        instance_name, _ = os.path.splitext(instance)
        instance_name = instance_name.replace('_', '-')
        line = [instance_name] + ['0' for i in range(max_id + 1)]
        maxitem, _ = argmax(algos, valuefunc=lambda x: int(x['fitness']))
        for id, data in algos.items():
            if id == maxitem:
                line[int(id) +
                     1] = r'\textcolor{red}{' + str(data['fitness']) + '}'
            else:
                line[int(id) + 1] = str(data['fitness'])
        print('&'.join(line) + r'\\')

    print(r'\end{longtable}')
Exemple #4
0
def main():
    import argparse
    import sys
    import json
    parser = argparse.ArgumentParser()
    parser.add_argument('dirs', nargs='*')
    parser.add_argument('-i', '--include')
    args = parser.parse_args()

    if len(args.dirs) == 0:
        exit(1)

    summaries, configs = get_summaries_and_configs(args.dirs)

    summary = merge_summary(*summaries)

    if args.include is not None:
        select(args.include, summary)

    id_name_map = id_name_map_from_configs(configs)

    summary_avg_fitness = avg_fitness(summary, id_name_map)

    json.dump(summary_avg_fitness, sys.stdout)