Compare commits
9 Commits
idm_upgrad
...
e0d205bbd7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e0d205bbd7 | ||
|
|
910615cc00 | ||
|
|
7a134d98c9 | ||
|
|
261e35eae8 | ||
|
|
a9314c4657 | ||
|
|
a37995694d | ||
|
|
62c28d0cfa | ||
|
|
6f181a7351 | ||
|
|
81e38f55ab |
@@ -162,9 +162,9 @@ if __name__ == '__main__':
|
|||||||
},
|
},
|
||||||
'policy': {
|
'policy': {
|
||||||
'learning_rate': 3e-4,
|
'learning_rate': 3e-4,
|
||||||
'learning_rate_decay': 1.0,
|
'learning_rate_decay': tune.grid_search([0.001, 1.0]),
|
||||||
'hidden_layer_size': tune.grid_search([20, 40]),
|
'hidden_layer_size': tune.grid_search([10, 20, 40, 80]),
|
||||||
'n_hidden_layers': tune.grid_search([2, 3]),
|
'n_hidden_layers': tune.grid_search([2, 3, 4]),
|
||||||
'activation':0,
|
'activation':0,
|
||||||
},
|
},
|
||||||
'train_epochs': args.epochs,
|
'train_epochs': args.epochs,
|
||||||
|
|||||||
33
best_configs/shail-etienne4_expA.json
Normal file
33
best_configs/shail-etienne4_expA.json
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"experiment": "A",
|
||||||
|
"trainenv": {
|
||||||
|
"stop_on_collision": false,
|
||||||
|
"safe_actions_collision_method": "circle",
|
||||||
|
"abort_unsafe_collision_method": "circle"
|
||||||
|
},
|
||||||
|
"policy": {
|
||||||
|
"learning_rate": 0.0003,
|
||||||
|
"learning_rate_decay": 1.0,
|
||||||
|
"clip_ratio": 0.2,
|
||||||
|
"iterations_per_epoch": 500,
|
||||||
|
"hidden_layer_size": 40,
|
||||||
|
"n_hidden_layers": 3,
|
||||||
|
"activation": 0,
|
||||||
|
"option": 0
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"learning_rate": 0.001,
|
||||||
|
"iterations_per_epoch": 1000
|
||||||
|
},
|
||||||
|
"discriminator": {
|
||||||
|
"learning_rate": 0.001,
|
||||||
|
"weight_decay": 0.0001,
|
||||||
|
"iterations_per_epoch": 100,
|
||||||
|
"n_hidden_layers_element": 3,
|
||||||
|
"n_hidden_layers_global": 2,
|
||||||
|
"hidden_layer_size": 10,
|
||||||
|
"activation": 0
|
||||||
|
},
|
||||||
|
"train_epochs": 150,
|
||||||
|
"seed": 0
|
||||||
|
}
|
||||||
@@ -1,17 +1,23 @@
|
|||||||
import os
|
import os
|
||||||
from src.eval_main import eval_main
|
from src.eval_main import eval_main
|
||||||
from src.evaluation.utils import load_and_average
|
from src.evaluation.utils import load_and_average
|
||||||
|
import torch
|
||||||
|
import json
|
||||||
|
|
||||||
|
activations = [torch.nn.Tanh, torch.nn.LeakyReLU]
|
||||||
|
|
||||||
def main(method:str='expert', folder:str=None, locations=[(0,0)], skip_running=False):
|
def main(method:str='expert', folder:str=None, locations=[(0,0)], skip_running=False):
|
||||||
|
|
||||||
|
exclude_keys_from_policy_kwargs = {'learning_rate', 'learning_rate_decay', 'clip_ratio', 'iterations_per_epoch', 'option'}
|
||||||
policy_kwargs = {}
|
policy_kwargs = {}
|
||||||
|
|
||||||
if method in ['expert', 'idm']:
|
if method in ['expert', 'idm']:
|
||||||
env, env_kwargs ='NRasterizedRouteIncrementingAgent', {}
|
env, env_kwargs ='NRasterizedRouteIncrementingAgent', {}
|
||||||
elif method in ['bc','gail']:
|
elif method in ['bc','gail']:
|
||||||
env='NormalizedContinuousEvalEnv'
|
env='NormalizedContinuousEvalEnv'
|
||||||
env_kwargs={'stop_on_collision':True, 'max_episode_steps':1000}
|
env_kwargs={'stop_on_collision':True, 'max_episode_steps':1000}
|
||||||
elif method in ['hail']:
|
elif method in ['hail']:
|
||||||
env = 'NormalizedOptionsEvalEnv'
|
env = 'NormalizedSafeOptionsEvalEnv'
|
||||||
env_kwargs={'stop_on_collision':True, 'max_episode_steps':1000, 'safe_actions_collision_method': None, 'abort_unsafe_collision_method': None}
|
env_kwargs={'stop_on_collision':True, 'max_episode_steps':1000, 'safe_actions_collision_method': None, 'abort_unsafe_collision_method': None}
|
||||||
elif method in ['shail']:
|
elif method in ['shail']:
|
||||||
env = 'NormalizedSafeOptionsEvalEnv'
|
env = 'NormalizedSafeOptionsEvalEnv'
|
||||||
@@ -23,7 +29,18 @@ def main(method:str='expert', folder:str=None, locations=[(0,0)], skip_running=F
|
|||||||
|
|
||||||
if folder is not None:
|
if folder is not None:
|
||||||
files = [os.path.join(folder, f) for f in os.listdir(folder) if os.path.isfile(os.path.join(folder, f))]
|
files = [os.path.join(folder, f) for f in os.listdir(folder) if os.path.isfile(os.path.join(folder, f))]
|
||||||
print('%i folders found in %s folder' %(len(files), folder))
|
files = [f for f in files if f.endswith('.pt')]
|
||||||
|
with open(os.path.join(folder, 'config.json'), 'rb') as f:
|
||||||
|
config = json.load(f)
|
||||||
|
print('%i policy files found in %s folder' %(len(files), folder))
|
||||||
|
print('found policy config', config['policy'])
|
||||||
|
|
||||||
|
policy_config = {k: v for k, v in config['policy'].items() if k not in exclude_keys_from_policy_kwargs}
|
||||||
|
policy_config['activation'] = activations[policy_config['activation']]
|
||||||
|
print('final policy config', policy_config)
|
||||||
|
|
||||||
|
policy_kwargs.update(policy_config)
|
||||||
|
print('final policy kwargs', policy_kwargs)
|
||||||
|
|
||||||
if not skip_running:
|
if not skip_running:
|
||||||
for policy_file in files:
|
for policy_file in files:
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ def training_function(config):
|
|||||||
), options=option_list[config['policy']['option']],
|
), options=option_list[config['policy']['option']],
|
||||||
safe_actions_collision_method=config['trainenv']['safe_actions_collision_method'],
|
safe_actions_collision_method=config['trainenv']['safe_actions_collision_method'],
|
||||||
abort_unsafe_collision_method=config['trainenv']['abort_unsafe_collision_method'],
|
abort_unsafe_collision_method=config['trainenv']['abort_unsafe_collision_method'],
|
||||||
) for _ in range(60)]
|
) for _ in range(120)]
|
||||||
|
|
||||||
elif config['experiment'] == 'B':
|
elif config['experiment'] == 'B':
|
||||||
envs = sum([[SafeOptionsEnv(Setobs(
|
envs = sum([[SafeOptionsEnv(Setobs(
|
||||||
@@ -78,7 +78,7 @@ def training_function(config):
|
|||||||
), options=option_list[config['policy']['option']],
|
), options=option_list[config['policy']['option']],
|
||||||
safe_actions_collision_method=config['trainenv']['safe_actions_collision_method'],
|
safe_actions_collision_method=config['trainenv']['safe_actions_collision_method'],
|
||||||
abort_unsafe_collision_method=config['trainenv']['abort_unsafe_collision_method'],
|
abort_unsafe_collision_method=config['trainenv']['abort_unsafe_collision_method'],
|
||||||
) for _ in range(15)] for track in range(4)],[])
|
) for _ in range(30)] for track in range(4)],[])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
@@ -142,7 +142,7 @@ def training_function(config):
|
|||||||
v_opt=v_opt,
|
v_opt=v_opt,
|
||||||
v_iters=config['value']['iterations_per_epoch'],
|
v_iters=config['value']['iterations_per_epoch'],
|
||||||
epochs=config['train_epochs'],
|
epochs=config['train_epochs'],
|
||||||
rollout_episodes=60,
|
rollout_episodes=120,
|
||||||
rollout_steps=60,
|
rollout_steps=60,
|
||||||
gamma=0.99,
|
gamma=0.99,
|
||||||
gae_lambda=0.9,
|
gae_lambda=0.9,
|
||||||
@@ -185,11 +185,11 @@ if __name__ == '__main__':
|
|||||||
'learning_rate': 3e-4,
|
'learning_rate': 3e-4,
|
||||||
'learning_rate_decay': 1.0,
|
'learning_rate_decay': 1.0,
|
||||||
'clip_ratio': 0.2,
|
'clip_ratio': 0.2,
|
||||||
'iterations_per_epoch': 100,
|
'iterations_per_epoch': tune.grid_search([250, 500, 750]),
|
||||||
'hidden_layer_size': tune.grid_search([20, 40]),
|
'hidden_layer_size': 40, #tune.grid_search([20, 40]),
|
||||||
'n_hidden_layers': tune.grid_search([2, 3]),
|
'n_hidden_layers': 3, #tune.grid_search([2, 3]),
|
||||||
'activation':0,
|
'activation':0,
|
||||||
'option': tune.grid_search(list(range(len(option_list))))
|
'option': 0, #tune.grid_search(list(range(len(option_list))))
|
||||||
},
|
},
|
||||||
'value': {
|
'value': {
|
||||||
'learning_rate': 1e-3,
|
'learning_rate': 1e-3,
|
||||||
@@ -199,8 +199,8 @@ if __name__ == '__main__':
|
|||||||
'learning_rate': 1e-3,
|
'learning_rate': 1e-3,
|
||||||
'weight_decay': 1e-4,
|
'weight_decay': 1e-4,
|
||||||
'iterations_per_epoch': 100,
|
'iterations_per_epoch': 100,
|
||||||
'n_hidden_layers_element': tune.grid_search([3,4]),
|
'n_hidden_layers_element': 3, #tune.grid_search([3,4]),
|
||||||
'n_hidden_layers_global': tune.grid_search([1,2]),
|
'n_hidden_layers_global': 2, #tune.grid_search([1,2]),
|
||||||
'hidden_layer_size': 10,
|
'hidden_layer_size': 10,
|
||||||
'activation': 0,
|
'activation': 0,
|
||||||
},
|
},
|
||||||
@@ -247,6 +247,13 @@ if __name__ == '__main__':
|
|||||||
os.makedirs(savepath)
|
os.makedirs(savepath)
|
||||||
|
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
|
# save config
|
||||||
|
shutil.copyfile(
|
||||||
|
args.test,
|
||||||
|
os.path.join(savepath, 'config.json')
|
||||||
|
)
|
||||||
|
|
||||||
for i in range(args.test_seeds):
|
for i in range(args.test_seeds):
|
||||||
s = analysis._checkpoints[i]['config']['seed']
|
s = analysis._checkpoints[i]['config']['seed']
|
||||||
check_dir = analysis._checkpoints[i]['logdir']
|
check_dir = analysis._checkpoints[i]['logdir']
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ class PControllerPolicy(BaseAlgorithm):
|
|||||||
self._env = env
|
self._env = env
|
||||||
self.target_v = 8.94 # m/s
|
self.target_v = 8.94 # m/s
|
||||||
self.attn_weight = 20
|
self.attn_weight = 20
|
||||||
|
|
||||||
# BaseAlgorithm abstract methods
|
# BaseAlgorithm abstract methods
|
||||||
def _setup_model(self):
|
def _setup_model(self):
|
||||||
return None
|
return None
|
||||||
def learn(self, *args, **kwargs):
|
def learn(self, *args, **kwargs):
|
||||||
return self
|
return self
|
||||||
@@ -26,7 +26,7 @@ class PControllerPolicy(BaseAlgorithm):
|
|||||||
Generate action, state from observation
|
Generate action, state from observation
|
||||||
|
|
||||||
(But actually generate next action from underlying environment state)
|
(But actually generate next action from underlying environment state)
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
observation (np.ndarray): instantaneous observation from environment
|
observation (np.ndarray): instantaneous observation from environment
|
||||||
|
|
||||||
@@ -36,16 +36,16 @@ class PControllerPolicy(BaseAlgorithm):
|
|||||||
"""
|
"""
|
||||||
agent = self._env._agent
|
agent = self._env._agent
|
||||||
ego_state = self._env._env.projected_state[agent].numpy() # (5,) tensor
|
ego_state = self._env._env.projected_state[agent].numpy() # (5,) tensor
|
||||||
|
|
||||||
|
|
||||||
# relative_state = np.delete(self._env._env.relative_state[agent].numpy(), agent, axis=0) #(nv-1, 6) tensor
|
# relative_state = np.delete(self._env._env.relative_state[agent].numpy(), agent, axis=0) #(nv-1, 6) tensor
|
||||||
|
|
||||||
# calculate front and left distances from ego
|
# calculate front and left distances from ego
|
||||||
|
|
||||||
# calculate relative speed in direction of position difference vector
|
# calculate relative speed in direction of position difference vector
|
||||||
|
|
||||||
# calculate angle alpha and distance d of vehicle i from ego heading
|
# calculate angle alpha and distance d of vehicle i from ego heading
|
||||||
|
|
||||||
# attn[i] ~= exp( -(alpha[i])^2 - .01 * d[i] - .1 * vrel[i]
|
# attn[i] ~= exp( -(alpha[i])^2 - .01 * d[i] - .1 * vrel[i]
|
||||||
|
|
||||||
|
|
||||||
@@ -60,14 +60,14 @@ class IDMRulePolicy(BaseAlgorithm):
|
|||||||
|
|
||||||
The front car is chosen as the closer of:
|
The front car is chosen as the closer of:
|
||||||
- closest car within a 45 degree half angle cone of the ego's heading
|
- closest car within a 45 degree half angle cone of the ego's heading
|
||||||
- ''' after propagating the environment forward by `t_future' seconds with
|
- ''' after propagating the environment forward by `t_future' seconds with
|
||||||
current headings and velocities
|
current headings and velocities
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, env: Intersimple,
|
def __init__(self, env: Intersimple,
|
||||||
target_speed:float= 8.94,
|
target_speed:float= 8.94,
|
||||||
t_future:List[float]=[0., 1., 2., 3.],
|
t_future:List[float]=[0., 1., 2., 3.],
|
||||||
half_angle:float=60.):
|
half_angle:float=60.):
|
||||||
"""
|
"""
|
||||||
Initialize policy with pointer to environment it will run on and target speed
|
Initialize policy with pointer to environment it will run on and target speed
|
||||||
@@ -82,7 +82,6 @@ class IDMRulePolicy(BaseAlgorithm):
|
|||||||
self._env = env
|
self._env = env
|
||||||
self.t_future = t_future
|
self.t_future = t_future
|
||||||
self.half_angle = half_angle
|
self.half_angle = half_angle
|
||||||
self.max_heading_diff = 120
|
|
||||||
|
|
||||||
# Default IDM parameters
|
# Default IDM parameters
|
||||||
assert target_speed>0, 'negative target speed'
|
assert target_speed>0, 'negative target speed'
|
||||||
@@ -96,18 +95,18 @@ class IDMRulePolicy(BaseAlgorithm):
|
|||||||
np.seterr(invalid='ignore')
|
np.seterr(invalid='ignore')
|
||||||
|
|
||||||
# BaseAlgorithm abstract methods
|
# BaseAlgorithm abstract methods
|
||||||
def _setup_model(self):
|
def _setup_model(self):
|
||||||
return None
|
return None
|
||||||
def learn(self, *args, **kwargs):
|
def learn(self, *args, **kwargs):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def predict(self, observation:np.ndarray,
|
def predict(self, observation:np.ndarray,
|
||||||
*args, **kwargs) -> Tuple[np.ndarray, None]:
|
*args, **kwargs) -> Tuple[np.ndarray, None]:
|
||||||
"""
|
"""
|
||||||
Predict action, state from observation
|
Predict action, state from observation
|
||||||
|
|
||||||
(But actually generate next action from underlying environment state)
|
(But actually generate next action from underlying environment state)
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
observation (np.ndarray): instantaneous observation from environment
|
observation (np.ndarray): instantaneous observation from environment
|
||||||
|
|
||||||
@@ -139,11 +138,11 @@ class IDMRulePolicy(BaseAlgorithm):
|
|||||||
if t > 0:
|
if t > 0:
|
||||||
xy2 = xy + t * v * np.vstack((np.cos(psi[:,0]), np.sin(psi[:,0]))).T
|
xy2 = xy + t * v * np.vstack((np.cos(psi[:,0]), np.sin(psi[:,0]))).T
|
||||||
d2, r2, i2 = self.get_ego_dr(agent, xy2, v, psi)
|
d2, r2, i2 = self.get_ego_dr(agent, xy2, v, psi)
|
||||||
|
|
||||||
# choose closer vehicle (now vs imagined)
|
# choose closer vehicle (now vs imagined)
|
||||||
if d2 < d:
|
if d2 < d:
|
||||||
d, r, i = d2, r2, i2
|
d, r, i = d2, r2, i2
|
||||||
|
|
||||||
# Update environment interaction graph with i
|
# Update environment interaction graph with i
|
||||||
if i:
|
if i:
|
||||||
self._env._env._graph._neighbor_dict={agent:[i]}
|
self._env._env._graph._neighbor_dict={agent:[i]}
|
||||||
@@ -156,19 +155,19 @@ class IDMRulePolicy(BaseAlgorithm):
|
|||||||
|
|
||||||
assert (d_des>= self.d_min)
|
assert (d_des>= self.d_min)
|
||||||
action = self.a_max*(1 - (s/self.s_max)**4 - (d_des/d)**2)
|
action = self.a_max*(1 - (s/self.s_max)**4 - (d_des/d)**2)
|
||||||
|
|
||||||
# normalize action to range if env is a NormalizedActionSpace
|
# normalize action to range if env is a NormalizedActionSpace
|
||||||
if isinstance(self._env, NormalizedActionSpace):
|
if isinstance(self._env, NormalizedActionSpace):
|
||||||
action = self._env._normalize(action)
|
action = self._env._normalize(action)
|
||||||
|
|
||||||
assert action.shape==(1,)
|
assert action.shape==(1,)
|
||||||
return action
|
return action
|
||||||
|
|
||||||
def get_ego_dr(self, agent:int, xy: np.ndarray,
|
def get_ego_dr(self, agent:int, xy: np.ndarray,
|
||||||
v: np.ndarray, psi: np.ndarray) -> Tuple[float, float, Optional[int]]:
|
v: np.ndarray, psi: np.ndarray) -> Tuple[float, float, Optional[int]]:
|
||||||
"""
|
"""
|
||||||
Return distance and relative speed of closest car within half angle from heading
|
Return distance and relative speed of closest car within half angle from heading
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
agent (int): agent index
|
agent (int): agent index
|
||||||
xy (np.ndarray): (nv, 2) x and y positions
|
xy (np.ndarray): (nv, 2) x and y positions
|
||||||
@@ -178,7 +177,7 @@ class IDMRulePolicy(BaseAlgorithm):
|
|||||||
Returns:
|
Returns:
|
||||||
d (float): distance to closest vehicle in cone
|
d (float): distance to closest vehicle in cone
|
||||||
r (float): relative speed between the two vehicles
|
r (float): relative speed between the two vehicles
|
||||||
i (Optional[int]): index of closest vehicle, or None
|
i (Optional[int]): index of closest vehicle, or None
|
||||||
"""
|
"""
|
||||||
nv, nxy = xy.shape
|
nv, nxy = xy.shape
|
||||||
nv2, nvel = v.shape
|
nv2, nvel = v.shape
|
||||||
@@ -193,12 +192,8 @@ class IDMRulePolicy(BaseAlgorithm):
|
|||||||
dl = (dxys*np.hstack((-np.sin(psi), np.cos(psi)))).sum(-1) # (nv, )
|
dl = (dxys*np.hstack((-np.sin(psi), np.cos(psi)))).sum(-1) # (nv, )
|
||||||
alpha = to_circle(np.arctan2(dl, df))
|
alpha = to_circle(np.arctan2(dl, df))
|
||||||
|
|
||||||
heading_diff = to_circle(psi - psi[agent]).flatten()
|
val_idx = np.arange(nv)[(np.abs(alpha) < self.half_angle*np.pi/180) & (np.arange(nv) != agent)]
|
||||||
|
|
||||||
val_idx = np.arange(nv)[
|
|
||||||
(np.abs(alpha) < self.half_angle*np.pi/180) & (np.arange(nv) != agent) & (np.abs(heading_diff) < self.max_heading_diff*np.pi/180)
|
|
||||||
]
|
|
||||||
|
|
||||||
if len(val_idx)==0:
|
if len(val_idx)==0:
|
||||||
i = None
|
i = None
|
||||||
d = float('inf')
|
d = float('inf')
|
||||||
@@ -207,10 +202,10 @@ class IDMRulePolicy(BaseAlgorithm):
|
|||||||
idx = np.argmin(ds[val_idx]) # closest car which meets requirements
|
idx = np.argmin(ds[val_idx]) # closest car which meets requirements
|
||||||
i = int(val_idx[idx])
|
i = int(val_idx[idx])
|
||||||
d = ds[i]
|
d = ds[i]
|
||||||
r = v[i,0]-v[agent,0]
|
r = v[i,0]-v[agent,0]
|
||||||
|
|
||||||
return d, r, i
|
return d, r, i
|
||||||
|
|
||||||
def to_circle(x: np.ndarray) -> np.ndarray:
|
def to_circle(x: np.ndarray) -> np.ndarray:
|
||||||
"""
|
"""
|
||||||
Casts x (in rad) to [-pi, pi)
|
Casts x (in rad) to [-pi, pi)
|
||||||
|
|||||||
@@ -41,33 +41,33 @@ def load_policy(method:str,
|
|||||||
if method == 'idm':
|
if method == 'idm':
|
||||||
policy = IDMRulePolicy(env, **policy_kwargs)
|
policy = IDMRulePolicy(env, **policy_kwargs)
|
||||||
elif method == 'bc':
|
elif method == 'bc':
|
||||||
policy = SetPolicy(env.action_space.shape[-1])
|
policy = SetPolicy(env.action_space.shape[-1], **policy_kwargs)
|
||||||
policy.load_state_dict(torch.load(policy_file, map_location=ml))
|
policy.load_state_dict(torch.load(policy_file, map_location=ml))
|
||||||
policy.eval()
|
policy.eval()
|
||||||
elif method == 'gail-trpo':
|
elif method == 'gail-trpo':
|
||||||
policy = SetPolicy(env.action_space.shape[-1])
|
policy = SetPolicy(env.action_space.shape[-1], **policy_kwargs)
|
||||||
policy(torch.zeros(env.observation_space.shape))
|
policy(torch.zeros(env.observation_space.shape))
|
||||||
policy = ReparamPolicy(policy)
|
policy = ReparamPolicy(policy)
|
||||||
policy.load_state_dict(torch.load(policy_file, map_location=ml))
|
policy.load_state_dict(torch.load(policy_file, map_location=ml))
|
||||||
policy.eval()
|
policy.eval()
|
||||||
elif method == 'gail':
|
elif method == 'gail':
|
||||||
policy = SetPolicy(env.action_space.shape[-1])
|
policy = SetPolicy(env.action_space.shape[-1], **policy_kwargs)
|
||||||
policy.load_state_dict(torch.load(policy_file, map_location=ml))
|
policy.load_state_dict(torch.load(policy_file, map_location=ml))
|
||||||
policy.eval()
|
policy.eval()
|
||||||
elif method == 'rail':
|
elif method == 'rail':
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
elif method == 'hail-trpo':
|
elif method == 'hail-trpo':
|
||||||
policy = SetDiscretePolicy(env.action_space.n)
|
policy = SetMaskedDiscretePolicy(env.action_space.n, **policy_kwargs)
|
||||||
policy(torch.zeros(env.observation_space.shape))
|
policy(torch.zeros(env.observation_space.shape))
|
||||||
policy = ReparamPolicy(policy)
|
policy = ReparamPolicy(policy)
|
||||||
policy.load_state_dict(torch.load(policy_file, map_location=ml))
|
policy.load_state_dict(torch.load(policy_file, map_location=ml))
|
||||||
policy.eval()
|
policy.eval()
|
||||||
elif method == 'hail':
|
elif method == 'hail':
|
||||||
policy = SetDiscretePolicy(env.action_space.n)
|
policy = SetMaskedDiscretePolicy(env.action_space.n, **policy_kwargs)
|
||||||
policy.load_state_dict(torch.load(policy_file, map_location=ml))
|
policy.load_state_dict(torch.load(policy_file, map_location=ml))
|
||||||
policy.eval()
|
policy.eval()
|
||||||
elif method == 'shail-trpo':
|
elif method == 'shail-trpo':
|
||||||
policy = SetMaskedDiscretePolicy(env.action_space.n)
|
policy = SetMaskedDiscretePolicy(env.action_space.n, **policy_kwargs)
|
||||||
policy(
|
policy(
|
||||||
torch.zeros(env.observation_space['observation'].shape),
|
torch.zeros(env.observation_space['observation'].shape),
|
||||||
torch.zeros(env.observation_space['safe_actions'].shape)
|
torch.zeros(env.observation_space['safe_actions'].shape)
|
||||||
@@ -76,7 +76,7 @@ def load_policy(method:str,
|
|||||||
policy.load_state_dict(torch.load(policy_file, map_location=ml))
|
policy.load_state_dict(torch.load(policy_file, map_location=ml))
|
||||||
policy.eval()
|
policy.eval()
|
||||||
elif method == 'shail':
|
elif method == 'shail':
|
||||||
policy = SetMaskedDiscretePolicy(env.action_space.n)
|
policy = SetMaskedDiscretePolicy(env.action_space.n, **policy_kwargs)
|
||||||
policy.load_state_dict(torch.load(policy_file, map_location=ml))
|
policy.load_state_dict(torch.load(policy_file, map_location=ml))
|
||||||
policy.eval()
|
policy.eval()
|
||||||
else:
|
else:
|
||||||
|
|||||||
15
test_policies/bc/expA/config.json
Normal file
15
test_policies/bc/expA/config.json
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"experiment": "A",
|
||||||
|
"trainenv": {
|
||||||
|
"stop_on_collision": false
|
||||||
|
},
|
||||||
|
"policy": {
|
||||||
|
"learning_rate": 0.0003,
|
||||||
|
"learning_rate_decay": 1.0,
|
||||||
|
"hidden_layer_size": 40,
|
||||||
|
"n_hidden_layers": 2,
|
||||||
|
"activation": 0
|
||||||
|
},
|
||||||
|
"train_epochs": 300,
|
||||||
|
"seed": 0
|
||||||
|
}
|
||||||
15
test_policies/bc/expB/config.json
Normal file
15
test_policies/bc/expB/config.json
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"experiment": "B",
|
||||||
|
"trainenv": {
|
||||||
|
"stop_on_collision": false
|
||||||
|
},
|
||||||
|
"policy": {
|
||||||
|
"learning_rate": 0.0003,
|
||||||
|
"learning_rate_decay": 1.0,
|
||||||
|
"hidden_layer_size": 40,
|
||||||
|
"n_hidden_layers": 2,
|
||||||
|
"activation": 0
|
||||||
|
},
|
||||||
|
"train_epochs": 300,
|
||||||
|
"seed": 0
|
||||||
|
}
|
||||||
31
test_policies/gail/expA/config.json
Normal file
31
test_policies/gail/expA/config.json
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"experiment": "A",
|
||||||
|
"trainenv": {
|
||||||
|
"stop_on_collision": false
|
||||||
|
},
|
||||||
|
"policy": {
|
||||||
|
"learning_rate": 0.0003,
|
||||||
|
"learning_rate_decay": 1.0,
|
||||||
|
"clip_ratio": 0.2,
|
||||||
|
"iterations_per_epoch": 100,
|
||||||
|
"hidden_layer_size": 40,
|
||||||
|
"n_hidden_layers": 2,
|
||||||
|
"activation": 0
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"learning_rate": 0.0001,
|
||||||
|
"weight_decay": 0.001,
|
||||||
|
"iterations_per_epoch": 1000
|
||||||
|
},
|
||||||
|
"discriminator": {
|
||||||
|
"learning_rate": 0.001,
|
||||||
|
"weight_decay": 0.0001,
|
||||||
|
"iterations_per_epoch": 100,
|
||||||
|
"n_hidden_layers_element": 4,
|
||||||
|
"n_hidden_layers_global": 1,
|
||||||
|
"hidden_layer_size": 10,
|
||||||
|
"activation": 0
|
||||||
|
},
|
||||||
|
"train_epochs": 100,
|
||||||
|
"seed": 0
|
||||||
|
}
|
||||||
31
test_policies/gail/expB/config.json
Normal file
31
test_policies/gail/expB/config.json
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"experiment": "B",
|
||||||
|
"trainenv": {
|
||||||
|
"stop_on_collision": false
|
||||||
|
},
|
||||||
|
"policy": {
|
||||||
|
"learning_rate": 0.0003,
|
||||||
|
"learning_rate_decay": 1.0,
|
||||||
|
"clip_ratio": 0.2,
|
||||||
|
"iterations_per_epoch": 100,
|
||||||
|
"hidden_layer_size": 40,
|
||||||
|
"n_hidden_layers": 2,
|
||||||
|
"activation": 0
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"learning_rate": 0.0001,
|
||||||
|
"weight_decay": 0.001,
|
||||||
|
"iterations_per_epoch": 1000
|
||||||
|
},
|
||||||
|
"discriminator": {
|
||||||
|
"learning_rate": 0.001,
|
||||||
|
"weight_decay": 0.0001,
|
||||||
|
"iterations_per_epoch": 100,
|
||||||
|
"n_hidden_layers_element": 4,
|
||||||
|
"n_hidden_layers_global": 1,
|
||||||
|
"hidden_layer_size": 10,
|
||||||
|
"activation": 0
|
||||||
|
},
|
||||||
|
"train_epochs": 100,
|
||||||
|
"seed": 0
|
||||||
|
}
|
||||||
33
test_policies/hail-etienne/expA/config.json
Normal file
33
test_policies/hail-etienne/expA/config.json
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"experiment": "A",
|
||||||
|
"trainenv": {
|
||||||
|
"stop_on_collision": false,
|
||||||
|
"safe_actions_collision_method": null,
|
||||||
|
"abort_unsafe_collision_method": null
|
||||||
|
},
|
||||||
|
"policy": {
|
||||||
|
"learning_rate": 0.0003,
|
||||||
|
"learning_rate_decay": 1.0,
|
||||||
|
"clip_ratio": 0.2,
|
||||||
|
"iterations_per_epoch": 100,
|
||||||
|
"hidden_layer_size": 20,
|
||||||
|
"n_hidden_layers": 4,
|
||||||
|
"activation": 0,
|
||||||
|
"option": 0
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"learning_rate": 0.001,
|
||||||
|
"iterations_per_epoch": 1000
|
||||||
|
},
|
||||||
|
"discriminator": {
|
||||||
|
"learning_rate": 0.001,
|
||||||
|
"weight_decay": 0.0001,
|
||||||
|
"iterations_per_epoch": 100,
|
||||||
|
"n_hidden_layers_element": 3,
|
||||||
|
"n_hidden_layers_global": 2,
|
||||||
|
"hidden_layer_size": 10,
|
||||||
|
"activation": 0
|
||||||
|
},
|
||||||
|
"train_epochs": 100,
|
||||||
|
"seed": 0
|
||||||
|
}
|
||||||
BIN
test_policies/hail-etienne/expA/policy_seed1.pt
Normal file
BIN
test_policies/hail-etienne/expA/policy_seed1.pt
Normal file
Binary file not shown.
BIN
test_policies/hail-etienne/expA/policy_seed2.pt
Normal file
BIN
test_policies/hail-etienne/expA/policy_seed2.pt
Normal file
Binary file not shown.
BIN
test_policies/hail-etienne/expA/policy_seed3.pt
Normal file
BIN
test_policies/hail-etienne/expA/policy_seed3.pt
Normal file
Binary file not shown.
BIN
test_policies/hail-etienne/expA/policy_seed4.pt
Normal file
BIN
test_policies/hail-etienne/expA/policy_seed4.pt
Normal file
Binary file not shown.
BIN
test_policies/hail-etienne/expA/policy_seed5.pt
Normal file
BIN
test_policies/hail-etienne/expA/policy_seed5.pt
Normal file
Binary file not shown.
33
test_policies/hail-etienne/expB/config.json
Normal file
33
test_policies/hail-etienne/expB/config.json
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"experiment": "B",
|
||||||
|
"trainenv": {
|
||||||
|
"stop_on_collision": false,
|
||||||
|
"safe_actions_collision_method": null,
|
||||||
|
"abort_unsafe_collision_method": null
|
||||||
|
},
|
||||||
|
"policy": {
|
||||||
|
"learning_rate": 0.0003,
|
||||||
|
"learning_rate_decay": 1.0,
|
||||||
|
"clip_ratio": 0.2,
|
||||||
|
"iterations_per_epoch": 100,
|
||||||
|
"hidden_layer_size": 20,
|
||||||
|
"n_hidden_layers": 4,
|
||||||
|
"activation": 0,
|
||||||
|
"option": 0
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"learning_rate": 0.001,
|
||||||
|
"iterations_per_epoch": 1000
|
||||||
|
},
|
||||||
|
"discriminator": {
|
||||||
|
"learning_rate": 0.001,
|
||||||
|
"weight_decay": 0.0001,
|
||||||
|
"iterations_per_epoch": 100,
|
||||||
|
"n_hidden_layers_element": 3,
|
||||||
|
"n_hidden_layers_global": 2,
|
||||||
|
"hidden_layer_size": 10,
|
||||||
|
"activation": 0
|
||||||
|
},
|
||||||
|
"train_epochs": 100,
|
||||||
|
"seed": 0
|
||||||
|
}
|
||||||
BIN
test_policies/hail-etienne/expB/policy_seed1.pt
Normal file
BIN
test_policies/hail-etienne/expB/policy_seed1.pt
Normal file
Binary file not shown.
BIN
test_policies/hail-etienne/expB/policy_seed2.pt
Normal file
BIN
test_policies/hail-etienne/expB/policy_seed2.pt
Normal file
Binary file not shown.
BIN
test_policies/hail-etienne/expB/policy_seed3.pt
Normal file
BIN
test_policies/hail-etienne/expB/policy_seed3.pt
Normal file
Binary file not shown.
BIN
test_policies/hail-etienne/expB/policy_seed4.pt
Normal file
BIN
test_policies/hail-etienne/expB/policy_seed4.pt
Normal file
Binary file not shown.
BIN
test_policies/hail-etienne/expB/policy_seed5.pt
Normal file
BIN
test_policies/hail-etienne/expB/policy_seed5.pt
Normal file
Binary file not shown.
33
test_policies/hail/expA/config.json
Normal file
33
test_policies/hail/expA/config.json
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"experiment": "A",
|
||||||
|
"trainenv": {
|
||||||
|
"stop_on_collision": false,
|
||||||
|
"safe_actions_collision_method": null,
|
||||||
|
"abort_unsafe_collision_method": null
|
||||||
|
},
|
||||||
|
"policy": {
|
||||||
|
"learning_rate": 0.0003,
|
||||||
|
"learning_rate_decay": 1.0,
|
||||||
|
"clip_ratio": 0.2,
|
||||||
|
"iterations_per_epoch": 100,
|
||||||
|
"hidden_layer_size": 40,
|
||||||
|
"n_hidden_layers": 2,
|
||||||
|
"activation": 0,
|
||||||
|
"option": 0
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"learning_rate": 0.001,
|
||||||
|
"iterations_per_epoch": 1000
|
||||||
|
},
|
||||||
|
"discriminator": {
|
||||||
|
"learning_rate": 0.001,
|
||||||
|
"weight_decay": 0.0001,
|
||||||
|
"iterations_per_epoch": 100,
|
||||||
|
"n_hidden_layers_element": 4,
|
||||||
|
"n_hidden_layers_global": 1,
|
||||||
|
"hidden_layer_size": 10,
|
||||||
|
"activation": 0
|
||||||
|
},
|
||||||
|
"train_epochs": 90,
|
||||||
|
"seed": 0
|
||||||
|
}
|
||||||
33
test_policies/hail/expB/config.json
Normal file
33
test_policies/hail/expB/config.json
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"experiment": "B",
|
||||||
|
"trainenv": {
|
||||||
|
"stop_on_collision": false,
|
||||||
|
"safe_actions_collision_method": null,
|
||||||
|
"abort_unsafe_collision_method": null
|
||||||
|
},
|
||||||
|
"policy": {
|
||||||
|
"learning_rate": 0.0003,
|
||||||
|
"learning_rate_decay": 1.0,
|
||||||
|
"clip_ratio": 0.2,
|
||||||
|
"iterations_per_epoch": 100,
|
||||||
|
"hidden_layer_size": 20,
|
||||||
|
"n_hidden_layers": 2,
|
||||||
|
"activation": 0,
|
||||||
|
"option": 0
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"learning_rate": 0.001,
|
||||||
|
"iterations_per_epoch": 1000
|
||||||
|
},
|
||||||
|
"discriminator": {
|
||||||
|
"learning_rate": 0.001,
|
||||||
|
"weight_decay": 0.0001,
|
||||||
|
"iterations_per_epoch": 100,
|
||||||
|
"n_hidden_layers_element": 4,
|
||||||
|
"n_hidden_layers_global": 2,
|
||||||
|
"hidden_layer_size": 10,
|
||||||
|
"activation": 0
|
||||||
|
},
|
||||||
|
"train_epochs": 85,
|
||||||
|
"seed": 0
|
||||||
|
}
|
||||||
33
test_policies/shail-etienne/expA/config.json
Normal file
33
test_policies/shail-etienne/expA/config.json
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"experiment": "A",
|
||||||
|
"trainenv": {
|
||||||
|
"stop_on_collision": false,
|
||||||
|
"safe_actions_collision_method": "circle",
|
||||||
|
"abort_unsafe_collision_method": "circle"
|
||||||
|
},
|
||||||
|
"policy": {
|
||||||
|
"learning_rate": 0.0003,
|
||||||
|
"learning_rate_decay": 1.0,
|
||||||
|
"clip_ratio": 0.2,
|
||||||
|
"iterations_per_epoch": 100,
|
||||||
|
"hidden_layer_size": 20,
|
||||||
|
"n_hidden_layers": 4,
|
||||||
|
"activation": 0,
|
||||||
|
"option": 0
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"learning_rate": 0.001,
|
||||||
|
"iterations_per_epoch": 1000
|
||||||
|
},
|
||||||
|
"discriminator": {
|
||||||
|
"learning_rate": 0.001,
|
||||||
|
"weight_decay": 0.0001,
|
||||||
|
"iterations_per_epoch": 100,
|
||||||
|
"n_hidden_layers_element": 3,
|
||||||
|
"n_hidden_layers_global": 2,
|
||||||
|
"hidden_layer_size": 10,
|
||||||
|
"activation": 0
|
||||||
|
},
|
||||||
|
"train_epochs": 100,
|
||||||
|
"seed": 0
|
||||||
|
}
|
||||||
BIN
test_policies/shail-etienne/expA/policy_seed1.pt
Normal file
BIN
test_policies/shail-etienne/expA/policy_seed1.pt
Normal file
Binary file not shown.
BIN
test_policies/shail-etienne/expA/policy_seed2.pt
Normal file
BIN
test_policies/shail-etienne/expA/policy_seed2.pt
Normal file
Binary file not shown.
BIN
test_policies/shail-etienne/expA/policy_seed3.pt
Normal file
BIN
test_policies/shail-etienne/expA/policy_seed3.pt
Normal file
Binary file not shown.
BIN
test_policies/shail-etienne/expA/policy_seed4.pt
Normal file
BIN
test_policies/shail-etienne/expA/policy_seed4.pt
Normal file
Binary file not shown.
BIN
test_policies/shail-etienne/expA/policy_seed5.pt
Normal file
BIN
test_policies/shail-etienne/expA/policy_seed5.pt
Normal file
Binary file not shown.
33
test_policies/shail-etienne/expB/config.json
Normal file
33
test_policies/shail-etienne/expB/config.json
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"experiment": "B",
|
||||||
|
"trainenv": {
|
||||||
|
"stop_on_collision": false,
|
||||||
|
"safe_actions_collision_method": "circle",
|
||||||
|
"abort_unsafe_collision_method": "circle"
|
||||||
|
},
|
||||||
|
"policy": {
|
||||||
|
"learning_rate": 0.0003,
|
||||||
|
"learning_rate_decay": 1.0,
|
||||||
|
"clip_ratio": 0.2,
|
||||||
|
"iterations_per_epoch": 100,
|
||||||
|
"hidden_layer_size": 20,
|
||||||
|
"n_hidden_layers": 4,
|
||||||
|
"activation": 0,
|
||||||
|
"option": 0
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"learning_rate": 0.001,
|
||||||
|
"iterations_per_epoch": 1000
|
||||||
|
},
|
||||||
|
"discriminator": {
|
||||||
|
"learning_rate": 0.001,
|
||||||
|
"weight_decay": 0.0001,
|
||||||
|
"iterations_per_epoch": 100,
|
||||||
|
"n_hidden_layers_element": 3,
|
||||||
|
"n_hidden_layers_global": 2,
|
||||||
|
"hidden_layer_size": 10,
|
||||||
|
"activation": 0
|
||||||
|
},
|
||||||
|
"train_epochs": 100,
|
||||||
|
"seed": 0
|
||||||
|
}
|
||||||
BIN
test_policies/shail-etienne/expB/policy_seed1.pt
Normal file
BIN
test_policies/shail-etienne/expB/policy_seed1.pt
Normal file
Binary file not shown.
BIN
test_policies/shail-etienne/expB/policy_seed2.pt
Normal file
BIN
test_policies/shail-etienne/expB/policy_seed2.pt
Normal file
Binary file not shown.
BIN
test_policies/shail-etienne/expB/policy_seed3.pt
Normal file
BIN
test_policies/shail-etienne/expB/policy_seed3.pt
Normal file
Binary file not shown.
BIN
test_policies/shail-etienne/expB/policy_seed4.pt
Normal file
BIN
test_policies/shail-etienne/expB/policy_seed4.pt
Normal file
Binary file not shown.
BIN
test_policies/shail-etienne/expB/policy_seed5.pt
Normal file
BIN
test_policies/shail-etienne/expB/policy_seed5.pt
Normal file
Binary file not shown.
33
test_policies/shail/expA/config.json
Normal file
33
test_policies/shail/expA/config.json
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"experiment": "A",
|
||||||
|
"trainenv": {
|
||||||
|
"stop_on_collision": false,
|
||||||
|
"safe_actions_collision_method": "circle",
|
||||||
|
"abort_unsafe_collision_method": "circle"
|
||||||
|
},
|
||||||
|
"policy": {
|
||||||
|
"learning_rate": 0.0003,
|
||||||
|
"learning_rate_decay": 1.0,
|
||||||
|
"clip_ratio": 0.2,
|
||||||
|
"iterations_per_epoch": 100,
|
||||||
|
"hidden_layer_size": 40,
|
||||||
|
"n_hidden_layers": 2,
|
||||||
|
"activation": 0,
|
||||||
|
"option": 0
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"learning_rate": 0.001,
|
||||||
|
"iterations_per_epoch": 1000
|
||||||
|
},
|
||||||
|
"discriminator": {
|
||||||
|
"learning_rate": 0.001,
|
||||||
|
"weight_decay": 0.0001,
|
||||||
|
"iterations_per_epoch": 100,
|
||||||
|
"n_hidden_layers_element": 4,
|
||||||
|
"n_hidden_layers_global": 1,
|
||||||
|
"hidden_layer_size": 10,
|
||||||
|
"activation": 0
|
||||||
|
},
|
||||||
|
"train_epochs": 90,
|
||||||
|
"seed": 0
|
||||||
|
}
|
||||||
33
test_policies/shail/expB/config.json
Normal file
33
test_policies/shail/expB/config.json
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"experiment": "B",
|
||||||
|
"trainenv": {
|
||||||
|
"stop_on_collision": false,
|
||||||
|
"safe_actions_collision_method": "circle",
|
||||||
|
"abort_unsafe_collision_method": "circle"
|
||||||
|
},
|
||||||
|
"policy": {
|
||||||
|
"learning_rate": 0.0003,
|
||||||
|
"learning_rate_decay": 1.0,
|
||||||
|
"clip_ratio": 0.2,
|
||||||
|
"iterations_per_epoch": 100,
|
||||||
|
"hidden_layer_size": 20,
|
||||||
|
"n_hidden_layers": 2,
|
||||||
|
"activation": 0,
|
||||||
|
"option": 0
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"learning_rate": 0.001,
|
||||||
|
"iterations_per_epoch": 1000
|
||||||
|
},
|
||||||
|
"discriminator": {
|
||||||
|
"learning_rate": 0.001,
|
||||||
|
"weight_decay": 0.0001,
|
||||||
|
"iterations_per_epoch": 100,
|
||||||
|
"n_hidden_layers_element": 4,
|
||||||
|
"n_hidden_layers_global": 2,
|
||||||
|
"hidden_layer_size": 10,
|
||||||
|
"activation": 0
|
||||||
|
},
|
||||||
|
"train_epochs": 85,
|
||||||
|
"seed": 0
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user