forked from AdrianPrice/Domain-Independent-Deception
/
generateGoalsFiles.py
102 lines (81 loc) · 3.29 KB
/
generateGoalsFiles.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import os
import math
import argparse
import csv
import time
import subprocess
def main():
DOMAIN = 'zenotravel'
pb = '01'
domain_problem_path = 'experiments/' + DOMAIN + '/' + DOMAIN + '-p' + pb
domaind_ir = domain_problem_path + '/domain.pddl'
hyps_dir = domain_problem_path + '/hyps.dat'
template_dir = domain_problem_path + '/template.pddl'
hyps_file = open(hyps_dir, 'r')
new_hyps = []
for l in hyps_file:
new_l = l.replace('(and ', '')
new_l = new_l.replace(') (', ')|(')
new_l = new_l.replace('))', ') - 1.0')
new_hyps.append(new_l)
print(new_l)
new_problem_file = open(domain_problem_path + '/goals.txt', 'w')
for l in new_hyps:
new_problem_file.write(l)
new_problem_file.close()
def main_all_domains():
DOMAINS = ['blocks-world', 'depots', 'driverlog', 'dwr', 'logistics', 'rovers', 'sokoban', 'zenotravel']
NUMBER_OF_PROBLEMS = 10
for DOMAIN in DOMAINS:
for i in range(1,NUMBER_OF_PROBLEMS+1):
pb = '0' + str(i) if i <= 9 else str(i)
domain_problem_path = 'experiments/' + DOMAIN + '/' + DOMAIN + '-p' + pb
domain_dir = domain_problem_path + '/domain.pddl'
hyps_dir = domain_problem_path + '/hyps.dat'
template_dir = domain_problem_path + '/template.pddl'
print (domain_dir)
hyps_file = open(hyps_dir, 'r')
new_hyps = []
for l in hyps_file:
new_l = l.replace('(and ', '')
new_l = new_l.replace('(AND ', '')
new_l = new_l.replace(') (', ')|(')
new_l = new_l.replace('))', ') - 1.0')
new_hyps.append(new_l)
print(new_l)
new_problem_file = open(domain_problem_path + '/goals.txt', 'w')
for l in new_hyps:
new_problem_file.write(l)
new_problem_file.close()
def main_all_domains_no_real_hyp():
DOMAINS = ['blocks-words', 'grid-navigation', 'logistics', 'ferry']
NUMBER_OF_PROBLEMS = 10
for DOMAIN in DOMAINS:
for i in range(1,NUMBER_OF_PROBLEMS+1):
pb = '0' + str(i) if i <= 9 else str(i)
domain_problem_path = 'experiments/' + DOMAIN + '/' + 'p' + pb
domain_dir = domain_problem_path + '/domain.pddl'
hyps_dir = domain_problem_path + '/hyps.dat'
print (domain_dir)
real_hyp = ''
real_hype_file = open(domain_problem_path + '/real_hyp.dat', 'r')
for l in real_hype_file:
real_hyp = l
hyps_file = open(hyps_dir, 'r')
new_hyps = []
print(real_hyp)
for l in hyps_file:
if real_hyp in l:
continue
new_l = l.replace('(and ', '')
new_l = new_l.replace('(AND ', '')
new_l = new_l.replace(') (', ')|(')
new_l = new_l.replace('))', ') - 1.0')
new_hyps.append(new_l)
print(new_l)
new_problem_file = open(domain_problem_path + '/goals-no_real_hyp.txt', 'w')
for l in new_hyps:
new_problem_file.write(l)
new_problem_file.close()
if __name__ == '__main__':
main_all_domains_no_real_hyp()