-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.py
191 lines (180 loc) · 6.27 KB
/
settings.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
"""Settings used throughout the directory.
"""
import time # pylint:disable=unused-import
class EnvConfig:
"""Environment-specific constants.
"""
family_to_run = "tampnamo"
# family_to_run = "tampbins"
# family_to_run = "enemiesbig"
# family_to_run = "enemiessmall"
train_tests = { # dict from family to 1) list of train envs, 2) test env
"tampnamo": {"train": [],
"test": []},
"tampbins": {"train": [],
"test": []},
"enemiesbig": {"train": [],
"test": []},
"enemiessmall": {"train": [],
"test": []},
}
for diff in ["Easy", "Medium", "Hard"]:
for ind in range(50):
train_tests["enemiesbig"]["train"].append(
"EnemiesEnvFamilyBig{}{}".format(diff, ind))
train_tests["enemiessmall"]["train"].append(
"EnemiesEnvFamilySmall{}{}".format(diff, ind))
for ind in range(60, 70):
train_tests["enemiesbig"]["test"].append(
"EnemiesEnvFamilyBig{}{}".format(diff, ind))
train_tests["enemiessmall"]["test"].append(
"EnemiesEnvFamilySmall{}{}".format(diff, ind))
for ind in range(50):
train_tests["tampnamo"]["train"].append(
"TAMPNAMOEnvFamily{}".format(ind))
for ind in range(60, 70):
train_tests["tampnamo"]["test"].append(
"TAMPNAMOEnvFamily{}".format(ind))
for ind in range(50):
train_tests["tampbins"]["train"].append(
"TAMPBinsEnvFamily{}".format(ind))
for ind in range(60, 70):
train_tests["tampbins"]["test"].append(
"TAMPBinsEnvFamily{}".format(ind))
if family_to_run == "tampnamo":
max_episode_length = 20
gamma = 0.99
consider_conj_constraints = False
consider_disj_constraints = True
max_constraint_length = 8
max_constraint_domain_size = 20
indep_check_num_states = 25
indep_check_num_changes_action = 25
indep_check_num_changes_notaction = 25
net_arch = "CNN"
train_solver_timeout = 10
test_solver_timeout = 60
loss_thresh = 0.001
elif family_to_run == "tampbins":
max_episode_length = 20
gamma = 0.99
consider_conj_constraints = True
consider_disj_constraints = True
max_constraint_length = 2
max_constraint_domain_size = 20
indep_check_num_states = 25
indep_check_num_changes_action = 25
indep_check_num_changes_notaction = 25
net_arch = "FCN"
train_solver_timeout = 20
test_solver_timeout = 60
loss_thresh = 0.001
elif family_to_run == "enemiesbig":
max_episode_length = 25
gamma = 0.99
consider_conj_constraints = False
consider_disj_constraints = True
max_constraint_length = 4
max_constraint_domain_size = 4
indep_check_num_states = 100
indep_check_num_changes_action = 50
indep_check_num_changes_notaction = 50
net_arch = "CNN"
train_solver_timeout = 5
test_solver_timeout = 10
loss_thresh = 0.5
elif family_to_run == "enemiessmall":
max_episode_length = 25
gamma = 0.99
consider_conj_constraints = False
consider_disj_constraints = True
max_constraint_length = 3
max_constraint_domain_size = 3
indep_check_num_states = 100
indep_check_num_changes_action = 50
indep_check_num_changes_notaction = 50
net_arch = "CNN"
train_solver_timeout = 5
test_solver_timeout = 10
loss_thresh = 0.5
class SolverConfig:
"""Solver-specific constants.
"""
# solver_name = "ValueIteration"
# solver_name = "MCTS"
solver_name = "TAMPSolver"
# solver_name = "TAMPSolverStilman"
# solver_name = "BFSReplan"
if solver_name == "ValueIteration":
vi_epsilon = 0.01
vi_maxiters = 1000
elif solver_name == "AsyncValueIteration":
avi_queue_size = 1000
avi_queue_epsilon = 0.01
avi_maxiters = 10000
elif solver_name == "MCTS":
mcts_c = 500
mcts_timelimit = 0.25
# RRT stuff, not in an elif b/c needed by TAMP regardless of solver.
extend_granularity = 0.05
birrt_num_attempts = 10
birrt_num_iters = 50
birrt_smooth_amt = 50
class ApproachConfig:
"""Approach-specific constants.
"""
# approach_names is a list of classes from approaches/
approach_names = [
"ModelBased",
# "ModelBasedNoDropping",
# "FullTestPlanner",
# "PlanTransfer",
# "PolicyTransfer",
# "TaskConditionedPolicyTransfer",
]
model_path_prefix = "trained_models/{}_{}".format(
EnvConfig.family_to_run, SolverConfig.solver_name)
limbo_reward = -100
lam_dict = { # reward vs. time tradeoff coefficient
"ValueIteration": 1,
"MCTS": 0,
"TAMPSolver": 10,
"BFSReplan": 100,
}
try:
lam = lam_dict[SolverConfig.solver_name]
except KeyError:
lam = lam_dict[SolverConfig.solver_name+EnvConfig.family_to_run]
retro_num_trajs = 1 # Number of trajectories to collect for each policy
class GeneralConfig:
"""General configuration constants.
"""
mode = "both" # "train" or "test" or "both"
total_num_runs = 10
if mode == "train":
total_num_runs = 1
if EnvConfig.family_to_run == "tampbins":
num_eval_episodes_train = 3
num_eval_episodes_test = 5
elif EnvConfig.family_to_run.startswith("tamp") or \
EnvConfig.family_to_run.startswith("enemies"):
num_eval_episodes_train = 5
num_eval_episodes_test = 10
max_satisfy_tries = 1000000
start_seed = int(time.time())
seed = None
rand_state = None
verbosity = 1
do_render = False
do_training_render = False
use_debug_info_visualizer = False
def print_settings():
"""Print these settings.
"""
print("Seed: {}".format(GeneralConfig.seed))
print("Task family: {}".format(EnvConfig.family_to_run))
print("Solver name: {}".format(SolverConfig.solver_name))
print("Approaches: {}".format(ApproachConfig.approach_names))
print("Train/test split: {}".format(
EnvConfig.train_tests[EnvConfig.family_to_run]))
print()