Manuscript Offprint
arXiv:2610.34163Reinforcement Learning for Adaptive Crowd Flow Control Using Dynamic Barriers
Abstract
Crowd barriers are widely used to regulate pedestrian movement during large public events such as pilgrimages. However, fixed barrier layouts often create unnecessary stopping and local congestion even when they successfully control the overall crowd flow. Finding better barrier configurations is difficult because there is no dataset that provides the best barrier placement for a given crowd scene. We address this challenge by introducing a simulation-driven reinforcement learning framework that learns barrier configurations without requiring labelled training data. Starting from a segmented crowd scene, we construct a realistic simulation environment that reproduces the observed pedestrian distribution. This environment is then used to train a Soft Actor-Critic (SAC) agent that continuously adjusts barrier positions to improve pedestrian movement. Unlike supervised approaches, the proposed framework allows the agent to explore barrier configurations that have never been observed in real data. We evaluate the learned policy under unseen numbers of pedestrians. The learned policy consistently outperforms the existing manually designed barrier configuration by reducing pedestrian stops while maintaining effective flow regulation. These results demonstrate that combining computer vision, crowd simulation, and reinforcement learning provides an effective framework for optimizing crowd control infrastructure. The source code is available on GitHub: https://github.com/HanoCat/RLForHajjProject
Keywords: crowd simulation; reinforcement learning; Soft Actor-Critic; barrier optimisation; pedestrian flow; crowd management.
1 Introduction
Crowd barriers are commonly used to regulate pedestrian movement in dense public spaces. However, manually designed layouts can create unnecessary stopping behaviour and local congestion. This is especially problematic when barriers are intended to regulate the overall crowd flow.
while avoiding inefficient movement locally. Existing crowd simulation methods mainly focus on modelling pedestrian behaviour or providing interactive tools for manually designing crowd control layouts rather than learning barrier configurations automatically (Montana Gonzalez and Maddock, 2021; Charalambous et al., 2023). Reinforcement learning has also been applied to crowd simulation and evacuation planning by learning pedestrian behaviours or tuning simulation parameters (Zhao and Geraerts, 2022; Zhang et al., 2024). However, learning how to optimize physical barrier configurations from an observed crowd scene has less attention.
We propose a simulation-driven framework for adaptive crowd barrier control. Starting from a segmented crowd image, we construct a pedestrian simulation that reproduces the observed crowd distribution. This simulation serves as the environment for Soft Actor-Critic (SAC) that learns continuous barrier configurations. The reward encourages smooth pedestrian movement by reducing stopping behaviour and local congestion while preserving the intended flow regulation of the barriers. Unlike supervised learning, our framework does not require labelled examples of optimal barrier placements and allows exploration beyond manually designed layouts. Experiments demonstrate that the learned policy consistently outperforms the existing ground-truth configuration and generalizes to unseen crowd sizes.
(a) Simulation Environment Construction

CVAT
Segmentation
Geometry
Extraction

JuPedSim Environment

Frame
P2PNET
Head
Detection

Crowd Initial and Goal Positions
(b) Learning Barrier Configurations

