Skip to content
Playing around with optimizing traffic light timing
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea
traffic
.gitignore
.travis.yml
LICENSE
README.md
TrafficSimulator.ipynb
requirements.txt

README.md

trafficlights

Build Status

Playing around with optimizing traffic light timing

The scenario being modeled is a set of four roads (L1, L2, R1, and R2) that all converge on a single exit (E) by way of three convergence intersections (L, R, and C). The two "funnel" roads (L and R) funnel traffic into the exit itself.

         L2     R2
          |     |
          |  C  |
    L1----+--+--+---- R1
          L  |  R
             |
             E

Each intersection act as both an XOR gate (only one of the two inputs can move/drain at a time) and as a small buffer, holding up to three cars. Cars can flow from input to output if:

a) The intersection gate is open in its direction b) The output segment is not full c) The intersection buffer is not full

The four input roads and the exit are considered to have infinite capacity. Funnel road L can hold five cars. Funnel road R can hold 10.

Cars have four possible states: waiting, reacting, moving, and exited (0-4 respectively). When moving, all cars move at the same speed, but each car has its own latency delay between when it's first possible to move and when it actually moves. The latency is randomly assigned in the range of 1-5. Once moving, it takes a car 2 ticks to travel 1 car length. A car cannot start moving until the car in front of it has moved.

You can’t perform that action at this time.