Wednesday, July 21, 2010

A traffic flow simulation

This traffic flow educational project with Matlab features a gradually increasing car density starting from an initial value of 0.2. There are 250 cells. The update rule (describing the transition from time t to time t + 1): apply rule 184, after which randomly select a position - if occupied, nothing happens, while if empty, introduce a car at the selected place with probability 0.7. The image follows the first 500 time units. Notice the transition to a congested regime happening at some point (emerging shock waves). In the picture, free cells are blue, while cells occupied by "cars" are red.