Esempio n. 1
0
                                          stdin=subprocess.PIPE,
                                          stdout=subprocess.PIPE)
        return job

    def finish_solving(job, retcode):
        if retcode != 0:
            print('%s: ERROR (return code %d)' % (job['trace_file'], retcode))
        else:
            out = job['process'].communicate()[0].decode()
            energy = int(out)
            print('%s: SUCCESS (energy %d)' % (job['trace_file'], energy))
            os.rename(job['temp_file'], job['trace_file'])
            with io.open(job['meta_file'], 'w') as f:
                f.write(json.dumps({'energy': energy}))

    ps = common.filter_problems(low_index, high_index, kinds)
    queue = []
    for bots in range(low_bots, high_bots + 1):
        for p in ps:
            if not (p['prefix'] == 'FA' and bots == 1
                    and p['id'] in [181, 163]):
                p2 = dict(p)
                p2['bots'] = bots
                queue.append(p2)

    pool = [None] * job_count
    left = len(queue)
    while left > 0:
        time.sleep(0.01)
        for i in range(len(pool)):
            if pool[i] is None:
import common
from shutil import copyfile

if __name__ == '__main__':
    ps = common.filter_problems(0, 200, 'ADR')
    ts = common.get_all_good_traces()
    for p in ps:
        pts = [
            t for t in ts if t['id'] == p['id'] and t['prefix'] == p['prefix']
        ]
        if pts == []:
            print('%s%s: no solution' % (p['prefix'], p['id']))
            continue
        pts.sort(key=lambda pt: pt['energy'])
        best = pts[0]
        target_file = '/home/cakeplus/Desktop/panopticum_fuck/%s%03d.nbt.gz' % (
            best['prefix'], best['id'])
        print('copying %s to %s' % (best['fname'], target_file))
        copyfile(best['fname'], target_file)
import io
import os
import common
import sys


if __name__ == '__main__':
    ps = common.filter_problems(0, 200, sys.argv[1])
    ps_a = [ p for p in ps if p['prefix'] == 'FA' ]
    ps_d = [ p for p in ps if p['prefix'] == 'FD' ]
    ps_r = [ p for p in ps if p['prefix'] == 'FR' ]
    ps_u = [ p for p in ps if p['prefix'] == 'FU' ]
    ps = ps_a + ps_d + ps_r + ps_u

    ts = common.get_all_good_traces()

    total_energy = 0

    for p in ps:
        pts = [ t for t in ts if t['id'] == p['id'] and t['prefix'] == p['prefix']]
        if pts == []:
            print('%s%d: no solution' % (p['prefix'], p['id']))
            continue

        pts.sort(key = lambda pt: pt['energy'])
        def print_pt(pt):
            return '%s(%s)' % (pt['solver']+str(pt['bots'])+pt['solver2']+pt['bots2'], format(pt['energy'], ',d'))
        print('%s%s: %s' % (p['prefix'], p['id'], ', '.join(print_pt(pt) for pt in pts[:4])))

        best = pts[0]
import json
import sys
import os
import io
import common

temp_counter = 0

if __name__ == '__main__':
    if len(sys.argv) < 1:
        print('Usage: drunner.py executable')
        sys.exit(1)

    executable = sys.argv[1]

    ps = common.filter_problems(0, 200, 'D')
    ts = common.get_all_good_traces()

    for p in ps:
        pts = [t for t in ts if t['id'] == p['id'] and t['prefix'] == 'FA']
        if pts == []:
            print('FA%d: no solution' % p['id'])
            continue
        pts.sort(key=lambda pt: pt['energy'])
        best = pts[0]

        trace_base = 'FD%s_%s%d' % (p['id'], best['solver'], best['bots'])
        trace_file = common.traces_dir + trace_base + '.nbt.gz'
        meta_file = common.traces_dir + trace_base + '.meta'
        if os.path.isfile(meta_file):
            print('Trace %s already exists.' % trace_base)