Simulated Scenario
Figure 1: Overview of the approach. (a) CVAT annotations and P2PNet pedestrian detections are used to construct a JuPedSim simulation. (b) A reinforcement learning policy adjusts barriers and receives feedback from the simulated crowd.
which consists of two main stages. First, we annotate a crowd image to identify the walkable regions, obstacles, and barrier locations using CVAT (Sekachev et al., 2019). The extracted geometry is converted into a JuPedSim simulation environment (Chraibi and Zhang, 2016). Pedestrian head locations are detected using P2PNet (Song et al., 2021) and each pedestrian is assigned an initial position and a destination according to the segmented scene. This process produces a realistic simulation that preserves the observed crowd distribution while allowing different barrier configurations to be evaluated. Unlike collecting real barrier-control data, the simulation provides unlimited interactions for reinforcement learning.
Second, we train a Soft Actor-Critic (SAC) agent in the constructed simulation. At time step t, the state contains the number of pedestrians , the barrier configuration , and the pedestrian state :
Here, is a pedestrian's position and is their speed. The action adjusts the translation and rotation of each barrier pair. The reward penalises stopping and slow movement:
In this expression, is the proportion of stopped pedestrians, is the mean pedestrian speed, and is the desired maximum walking speed. Lower stopping and higher walking speeds lead to a better reward.
3 Results and Discussion
Figure 2 shows the training curves. The critic losses decrease during training, while the actor loss gradually stabilises. These curves describe optimisation behaviour; the comparison against other barrier configurations provides the main evidence of performance. We compare the learned policy with the original ground-truth (GT) barriers, all-open barriers, and all-closed barriers. The all-open configuration allows pedestrians to move with fewer restrictions, giving the highest throughput and lowest stopping ratio overall. However, removing every barrier would not meet the intended purpose of regulating crowd movement. The all-closed configuration creates substantial congestion. The learned policy provides a compromise between the original layout and the two extreme settings. As Table 1 shows, it improves throughput and mean normalised speed while reducing the stopped-pedestrian ratio relative to GT. The all-open baseline still achieves better flow metrics, so the learned policy should not be described as the best-performing configuration on every measure. Figure 4 provides the results for individual crowd sizes. These results include
Table 1: Performance across evaluation scenarios (mean standard deviation). Higher throughput and speed are preferable; a lower stopped ratio is preferable.
| Configuration | Stopped ratio | Normalised speed | Throughput (agents/s) |
|---|---|---|---|
| GT | |||
| All open | |||
| All closed | |||
| RL (ours) |
crowd sizes not seen during training. They suggest that the policy can transfer to different crowd sizes in the tested simulation, although broader testing would be needed to establish generalisation to other physical scenes.
4 Conclusions
We presented a simulation-driven method for learning barrier configurations without labelled examples of optimal layouts. The approach builds a crowd simulation from an observed scene and trains a SAC agent to adjust barriers based on simulated pedestrian movement. Relative to the original GT layout, the learned policy increased throughput from 4.604 to 5.098 agents/s (10.73%), increased normalised speed from 0.887 to 0.942 (6.20%), and reduced the stopped ratio from 0.104 to 0.072 (30.77%). The results support the potential of reinforcement learning to improve pedestrian movement while retaining barriers for crowd regulation. These findings are based on the tested simulated environment and do not yet establish real-world performance.

Figure 2: SAC training curves. The top plot shows actor loss; the bottom plot shows losses of the two critics. Faint lines show raw values and solid lines show smoothed trends.

Figure 3: Qualitative comparison of barrier configurations for 10, 300, and 1,500 pedestrians. The policy was trained on crowd sizes from 100 to 700; the 10- and 1,500-pedestrian cases are outside this training range. Colour indicates pedestrian speed.
(a) Remaining agents vs crowd size

(b) Reward vs crowd size
(c) Stopped ratio vs crowd size

(d) Throughput vs crowd size
Number of Agents
Figure 4: Comparison by crowd size: (a) remaining pedestrians at the end of the simulation, (b) reward, (c) stopped ratio, and (d) throughput.
5 Future Work
- Improve scene calibration using known corridor widths, barrier dimensions, or site maps to convert image pixels into real-world distances.
• Investigate faster simulation engines to reduce training cost.
• Explore more sample-efficient reinforcement learning methods.
• Test additional crowd scenes and live observations before considering real-world deployment.
References
Panayiotis Charalambous, Julien Pettré, Vassilis Vassiliades, Yiorgos Chrysanthou, and Nuria Pelechano. GREIL-Crowds: Crowd simulation with deep reinforcement learning and examples. ACM Transactions on Graphics, 42(4), 2023. doi: 10.1145/3592459.
Mohcine Chraibi and Jun Zhang. JuPedSim: An open framework for simulating and analyzing the dynamics of pedestrians. In SUMO 2016: Traffic, Mobility, and Logistics, pages 127–134, 2016. URL https://hdl.handle.net/2128/11280.
Luis Rene Montana Gonzalez and Steve Maddock. A sketch-based interface for real-time control of crowd simulations that incorporate dynamic knowledge. Journal of Virtual Reality and Broadcasting, 16(3), 2021. doi: 10.48663/1860-2037/16.2019.3.
Boris Sekachev, Nikita Manovich, and Andrey Zhavoronkov. Computer vision annotation tool, 2019. URL https://zenodo.org/records/3497106.
Qingyu Song, Changan Wang, Zhengkai Jiang, Yabiao Wang, Ying Tai, Chengjie Wang, Jilin Li, Feiyue Huang, and Yang Wu. Rethinking counting and localization in crowds: A purely point-based framework. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), pages 3365–3374, 2021. doi: 10.1109/ICCV48922.2021.00335.
Yong Zhang, Bo Yang, and Jianlin Zhu. A double-layer crowd evacuation simulation method based on deep reinforcement learning. Computer Animation and Virtual Worlds, 35(3):e2280, 2024. doi: 10.1002/cav.2280.
Yiran Zhao and Roland Geraerts. Automatic parameter tuning via reinforcement learning for crowd simulation with social distancing. In 2022 26th International Conference on Methods and Models in Automation and Robotics (MMAR), pages 87–92. IEEE, 2022. doi: 10.1109/MMAR55195.2022.9874284.