$29
Note that the work that you turn in for this assignment must represent your individual effort. You are welcome to help your fellow students to understand the material of the course and the meaning of the assignment questions, however, the answer that you submit must be created by you alone. Assignments will be assessed on your efforts and approach you are using for particular solution.
1 Deadlock Detection
Consider an uncontrolled traffic intersection problem found in area where traffic is increasing day by day and new traffic system needs to be designed on intersection based on standard North America intersection protocol. You are required to simulate the intersection signalling controller solution and submit in a presentable form. For instance, see the Figure 1 where four cars reaching traffic intersection are deadlocked. You are encouraged to avoid this deadlock with your solution in any preferred programming language. Follow the given protocol:
Figure 1: Deadlocked intersection with four vehicles
1
1. All roads (A, B, C, and, D) have two lanes giving each vehicle three ways(right, left, and, straight) on intersection to proceed.
2. When vehicle Facing GREEN light:
(a) Vehicle can proceed two ways, i.e. right and straight
(b) For left tern driver must see there is no vehicle coming from other sides. If there is no vehicle take left turn or if there is one or more let them proceed first, before it take the turn.
3. When vehicle Facing RED:
(a) For right tern vehicle must stop for 3 seconds and if no vehicle is coming from left, driver can take right. If there is one, let it proceed and wait for 3 seconds again watching if another vehicle is coming, if not; take right turn otherwise remain stopped and repeat the same process.
4. At once both side must not have same signal light ON. If one is RED, second must be GREEN and vice versa.
5. Of course, you need to give considerable transition period (for instance 2 seconds) from RED to GREEN. Use YELLOW light during the transition period.
6. No need to consider Pedestrian, for the purpose of simulation.
2 Simulation
1. For this assignment you are required to simulation three vehicles on road A e.g. (av1,av2,av3), two vehicles on B e.g. (bv1,bv2), one vehicle on C e.g. (cv1), and one on D e.g. (dv1). Your simulation should start with the described number of vehicles on each road and clearly output the status of each vehicle moving and going forward towards any of three sides but end of simulation all the vehicles should leave the intersection without any collision. You will randomly choose the direction for vehicles on the intersection in three direction: straight, left or right. You cannot choose the reverse direction. Record the reasonable turnaround time for the complete scenario proving deadlock free implementation.
2. Change the number of vehicles of your simulation and determine the point where human error can cause a collision i.e. when driver takes right turn on RED light and did not stop for 3 seconds. Hint: use exception classes in your preferred programming language