# Deep Multi-agent Reinforcement Learning for Highway On-Ramp Merging in Mixed Traffic

Dong Chen, Mohammad Hajidavalloo, Zhaojian Li, Kaian Chen, Yongqiang Wang, Longsheng Jiang and 1 more · arXiv · 2021-5-12

- **Problem** Merging AVs into traffic that includes human-driven vehicles needs coordination that rule-based and model predictive control methods handle poorly.
- **Method** Trains a decentralized actor-critic policy with parameter sharing, neighborhood-averaged rewards and action masking, then adds a sequential priority-based safety supervisor and curriculum training for the Hard mode.
- **Results** In testing, the supervised configuration reached a collision rate of 0 in all three traffic modes at Tn = 8, while the baseline reached 0.07 in Medium and 0.16 in Hard mode.

![Figure 2: Schematics of system and simulation setup](https://refivu.com/papers/5a4426df-329c-4335-a2f9-61fd8bab85a2/figures/figure-4960c242783a34a2365d395b28df36d0.png?thumb=512)

**Figure 2** : Schematics of system and simulation setup.

[Original paper](https://arxiv.org/abs/2105.05701v3) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Dong Chen, Mohammad Hajidavalloo, Zhaojian Li, Kaian Chen, Yongqiang Wang, Longsheng Jiang, Yue Wang · Deep Multi-agent Reinforcement Learning for Highway On-Ramp Merging in Mixed Traffic · Original paper figure · Extracted the figure area from page 3 of the original PDF.

## Why merging in mixed traffic is hard

Highway on-ramp merging is among the harder driving tasks for autonomous vehicles, and it becomes harder when human-driven vehicles share the road. The authors link a rising number of AV accidents to AVs that react too slowly to the road objects and to the behavior of human drivers. The merge is a coordination problem: ramp vehicles must enter the through lane without a collision, while through-lane vehicles must make room, otherwise the two groups can deadlock.

Rule-based methods use hand-written heuristics, which work for simple traffic but become impractical in more complex merges. Model predictive control treats vehicle interaction explicitly, but it needs accurate models of human driving and an online optimization at every time step. The surveys of model-based merging control assume fully automated vehicles, so they do not address mixed traffic.

Reinforcement learning has been applied to AV merging, but the single-agent approaches treat every other vehicle as part of the environment. The authors know of no MARL algorithm for this on-ramp merging setting, so they extend the single-agent view to several cooperating AVs. Dynamic connectivity, coupled AV motion and the decisions of human drivers make this extension hard.

## Merging as a decentralized POMDP

The merge is modeled as a partially observable Markov decision process in which each AV is an agent that sees only part of the environment, namely nearby vehicles. Agents are linked through a graph whose edges define neighbors, and the connectivity may change over time, so the formulation can cover a dynamic topology.

Each AV chooses one of five high-level decisions: turn left, turn right, cruising, speed up or slow down. Lower-level controllers turn the chosen decision into steering and throttle signals, and the system setup is shown in a schematic. An agent's observation is a matrix with one row per observed vehicle and five features: a presence flag, longitudinal and lateral position, and longitudinal and lateral speed, all relative to the ego vehicle.

Only the nearest five vehicles within 150 m longitudinal distance are included, and five gave the best result in the on-ramp case.

Each agent's reward is a weighted sum of a collision term, a speed term, a time headway term and a merging cost term: \\\\( r\_{i,t}=w\_c r\_c+w\_s r\_s+w\_h r\_h+w\_m r\_m \\\\). The collision term is -1 when a collision happens and 0 otherwise, and its weight is the largest so that safety dominates. The speed term is \\\\( r\_s=\\\\min\\\\{(v\_t-v\_{min})/(v\_{max}-v\_{min}),1\\\\} \\\\), with v\_min = 10 m/s and v\_max = 30 m/s.

The time headway term is \\\\( r\_h=\\\\log(d\_{headway}/(t\_h v\_t)) \\\\) with t\_h = 1.2 s, so the ego vehicle is penalized when its headway falls below the threshold. The merging cost is \\\\( r\_m=-\\\\exp(-(x-L)^2/(10L)) \\\\), where x is the distance driven on the ramp and L is the ramp length; the penalty grows as the vehicle nears the merge end.

The simulator defines the transitions: HDV accelerations come from IDM, HDV lane changes from MOBIL, and AV trajectories from a kinematic bicycle model. The learner is given no prior knowledge of these transition probabilities.

## Local rewards and a shared policy

A single global reward is slow to aggregate, adds communication load, and blurs each vehicle's contribution, which the authors describe as a credit assignment problem. Each agent instead receives \\\\( r\_{i,t}=\\\\frac{1}{\|\\\\nu\_i\|}\\\\sum\_{j\\\\in\\\\nu\_i} r\_{j,t} \\\\), where \\\\( \\\\nu\_i = i \\\\cup \\\\mathcal{N}\_i \\\\) is the agent together with its neighbors.

Because a vehicle mainly interacts with its surrounding vehicles, the authors treat distant vehicles as having limited effect on it.

The actor and the critic share low-level layers, so the policy loss and the value error are combined into one objective: \\\\( J(\\\\theta\_i)=J\_{\\\\pi\_{\\\\theta\_i}}-\\\\beta\_1 J\_{V\_{\\\\phi\_i}}+\\\\beta\_2 H(\\\\pi\_{\\\\theta\_i}(s\_t)) \\\\). Here H is the expected negative log-probability of the policy, which encourages exploration, while beta\_1 weights the value loss and beta\_2 weights the entropy term.

The policy term uses the advantage \\\\( A\_{i,t}=r\_{i,t}+\\\\gamma V(s\_{i,t+1})-V(s\_{i,t}) \\\\), and the value loss is the squared one-step error of this target.

All AVs on both lanes use one policy network with the same parameters, which lets the model handle a changing number of agents. Each agent keeps a separate experience buffer, and minibatches of sampled trajectories are used to reduce the variance of the update. The parameters are updated after each episode using the stored experience.

## Observation encoding and action masking

The observation is split by physical unit into presence, position and speed groups, and each group passes through its own fully connected layer. The three encoded groups are concatenated and fed into a 128-neuron fully connected layer, whose output is used by both the actor and the critic. The actor produces five logits, and a softmax turns them into action probabilities.

A plain softmax still gives invalid actions non-zero probability, so they can be sampled, and their experience then misleads the policy update. The fix sets the logits of invalid actions to large negative values, such as -1e8, so their probability after the softmax is close to zero and the valid actions are sampled instead.

Two kinds of invalid action are masked: a lane change to a lane that does not exist, and a speed-up or slow-down when the speed limit is already reached. Masking covers only these two rule-based cases, and other unsafe actions are left to the safety supervisor.

## Sequential priority-based safety check

Checking every joint action would mean searching a space of size \|A\_i\| raised to the power N for N AVs, which quickly becomes intractable. The supervisor therefore handles the AVs one at a time in priority order, placing merge-lane vehicles first, then those closer to the merge end, and then those with smaller time headway.

For the AV at the head of the list, the supervisor predicts its trajectory and those of its neighbors over Tn steps, using IDM for HDV longitudinal motion and MOBIL for HDV lane changes. AVs not yet processed are assumed to repeat their last action in this prediction. A conflict is flagged when any two predicted trajectories come closer than a set threshold at any step k.

No collisions among HDVs are assumed, which the authors justify by the safety focus of IDM and MOBIL.

When the exploratory action conflicts, the supervisor evaluates the valid alternatives and keeps the one with the largest minimum safety margin over the horizon: \\\\( a'\_t=\\\\arg\\\\max\_{a\_t\\\\in A\_{valid}}\\\\left(\\\\min\_{k\\\\in T\_n} d\_{sm,k}\\\\right) \\\\). After a decision, the AV's trajectory is regenerated, and the vehicles checked later are predicted with the already verified actions of higher-priority vehicles.

The authors propose running the check at a roadside infrastructure station through vehicle-to-infrastructure communication. With Tn = 8 in the Hard mode, one decision took approximately 28.13 ms, and the authors expect the check to run within one sampling step.

The horizon Tn trades off two errors: if it is too short, the supervisor can find no feasible action after a few steps; if it is too long, HDV model uncertainty accumulates and the policy becomes conservative. The authors choose Tn = 8 or 9 by cross-validation.

## Simulation and training configuration

The road is 520 m long, the merge lane entrance is at 320 m, and the merge lane length L is 100 m. Twelve spawn points are distributed between 0 m and 220 m on the through lane and the ramp. Easy mode has 1-3 AVs and 1-3 HDVs, Medium mode 2-4 AVs and 2-4 HDVs, and Hard mode 4-6 AVs and 3-5 HDVs.

Each episode draws vehicles onto the spawn points with uniform position noise between -1.5 m and 1.5 m, and initial speeds between 25 and 27 m/s.

Training runs for 2 million steps with three random seeds, about 20,000 episodes with a horizon of 100 steps, and evaluation runs over 3 episodes every 200 training episodes. The loss weights are beta\_1 = 1 and beta\_2 = 0.01, and the priority coefficients alpha\_1, alpha\_2 and alpha\_3 are each set to 1. The baseline is the MARL algorithm without the safety supervisor, and the simulator is modified from highway-env and open-sourced.

## Local reward and the safety weight

The local reward is compared with a global reward in which each agent receives the average of all agents' rewards. Across the Easy, Medium and Hard modes the local reward gives higher evaluation reward and converges faster. The global reward is reasonable in Easy and Medium, but in Hard mode its evaluation reward falls below 0.

The authors attribute the Hard-mode failure to credit assignment, and to the average global reward correlating less with each agent's actions as the number of agents grows. The evaluation curves average over 3 random seeds, with the standard deviation shaded.

Table I varies wc in the Medium mode while the other weights stay fixed. Collision rate is 0.1 at wc = 10 and 0 at wc = 100, 200, 1000 and 10000. Average speed is 24.77 at wc = 10 and then 24.09, 24.08, 23.69 and 23.62 at wc = 100, 200, 1000 and 10000. The authors chose wc = 200 as a trade-off between safety margin and traffic efficiency, and they attribute the speed drop to AVs behaving more conservatively.

## Curriculum training for the Hard mode

Hard-mode training starts from models trained on the Easy and Medium modes instead of from scratch. The authors argue that starting from a reasonable model avoids many random and risky explorations in dense traffic.

Training returns in Hard mode converge faster and reach a higher final performance with curriculum learning than when training from scratch. During training, average speed reaches up to 22 m/s with curriculum learning, against 18 m/s for the baseline.

These speeds are averages taken during training, so they describe learning progress rather than a separate test run.

## Collision rate and speed with the supervisor

With the supervisor, training shows better sample efficiency and higher evaluation reward, including in the Hard mode, which the authors link to unsafe actions being replaced early in training. Training speeds stay higher with the supervisor than without it, which the authors read as better traffic efficiency. Training speeds fall as density rises, to about 26 m/s, 24 m/s and 22 m/s for Easy, Medium and Hard.

In testing, the baseline records a collision rate of 0 in Easy, 0.07 in Medium and 0.16 in Hard mode.

Table II lists collision rate, average speed and inference time for the baseline and for the n-step supervisor variants in all three modes.

## Comparison with MARL and MPC benchmarks

The proposed configuration, baseline with Tn = 8, is compared with MAA2C, MAACKTR, MAPPO and an improved MPC. The MARL benchmarks share parameters across agents but use the global reward and a discrete action space, so the comparison mixes the learning algorithm with the reward design. Testing runs over 3 random seeds for 30 epochs in each traffic density.

The training curves show the proposed policy ahead of the benchmarks in all modes, and the authors report the largest advantage in Hard mode. Its training speeds are relatively high, while MAPPO reaches high speed in dense traffic, which the authors expect to cause high collision rates.

In Table III the proposed method has a collision rate of 0 in all three modes, while MPC has 0.03, 0.03 and 0.40 in Easy, Medium and Hard. MAA2C has 0.02, 0.08 and 0.52, MAACKTR 0.08, 0.12 and 0.18, and MAPPO 0, 0.02 and 0.34. The proposed method has the highest average speed in each mode, though MAPPO is close in Easy and Medium with 25.70 and 24.00 m/s.

The authors attribute the high collision rates of MAPPO in dense traffic to its high vehicle speed. In Hard mode, however, MAPPO's average speed is 22.41 m/s, below the proposed 22.73 m/s, while its collision rate is 0.34, so speed alone does not explain that gap. For MPC the authors point to the mismatch between the controller's model and the simulator dynamics, together with the uncertainty injected in the simulator.

The authors argue that MPC must solve a nonlinear program at each step and so needs much more onboard computation than their RL policy, but no MPC runtime is reported to check this.

## What the learned policy does in one merge

Figure 15 shows three snapshots, at steps 25, 37 and 50, together with the speeds of agents 2 to 4. At step 25 agent 2 slows down to open a gap for agent 3, which accelerates to merge while keeping headway to agent 1.

Agent 3 completes the merge and speeds up at step 37, while agent 2 keeps a low speed to maintain headway to it. At step 50 agent 2 speeds up but stays slower than agent 3, and the authors note a similar pattern for agent 4. This is a single scene used for interpretation, not a measured result.

## Extension to multiple through lanes

For the multi-lane case the reward gains a lane-changing term: \\\\( r\_{i,t}=w\_c r\_c+w\_s r\_s+w\_h r\_h+w\_m r\_m+w\_l r\_l \\\\). The term \\\\( r\_l \\\\) is -1 when the AV changes lanes and 0 otherwise, which penalizes unnecessary and frequent lane changes, following a design from prior work.

The training curves for the n-step supervisor on this road are reported as showing good performance, which the authors take as evidence that the approach extends to several through lanes. No other benchmark is compared in the multi-lane case.

## Limits of the evidence

The traffic is simulated: MOBIL does not know where the merge ends, so HDVs can incur unexpected delays on the ramp. The authors state that sim-to-real transfer and real-traffic validation remain future work.

The safety check assumes no collisions among HDVs, and the authors justify this by IDM and MOBIL being safety-focused rather than by a separate test. The benchmark comparison mixes reward design with the learning algorithm, and the MPC model differs from the simulator.

The reported experiments vary the reward design, wc, curriculum learning and Tn, but the units do not report a run that removes action masking or parameter sharing alone. Test statistics come from 3 random seeds and 30 epochs per traffic density. The multi-lane case has no comparison with other benchmarks.

## Paper info

- **Authors**: Dong Chen, Mohammad Hajidavalloo, Zhaojian Li, Kaian Chen, Yongqiang Wang, Longsheng Jiang, Yue Wang
- **Venue**: arXiv · Preprint
- **First published**: 2021-5-12
- **Added**: 2026-11-6
- **Updated**: 2022-11-5
- **Version**: v3
- **arXiv**: 2105.05701
- **Category**: eess.SY
- **Original paper terms**: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
- **What we show**: Paper info, commentary and permitted figures from the original paper

[Original paper ↗](https://arxiv.org/abs/2105.05701v3) · [PDF ↗](https://arxiv.org/pdf/2105.05701v3)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Abstract

On-ramp merging is a challenging task for autonomous vehicles (AVs), especially in mixed traffic where AVs coexist with human-driven vehicles (HDVs). In this paper, we formulate the mixed-traffic highway on-ramp merging problem as a multi-agent reinforcement learning (MARL) problem, where the AVs (on both merge lane and through lane) collaboratively learn a policy to adapt to HDVs to maximize the traffic throughput. We develop an efficient and scalable MARL framework that can be used in dynamic traffic where the communication topology could be time-varying. Parameter sharing and local rewards are exploited to foster inter-agent cooperation while achieving great scalability. An action masking scheme is employed to improve learning efficiency by filtering out invalid/unsafe actions at each step. In addition, a novel priority-based safety supervisor is developed to significantly reduce collision rate and greatly expedite the training process. A gym-like simulation environment is developed and open-sourced with three different levels of traffic densities. We exploit curriculum learning to efficiently learn harder tasks from trained models under simpler settings. Comprehensive experimental results show the proposed MARL framework consistently outperforms several state-of-the-art benchmarks.

## Quote from the paper

Dong Chen, Mohammad Hajidavalloo, Zhaojian Li, Kaian Chen, Yongqiang Wang, Longsheng Jiang, Yue Wang (2021). Deep Multi-agent Reinforcement Learning for Highway On-Ramp Merging in Mixed Traffic. arXiv:2105.05701v3. https://arxiv.org/abs/2105.05701v3

**BibTeX**

```
@misc{chen2021deep,
  title = {{Deep Multi-agent Reinforcement Learning for Highway On-Ramp Merging in Mixed Traffic}},
  author = {Dong Chen and Mohammad Hajidavalloo and Zhaojian Li and Kaian Chen and Yongqiang Wang and Longsheng Jiang and Yue Wang},
  year = {2021},
  eprint = {2105.05701},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2105.05701v3}
}
```

## Other paper commentary

- [Reflexion: Language Agents with Verbal Reinforcement Learning](https://refivu.com/en/papers/a572f458-b121-4d38-bfc9-7a77309a3aba-reflexion-language-agents-with-verbal-reinforcement-learning.md)
- [A Generalist Agent](https://refivu.com/en/papers/890475cb-e797-43df-8de3-0d0eb9ed882e-a-generalist-agent.md)
- [Implicit Intelligence - Evaluating Agents on What Users Don’t Say](https://refivu.com/en/papers/46a3027e-e7cd-4c3e-be85-2fe588fd1675-implicit-intelligence-evaluating-agents-on-what-users-don.md)
- [Escaping Whack-a-Mole: Optimizing Documentation as Repo-Specific Playbooks for Coding Agents](https://refivu.com/en/papers/52e2d558-711f-4753-af6e-c88268527a9b-escaping-whack-a-mole-optimizing-documentation-as-repo.md)
- [VeriLadder: A Multi-Agent Specification Refinement System for Tool-Verified Verilog Datasets](https://refivu.com/en/papers/f3a3ce4f-fd41-462e-8bb7-f3e5263ba827-veriladder-a-multi-agent-specification-refinement-system-for.md)
- [AutoPILOT: A Visual Agent Harness for Real-Time Gameplay](https://refivu.com/en/papers/610b7c6f-2c3b-4308-bb50-b139b48fceb7-autopilot-a-visual-agent-harness-for-real-time.md)
- [SuperSpike: Supervised learning in multi-layer spiking neural networks](https://refivu.com/en/papers/69e65b6b-2815-4179-aaac-1c5294019aba-superspike-supervised-learning-in-multi-layer-spiking-neural.md)
- [Deep Reinforcement Learning Based Intelligent Reflecting Surface for Secure Wireless Communications](https://refivu.com/en/papers/7f104da3-3d98-4ecd-95d9-a25944d61e36-deep-reinforcement-learning-based-intelligent-reflecting.md)
- [Self-supervised Learning for Human Activity Recognition Using 700,000 Person-days of Wearable Data](https://refivu.com/en/papers/7d06c47d-a111-423f-a4f8-68d244e1093c-self-supervised-learning-for-human-activity-recognition.md)
- [A Generalized Deep Learning Framework for Whole-Slide Image Segmentation and Analysis](https://refivu.com/en/papers/17229723-709e-4a8a-9857-8cd6f0d14883-a-generalized-deep-learning-framework-for-whole-slide.md)
- [Attention Spiking Neural Networks](https://refivu.com/en/papers/2c52d99c-a249-4911-96bd-79f6720c0a09-attention-spiking-neural-networks.md)
- [Uncovering near-wall blood flow from sparse data with physics-informed neural networks](https://refivu.com/en/papers/5532e81a-0a00-4722-b226-e72f33cb333a-uncovering-near-wall-blood-flow-from-sparse-data.md)

## Terms in this paper

- [reinforcement learning](https://refivu.com/en/terms/6c51042515d2-reinforcement-learning)
- [curriculum learning](https://refivu.com/en/terms/b6ef6666624f-curriculum-learning)
- [Actor-Critic](https://refivu.com/en/terms/080ed1efed92-actor-critic)
- [POMDP](https://refivu.com/en/terms/1c9c6e27aaa2-pomdp)
- [partially observable Markov decision process](https://refivu.com/en/terms/4e32d4575cd4-partially-observable-markov-decision-process)
- [MAPPO](https://refivu.com/en/terms/04d293a5c68c-mappo)
- [model predictive control](https://refivu.com/en/terms/938ebb77f1ac-model-predictive-control)
- [parameter sharing](https://refivu.com/en/terms/a678bc1aadfb-parameter-sharing)
- [collision rate](https://refivu.com/en/terms/767e1cc13a56-collision-rate)
- [Multi-agent Reinforcement Learning](https://refivu.com/en/terms/fb832f1a34ec-multi-agent-reinforcement-learning)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/5a4426df-329c-4335-a2f9-61fd8bab85a2-deep-multi-agent-reinforcement-learning-for-highway-on)
