Merge¶
In this task, the ego-vehicle starts on a main highway but soon approaches a road junction with incoming vehicles on the access ramp. The agent’s objective is now to maintain a high speed while making room for the vehicles so that they can safely merge in the traffic.
Usage¶
env = gym.make("merge-v0")
Default configuration¶
{
"observation": {
"type": "TimeToCollision"
},
"action": {
"type": "DiscreteMetaAction"
},
"simulation_frequency": 15, # [Hz]
"policy_frequency": 1, # [Hz]
"other_vehicles_type": "highway_env.vehicle.behavior.IDMVehicle",
"screen_width": 600, # [px]
"screen_height": 150, # [px]
"centering_position": [0.3, 0.5],
"scaling": 5.5,
"show_trajectories": False,
"render_agent": True,
"offscreen_rendering": False
}
More specifically, it is defined in:
-
classmethod
MergeEnv.
default_config
() → dict¶ Default environment configuration.
Can be overloaded in environment implementations, or by calling configure(). :return: a configuration dict
API¶
-
class
highway_env.envs.merge_env.
MergeEnv
(config: dict = None)[source]¶ A highway merge negotiation environment.
The ego-vehicle is driving on a highway and approached a merge, with some vehicles incoming on the access ramp. It is rewarded for maintaining a high speed and avoiding collisions, but also making room for merging vehicles.
-
COLLISION_REWARD
: float = -1¶
-
RIGHT_LANE_REWARD
: float = 0.1¶
-
HIGH_SPEED_REWARD
: float = 0.2¶
-
MERGING_SPEED_REWARD
: float = -0.5¶
-
LANE_CHANGE_REWARD
: float = -0.05¶
-
_reward
(action: int) → float[source]¶ The vehicle is rewarded for driving with high speed on lanes to the right and avoiding collisions
But an additional altruistic penalty is also suffered if any vehicle on the merging lane has a low speed.
- Parameters
action – the action performed
- Returns
the reward of the state-action transition
-
_is_terminal
() → bool[source]¶ The episode is over when a collision occurs or when the access ramp has been passed.
-
reset
() → numpy.ndarray[source]¶ Reset the environment to it’s initial configuration
- Returns
the observation of the reset state
-
_make_road
() → None[source]¶ Make a road composed of a straight highway and a merging lane.
- Returns
the road
-
_make_vehicles
() → None[source]¶ Populate a road with several vehicles on the highway and on the merging lane, as well as an ego-vehicle.
- Returns
the ego-vehicle
-
__annotations__
= {'COLLISION_REWARD': <class 'float'>, 'HIGH_SPEED_REWARD': <class 'float'>, 'LANE_CHANGE_REWARD': <class 'float'>, 'MERGING_SPEED_REWARD': <class 'float'>, 'RIGHT_LANE_REWARD': <class 'float'>}¶
-
__module__
= 'highway_env.envs.merge_env'¶
-