Skip to content

Development

mitgobla edited this page Apr 26, 2019 · 6 revisions

Traffic Light System Wiki

Development

The entire project was developed over these stages:

  1. Initial brainstorming. (See Backstory)
  2. First simulation programming for PA Consulting competition entry deadline.
  3. Re-write of simulation software, and development of demo program for the PA Consulting Finals.

First Submission

Explanation video: https://youtu.be/tiH4ZLpnVOU

We programmed the simulation software in Python using a module called SimPy. This allows us to run long simulations almost instantly and receive results based on variables we were monitoring. We used vectors to determine the distances between two traffic lights, and many variables in an environment class to reflect on the conditions of the traffic system.

Furthermore, we stored information about different vehicles in JSON which enabled us to set a bias towards certain vehicles appearing at the traffic system. Vehicles have different lengths and acceleration speeds, therefore the data had ranges so the program could randomly select suitable vehicle properties.

We then used MatPlotLib to display our results on a 3D graph. Furthermore, using NumPy and SciPy, we programmed an automatic "most efficient" line of best fit on the 3D graph which reflected the best timings to use for the traffic lights at a certain traffic level.

However, this submission had many problems. The simulation was not accurate and we had no way to visualize the simulation process to find how to correct it. The SimPy module limited how accurate the simulation could be, so we looked into other options.

Final Submission

We are extremely pleased to be invited to the PA Consulting Finals. Using GitHub Project boards, we created notes on issues we had with the first version. This helped us keep organised while creating improvements for the final submission.

Our first major improvement was porting to Salabim from SimPy. This module comes with excellent tools for simulation such as monitoring and animation. These tools were vital for us to visualize what was going on during the simulation, allowing us to find errors much faster than before. Salabim also runs much faster than SimPy, meaning we could run multiple simulations for longer durations to produce accurate results.

We also created a demo game using Pygame. This is to make it easier to visualize the simulated timings being used in a random environment. The vehicles in this game are coloured depending on how long they have been waiting at the traffic light.

Moreover, we built a physical miniature traffic light to show how the Raspberry Pi would control the traffic lights using the simulation data.