-
Notifications
You must be signed in to change notification settings - Fork 25
/
poli_eval.py
58 lines (46 loc) · 1.46 KB
/
poli_eval.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
import os
import subprocess
import sys
poli_files_dir = sys.argv[2]
exe_path = 'x64/Release/TerrainRL_Optimizer'
args = '-arg_file= ' + sys.argv[1]
root_dir = curr_dir =os.path.dirname(os.path.abspath(__file__))
print ("Root Directory" + str(root_dir))
os.chdir(root_dir)
files = os.listdir(poli_files_dir)
actor_files = []
critic_files = []
fd_files = []
for f in files:
filename, ext = os.path.splitext(f)
if (ext == '.h5'):
if '_critic' in filename:
critic_files.append(f)
elif '_forward_dynamics' in filename:
fd_files.append(f)
else:
actor_files.append(f)
num_files = len(actor_files)
num_critic_files = len(critic_files);
num_fd_files = len(fd_files);
print('model files:')
for f in range(0, num_files):
curr_str = actor_files[f];
if (num_critic_files > f):
curr_str += ' ' + critic_files[f]
print(curr_str)
print('\n')
num_files = len(actor_files)
f_steps = 1
actor_files.sort()
critic_files.sort()
fd_files.sort()
for f in range(0, num_files, f_steps):
command = exe_path + ' ' + args
command += ' ' + '-policy_model=' + ' ' + poli_files_dir + actor_files[f]
if (num_critic_files > f):
command += ' ' + '-critic_model=' + ' ' + poli_files_dir + critic_files[f]
if (num_fd_files > f):
command += ' ' + '-forward_dynamics_model=' + ' ' + poli_files_dir + fd_files[f]
print(command + '\n')
subprocess.call(command, shell=True)