-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_prob.py
41 lines (32 loc) · 1.06 KB
/
create_prob.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
from common import *
import pandas
import sys
if __name__ == '__main__':
lines = list()
lines.append('(define(problem pb1)\n')
lines.append(' (:domain attack_graph)\n')
lines.append('(:objects s)\n\n')
vertices_file = sys.argv[1]
vertices = pandas.read_csv(vertices_file, header=None)
classified_vertices = {'AND': set(), 'OR': set(), 'LEAF': set()}
# classify the nodes
for v in vertices.values:
type = v[2]
classified_vertices[type].add(tuple(v))
temp = str()
for v in classified_vertices['LEAF']:
temp += '(' + format_string(v[1]) + ' s)\n'
lines.append('(:init\n')
lines.append(temp)
lines.append('\n)\n\n')
# in order to have all the transitions, we need all OR nodes to be true
lines.append('(:goal (and\n')
temp = str()
for v in classified_vertices['OR']:
temp += '(' + format_string(v[1]) + ' s)\n'
lines.append(temp)
lines.append(')\n')
lines.append(')\n\n')
lines.append(')\n')
with open("problem.pddl", 'w+') as f:
f.writelines(lines)