示例#1
0
def test_settings(domain, CMD):

    problems = get_file_list("exp-input/%s" % domain)
    toggles = ['PP', 'CA', 'NCB', 'CC', 'IBCP']

    results = exp.run_experiment(base_command="%s -q" % CMD,
                                 single_arguments={
                                     'problem': problems,
                                     'PP': ['-noPP', ''],
                                     'CA': ['-noCA', ''],
                                     'CC': ['-noCC', ''],
                                     'NCB': ['-noNCB', ''],
                                     'IBCP': ['-noIBCP', '']
                                 },
                                 time_limit=TIMEOUT,
                                 memory_limit=MEMORY,
                                 results_dir="results-%s-settings" % domain,
                                 processors=CORES,
                                 progress_file=None)

    #-- Compile
    file_output = "%s,problem,size,runtime\n" % ','.join(toggles)

    for result in results.get_ids():
        res = results[result]
        for tog in toggles:
            if '' == res.single_args[tog]:
                file_output += '1,'
            else:
                file_output += '0,'

        file_output += "%s,%d,%f\n" % _get_file_size_time_bdg(res)

    write_file(domain + '-results.csv', file_output)
示例#2
0
def test0():
    test_files = get_file_list('examples/', match_list=['.pdkb'])
    for f in test_files:
        print "\n Testing file: %s" % f
        parse_test_pdkb(f)
        print "***"
        print "*******************************************" * 2
        print "*******************************************" * 2
        print "***\n"
示例#3
0
def test_size_time(domain):

    print "\nTesting domain '%s'." % domain

    problems = get_file_list("exp-input/%s" % domain)
    results_size = {}
    results_time = {}

    print "Doing ddnnf..."

    results_ddnnf = exp.run_experiment(base_command="./sharpSAT-ddnnf -q",
                                       single_arguments={'problem': problems},
                                       time_limit=TIMEOUT,
                                       results_dir="results-%s-ddnnf" % domain,
                                       processors=CORES,
                                       memory_limit=MEMORY,
                                       progress_file=None)

    for result_id in results_ddnnf.get_ids():
        file, size, time = _get_file_size_time_bdg(results_ddnnf[result_id])
        results_size[file] = [size]
        results_time[file] = [time]

    print "\t...done!"
    print "Doing c2d..."

    results_c2d = exp.run_experiment(base_command="c2d",
                                     parameters={'-in': problems},
                                     time_limit=TIMEOUT,
                                     results_dir="results-%s-c2d" % domain,
                                     processors=CORES,
                                     memory_limit=MEMORY,
                                     progress_file=None)

    for result_id in results_c2d.get_ids():
        file, size, time = _get_file_size_time_c2d(results_c2d[result_id])
        results_size[file].append(size)
        results_time[file].append(time)

    print "\t...done!"

    #-- Compile
    file_output = "problem,ddnnf runtime,c2d runtime,ddnnf size,c2d size\n"

    for prob in results_size.keys():
        file_output += "%s,%f,%f,%d,%d\n" % (
            prob, results_time[prob][0], results_time[prob][1],
            results_size[prob][0], results_size[prob][1])

    write_file(domain + '-results.csv', file_output)

    #-- Cleanup
    os.system("rm exp-input/%s/*.nnf" % domain)
示例#4
0
def handle_single(dom):
    towrite = 'domains = [\n'

    extra_domain = False
    domdata = {}

    domdata['name'] = get_name(dom)
    domdata['description'] = domain_description[get_name(dom)]

    # Special Cases:
    # IPC-2000: freecell (non-pfiles)
    # IPC-2002: satellite (p#-pfile#.pddl)
    # IPC-2002: freecell (pfile#)

    if './freecell' == dom:
        extra_domain = True

        domdata['problems'] = [
            ((dom + '/domain.pddl')[2:], prob[2:]) for prob in sorted(
                get_file_list(dom,
                              forbidden_list=forbidden_files +
                              ['pfile', '/domain.pddl']))
        ]
        domdata['ipc'] = '2000'

        domdata2 = {}
        domdata2['name'] = domdata['name']
        domdata2['description'] = domain_description[get_name(dom)]
        domdata2['problems'] = [
            ((dom + '/domain.pddl')[2:], prob[2:]) for prob in sorted(
                get_file_list(dom,
                              forbidden_list=forbidden_files +
                              ['/domain.pddl'],
                              match_list=['pfile']))
        ]
        domdata2['ipc'] = '2002'

    elif './satellite' == dom:
        extra_domain = True

        domdata['problems'] = [
            ((dom + '/domain.pddl')[2:], prob[2:]) for prob in sorted(
                get_file_list(
                    dom, forbidden_list=forbidden_files + ['/domain.pddl']))
        ]
        domdata['ipc'] = ipc_map.get(dom[2:])

        domdata2 = {}
        domdata2['name'] = domdata['name']
        domdata2['description'] = domain_description[get_name(dom)]
        domdata2['problems'] = [
            ((dom + '/domain.pddl')[2:], prob[2:]) for prob in sorted(
                get_file_list(dom,
                              forbidden_list=forbidden_files +
                              ['/domain.pddl', '-HC-']))
        ]
        domdata2['ipc'] = '2002'

    else:
        domdata['problems'] = [((
            dom + '/domain.pddl'
        )[2:], prob[2:]) for prob in sorted(
            get_file_list(
                dom,
                forbidden_list=forbidden_files +
                ['/domain.pddl', '/domain-nosplit.pddl', '/orig-domain.pddl']))
                               ]
        domdata['ipc'] = ipc_map.get(dom[2:])

    towrite += pprint.pformat(domdata)
    if extra_domain:
        towrite += ',\n'
        towrite += pprint.pformat(domdata2)
    towrite += '\n]'

    #print "To be printed:\n-------"
    #print towrite
    #print "-------\n"

    print "Handling single domain: %s" % dom
    write_file(dom + '/api.py', towrite)
示例#5
0
def handle_double(dom):
    towrite = 'domains = [\n'

    domdata = {}

    domdata['name'] = get_name(dom)
    domdata['description'] = domain_description[get_name(dom)]

    domfiles = get_file_list(dom,
                             match_list=['domain'],
                             forbidden_list=forbidden_files)
    prbfiles = get_file_list(dom, forbidden_list=forbidden_files + ['domain'])

    if len(domfiles) == len(prbfiles):

        def remdom(dom):
            toret = dom
            for s in ['-domain', 'domain_']:
                toret = ''.join(toret.split(s))
            return toret

        dmap = {remdom(d): d for d in domfiles}
        if all([k in prbfiles for k in dmap]):
            print "Handling multi-domain: %s" % dom
            assert len(set(dmap.keys())) == len(set(prbfiles))
            domdata['problems'] = [(dmap[prob][2:], prob[2:])
                                   for prob in sorted(prbfiles)]
            domdata['ipc'] = ipc_map.get(dom[2:])
        elif dom in ['./psr-small', './airport']:
            print "Handling custom 50-problem domain: %s" % dom
            assert 100 == len(
                get_file_list(dom,
                              match_list=['pddl'],
                              forbidden_list=forbidden_files))
            probs = []
            for i in range(1, 51):
                d = get_file_list(dom,
                                  match_list=["p%02d-domain" % i],
                                  forbidden_list=forbidden_files)
                p = get_file_list(dom,
                                  match_list=["p%02d-" % i],
                                  forbidden_list=forbidden_files + ['domain'])
                assert 1 == len(d), str(d)
                assert 1 == len(p), str(p)
                probs.append((d[0][2:], p[0][2:]))
            domdata['problems'] = sorted(probs)
            domdata['ipc'] = ipc_map.get(dom[2:])
        else:
            print "Unhandled balanced multi-domain: %s" % dom
            return
    else:
        print "Unhandled lopsided multi-domain: %s" % dom

    towrite += pprint.pformat(domdata)
    towrite += '\n]'

    #print "To be printed:\n-------"
    #print towrite
    #print "-------\n"

    write_file(dom + '/api.py', towrite)
示例#6
0
            print "Unhandled balanced multi-domain: %s" % dom
            return
    else:
        print "Unhandled lopsided multi-domain: %s" % dom

    towrite += pprint.pformat(domdata)
    towrite += '\n]'

    #print "To be printed:\n-------"
    #print towrite
    #print "-------\n"

    write_file(dom + '/api.py', towrite)


domains = get_file_list('.', forbidden_list=['.py'])

single_dom = []
multi_dom = []
done_dom = []

print

for dom in domains:

    if os.path.isfile(dom + '/api.py'):
        done_dom.append(dom)
    else:
        if os.path.isfile(dom + '/domain.pddl'):
            single_dom.append(dom)
            for i in get_file_list(dom,
示例#7
0
    './transport-sat11-strips', './no-mystery', './miconic-fulladl',
    './gripper', './philosophers', './openstacks-sat08-strips',
    './scanalyzer-opt11-strips', './rovers', './psr-middle',
    './parcprinter-08-strips', './mprime', './schedule',
    './barman-sat11-strips', './settlers', './pegsol-opt11-strips',
    './barman-opt14-strips', './ged-sat14-strips', './rovers-02',
    './floortile-opt11-strips', './parking-sat14-strips',
    './elevators-sat11-strips', './openstacks', './floortile-sat11-strips',
    './hiking-opt14-strips', './pathways', './assembly',
    './nomystery-sat11-strips', './hiking-sat14-strips',
    './openstacks-opt08-adl', './storage', './tpp', './nomystery-opt11-strips',
    './ged-opt14-strips', './trucks-strips', './grid',
    './transport-opt14-strips', './satellite', './woodworking-opt11-strips'
])

