This project aims to simulate road traffic using a macroscopic approach. The traffic flow is modeled using the Lighthill-Whitham-Richards (LWR) model. The simulation is done in 2D and the road network is generated using a web interface. The results are then displayed in a video file, or in multiple graphs showing the evolution of the density over time on each road.
- Clone this repository and enter the python environment. The list of dependencies is in the
requirements.txtfile. You will also need to install ffmpeg to generate the video file. - To change the parameters used by the numerical solver, edit the
config.jsonfile in theres/folder.
- Open the HTML file
index.htmlin theapp/folder in a browser. This will open an interface to generate the road network and the traffic flow. The instructions are written on the interface webpage. - Once the network is generated, click on the
Exportbutton to get a file calledroads.json. This file contains the road network data used by the simulation. Copy this file in theres/folder by replacing the existing file (the name of the file is important and should beroads.json).
- Finally, run the
main.pyfile. This will run the simulation and generate a video file in theout/folder. This video file contains the simulation of the traffic flow on the road network. - You can also choose to visualize the evolution of density over time on each road, you can also change the value of
outputTypefrom "video" to "density" in theres/config.jsonfile (advise: do not use this option if you have a lot of roads, otherwhise it might cause lag).
Main sources used for this project:
