-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_fama.py
executable file
·38 lines (28 loc) · 932 Bytes
/
run_fama.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
#!/usr/bin/env python
# Usage: ./run_fama.py [EMPTY_DOMAIN] [LOGS_FOLDER] [MODELS_FOLDER]
# e.g. ./run_fama.py empty-sokoban.pddl logs models
import sys, os
from meta_planning.parsers import parse_trajectory, parse_model
from meta_planning import LearningTask
from meta_planning.evaluation import SynEvaluator
empty = sys.argv[1]
log = sys.argv[2]
model = sys.argv[3]
# Define the initial model
M = parse_model(empty)
# Define the set of trajectories, observations
#for log in os.listdir(logs_folder):
# print('Generating trajectory for', log)
# id = log.split('.')[0].split('-')[1]
T = [parse_trajectory(log, M)]
O = [t.observe(1, action_observability=1) for t in T]
# Create learning task
lt = LearningTask(M, O)
solution = lt.learn()
id = 1
try:
# print(solution.learned_model)
with open(model, 'w') as m:
m.write(str(solution.learned_model))
except AttributeError:
print('No solution found')