Commit 074d2f49 by Jaeyoung Lee

Successful high-level policy (6-hidden layers, 1m training).

- Also added ManualWait class.
parent 7a4ea75b
......@@ -270,17 +270,17 @@ class DQNLearner(LearnerBase):
Returns: Keras Model object of actor
"""
model = Sequential()
model.add(Flatten(input_shape=(1, ) + self.input_shape))
model.add(Dense(64))
model.add(Activation('relu'))
model.add(Dense(64))
model.add(Activation('relu'))
model.add(Dense(64))
model.add(Activation('relu'))
model.add(Dense(64, activation='relu'))
model.add(Dense(64, activation='relu'))
model.add(Dense(64, activation='relu'))
model.add(Dense(64, activation='relu'))
model.add(Dense(64, activation='relu'))
model.add(Dense(64, activation='tanh'))
model.add(Dense(self.nb_actions))
model.add(Activation('linear'))
# print(model.summary())
print(model.summary())
return model
......@@ -555,4 +555,4 @@ class DQNAgentOverOptions(DQNAgent):
for node_index in invalid_node_indices:
q_values[node_index] = -np.inf
return q_values
\ No newline at end of file
return q_values
......@@ -50,13 +50,16 @@ class KeepLane(ManeuverBase):
@staticmethod
def _features_dim_reduction(features_tuple):
return extract_ego_features(features_tuple, 'v', 'v_ref', 'e_y', 'psi', 'v tan(psi/L)', 'theta', 'lane', 'acc', 'psi_dot')
return extract_ego_features(features_tuple, 'v', 'v_ref', 'e_y',
'psi', 'v tan(psi/L)', 'theta', 'lane',
'acc', 'psi_dot')
@property
def initiation_condition(self):
"""a virtual function (property) from ManeuverBase.
As KeepLane is a default maneuver, it has to be activated to be chosen at any time, state, and condition
(refer to initiation_condition of ManeuverBase for the usual case.
As KeepLane is a default maneuver, it has to be activated to be
chosen at any time, state, and condition (refer to
initiation_condition of ManeuverBase for the usual case).
:returns True.
"""
......@@ -320,6 +323,31 @@ class Wait(ManeuverBase):
'pos_stop_region', 'intersection_is_clear', 'highest_priority')
class ManualWait(ManeuverBase):
_reward_in_goal = None
_terminate_in_goal = True
def _init_LTL_preconditions(self):
self._LTL_preconditions.append(
LTLProperty("G ( (in_stop_region and stopped_now) and not (highest_priority and intersection_is_clear))",
None, not self._enable_low_level_training_properties)) # not available in low-level training...
self._LTL_preconditions.append(
LTLProperty("G ( in_stop_region U (highest_priority and intersection_is_clear) )",
150, self._enable_low_level_training_properties))
self._LTL_preconditions.append(
LTLProperty("G ( (lane and target_lane) or (not lane and not target_lane) )",
100, self._enable_low_level_training_properties))
def _init_param(self):
self._v_ref = 0
self._target_lane = self.env.ego.APs['lane']
def _low_level_manual_policy(self):
return (0, 0) # Do nothing during "Wait" but just wait until the highest priority is given.
class Left(ManeuverBase):
min_y_distance = rd.hlanes.width / 4
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment