In this (ring-road multi-lane) traffic simulation, one can take the wheel of a car for changing lanes, acceleration and deceleration in real time, also creating congestion. One can observe the traffic dynamics and stop-and-go waves through plotting the time-space diagram of trajectories
I used R2023a
- Make sure everything is under the same folder
- Change settings in "Z_Setup.m"
- Type "Main_A_Simulation" in Command Window to run the simulation and interactive interface
- Type "Main_B_PlotTrajectory" in Command Window to plot the trajectories
- Simulation results (data) are saved in the folder "SimulationResult" Note: I used a MacBook Pro. The position and size of the animation may vary depending on the screen resolution. I will improve it when I have more time.
- Press 'Enter' on the keyboard to enter the interactive mode; Press it again to quit
- Press 'Up' - Accelerate
- Press 'Down' - Decelerate
- Press 'Left' - Change lane to left
- Press 'Right' - Change lane to right
A variant of Cellular Automata (CA) model is used. see slides for CA https://github.com/gotrafficgo/traffic_flow_theory_slides
- Velocity-Dependent-Randomization (VDR) model -- that is why you see two slowdown probabilities in Config.m
- Each cell is 1 m long -- that is why you see the animation is quite smooth
- Instantanous lane changing
Any suggestions are welcome!
Video of the simulation and interaction
Time-space diagram of trajectoris in a lane
Try the Super Mario version by downloading "Mario_Version.zip". Have FUN!