domains = get_file_list('.', forbidden_list=['.py'])


def gen_js(domain):
    toret = "\t\tDomain.forge({dom_name:'%s', description:'%s'}).save().then(function(model) {\n" % (
        domain['name'], domain['description'])
    for (d, p) in domain['problems']:
        pname = p.split('/')[-1]
        domurl = "classical/%s" % d
        proburl = "classical/%s" % p
        toret += "\t\t\tProblem.forge({prob_name:'%s', domain:model.id, dom_url:'%s', prob_url:'%s'}).save();\n" % (
            pname, domurl, proburl)
    toret += "\t\t});\n"
    return toret

示例#8
0
import os

from krrt.utils import get_file_list, read_file, write_file, get_lines

domains = get_file_list('.', ['fixed', 'fip'], ['d_'])

print domains

for dom in domains:
    # Fix the original domain
    lines = read_file(dom)
    fixed_dom = '.'+''.join(dom.split('.')[:-1])+'-fixed.pddl'
    write_file(fixed_dom, [lines[0]] + ["(:requirements :typing :strips :non-deterministic)"] + lines[1:])
    
    # Fix the fip version
    preface = get_lines(dom, upper_bound = ':action')
    fixed_dom_fip = fixed_dom + '.fip'
    write_file(fixed_dom_fip, preface)
    
    print "python ../../src/translate/determinizer.py %s p_1_1.pddl >> %s" % (fixed_dom, fixed_dom_fip)
    os.system("python ../../src/translate/determinizer.py %s p_1_1.pddl >> %s" % (fixed_dom, fixed_dom_fip))
    os.system('echo ")" >> ' + fixed_dom_fip)
示例#9
0
def ab_compare(res1, res2):
    def get_time(line):
        if line[4] == '-':
            return max(0.1, float(line[2]))
        else:
            return float('inf')

    def get_size(line):
        if line[4] == '-':
            return float(line[3])
        else:
            return float('inf')

    def get_score(_x, y):
        x = max(_x, 0.001)
        if x == float('inf') and y == float('inf'):
            return 0.0
        else:
            return min(x, y) / x

    res1_experiments = set(
        map(lambda x: x.split('/')[-1], get_file_list(res1,
                                                      match_list=['.csv'])))
    res2_experiments = set(
        map(lambda x: x.split('/')[-1], get_file_list(res2,
                                                      match_list=['.csv'])))
    shared_results = list(res1_experiments & res2_experiments)

    print
    print "Found %d overlapping experiments to compare." % len(shared_results)

    time_score = [0.0, 0.0]
    size_score = [0.0, 0.0]
    coverage = [0, 0]

    for res in shared_results:
        data1 = load_CSV(res1 + '/' + res)[1:]
        data2 = load_CSV(res2 + '/' + res)[1:]

        if len(data1) != len(data2):
            print "Error with %s experiment -- different number of data points." % res
            continue

        times1 = [get_time(line) for line in data1]
        times2 = [get_time(line) for line in data2]
        time1 = sum(
            [get_score(times1[i], times2[i]) for i in range(len(data1))])
        time2 = sum(
            [get_score(times2[i], times1[i]) for i in range(len(data1))])

        sizes1 = [get_size(line) for line in data1]
        sizes2 = [get_size(line) for line in data2]
        size1 = sum(
            [get_score(sizes1[i], sizes2[i]) for i in range(len(data1))])
        size2 = sum(
            [get_score(sizes2[i], sizes1[i]) for i in range(len(data1))])

        cov1 = len(filter(lambda x: x[4] == '-', data1))
        cov2 = len(filter(lambda x: x[4] == '-', data2))

        time_score[0] += time1
        time_score[1] += time2
        size_score[0] += size1
        size_score[1] += size2
        coverage[0] += cov1
        coverage[1] += cov2

        print "\n    [ %s ]\n" % res.split('-results.csv')[0]
        print "  Coverage: %d -vs- %d" % (cov1, cov2)
        print "Size Score: %.2f -vs- %.2f" % (size1, size2)
        print "Time Score: %.2f -vs- %.2f\n" % (time1, time2)

    print "\n    [ OVERALL ]"
    print "  Coverage: %d -vs- %d" % (coverage[0], coverage[1])
    print "Size Score: %.2f -vs- %.2f" % (size_score[0], size_score[1])
    print "Time Score: %.2f -vs- %.2f" % (time_score[0], time_score[1])
    print