top of page
Writer's pictureHyun Min (Eddie) Kim

Simulating Different Rules for a Four-Way Intersection with Two Traffic Flows

Updated: Nov 12, 2020

Abstract


The purpose of this project was to simulate a four-way intersection that has two traffic flows with different rules. By measuring the ability of the number of cars passed through the intersection in each period, the efficiency of each rule for the intersection was determined and analyzed.



Introduction


Currently in the United States, there are general rules for four-way intersections. Most small roads use stop signs to effectively establish the order of traffic flow while larger intersections direct traffic through traffic lights. Those responsible for public infrastructure created these stop signs and traffic lights to prevent crashes in the intersections while allowing the flow of traffic to experience minimal hindrances. These traffic rules have been enforced in roads since the early 1900s and have not changed much since.


The analysis of such intersections is done both using real traffic data, as seen in Nikolay Nikitin’s work on roundabout analysis, and by observing simulation data1. There were many simulation-type resources of traffic flow on the web, varying in the representation of traffic flow and the types of intersections they modeled. Some of these were just visualizations of traffic while others provided information on the efficiencies of their respective intersection coupled with the type of traffic flow they simulated. For example, Martin Treiber’s traffic simulation visualizer gave the average speed of all the cars in km/hr and the total traffic flow in vehicles/hr3.


This project is an introductory visualizer of a four-way intersection where two perpendicular directions of traffic were tested with varying degrees of traffic density. Because of the usefulness of the Cellular Automaton Rule 184 in modeling basic one-lane traffic flows, this simulation aimed to apply the rule in the traffic flow logic to ultimately find the efficiency of a four-way intersection, one modeled by two traffic flows with both stopping and yielding1.


The efficiency of traffic flow is determined similarly to Treiber’s traffic simulation. The total number of cars that pass through the intersection in a fixed time-period is compared to the theoretical number of cars that should pass without the intersection. By dividing the actual by the theoretical number, the efficiency can be calculated. Along with efficiency, this simulation will help analyze the rules’ ability to effectively move traffic through the intersection with minimum delay.



Methods and Materials


Materials:

  • Wolfram Mathematica


Observation and Application of Cellular Automaton 184 (Rule 184):


As seen below in Figure 1, the Cellular Automaton 184 resembles traffic flow where a node occupies the next space to the right if that space is not occupied in the previous state4. A car can be modeled this way because, in the same way, a car is not able to move forward if there is another car in front of it blocking its way. To resemble the intersection, there had to be other functions inhibiting the Rule 184 iteration when the car furthest to the right reaches the intersection.



Figure 1. Rule 184 Code

By replacing 1’s with random colors showing the different cars and implementing the rule for the first car stopping, the movement of one-lane traffic was visualized. The randIteration function shown below in Figure 2 generates a random list of nodes represented by colors and placeholder 0’s. Cellular automaton 184 is used to create the visualizer of cars traveling in the leftward direction.



Figure 2. randIteration Function Visualization


Test #1:

For the first test, a fixed number of cars were generated by the randCar function for the x and y axis as seen in Figure 3. A list of values, car nodes, are generated. A set number of cars are placed in random numbers of spaces between them.



Figure 3. randCar Function Code



With these randomly generated lists of values, the efficiency of a Four-way intersection with Rule #1 where one flow of traffic yielded for the other and Rule #2 where two traffic flows behaved as though they had stop signs for each flow. To make this work, functions for the rules of the intersections were created. The functions defined in Figure 4 effectively handle these rules. The checkStop function first checks if any cars are at the intersection by calling isAtStopSign for both directions. Then, the checkIntersection function is called which determines if any points are currently in the intersection area.



Figure 4. Functions for Intersection Rules




Test #2:


This test was like Test #1 but had continuous flows of traffic rather than fixed amounts. The pushCar function seen below was used to append the car nodes to the x and the y axes at given intervals.



Figure 5. pushCar Function

Only data from Rule #2 was collected in this test because when one traffic yields to another in a situation with continuous traffic flow, the flow that yields will not be able to ever move. Data was obtained by running 4000 iterations of the simulated scenes for each of the traffic flow cases. For each iteration, the algorithm checked if there was a car that left the intersection and if this was the case, increased the number of counted cars. The same functions in the intersection were applied to the usage of Rule 184 to simulate the traffic flow.


Data

Figure 7. Graphic of Rule #1 from Test #1


Figure 8. Graphic of Rule #2 from Test #1



Figure 9. Graphic of Rule #2 from Test #2


Figure 10. Actual number of cars that went through the intersection from the two traffic flows in Rule #2 (Space between cars vs Number of cars)



Figure 11. Theoretical number of cars that would have passed without the intersection in Rule #2 (Treating the x and y as individual lanes without any obstacle)


Figure 12. Graph of data from Figure 4 & Figure 5 to find the efficiency of Rule 2 with various traffic flows


Analysis


In Test #1, the number of iterations it took for the car nodes to cross the intersection was less for Rule #1, visualized in Figure 7, than for Rule #2, visualized in Figure 8. This was because in Rule #2, all cars had to stop before the intersection, slowing the traffic significantly. On the other hand, in Rule #2, only the yielding traffic did. However, for rare cases for Rule #1 where all cars stopped once, the number of iterations it took for all traffic to pass the intersection was the same as with Rule #2. During Test #1, it was evident that Rule #1 could not be implemented if given continuous flows of traffic. With enough cars, the traffic that yields for the other will simply not move, making it unrealistic for large amounts of traffic.


Test #2 was only simulated with Rule #2 for the reasons discussed above and it provided information on the efficiency of continuous traffic flows. The visualizer for this test on Rule #2 was saved as a graphic in Figure 9 with cars moving in the positive x and y directions. The number of cars that passed through the intersection for various intervals of traffic is shown in Figure 10. For cases simulated where the interval between the cars was less than or equal to eight, many cars piled up in both the x and y lanes, causing major delay and slowing the overall rate of traffic flow in a few iterations. The theoretical number of cars that should have passed without the intersection was graphed in Figure 11. the actual number of cars passed through the intersection was divided by the theoretical value, giving the efficiency of traffic. This data, graphed in Figure 12, showed an upward linear trend for cases where the spacing between cars was 1-8 intervals. The rest of the intervals showed a relatively constant rate near the 100% efficiency mark. This is because when the spacing is greater than 9, there is no instance when the traffic starts to pile up. Therefore, the implementation of stop signs for intersections where there are fewer cars all traveling at the same time is appropriate. The stop sign rule provides the ability for both traffic to move cars from the two flows of traffic with adequate efficiency under the circumstance that there is a small amount of traffic and the frequency of cars coming to the intersection is low.


Conclusion


The simulation and the data it provided was used to determine the efficiency of the stop sign rule for a four-way intersection with two traffic flows. It was evident from the tests that yielding was only effective in moving traffic with low density. On the other hand, the stop sign rule guaranteed that all traffic would find its way on the other side of the intersection although this rule allowed fewer cars to pass the intersection in a given time compared to the yielding rule. The data collected was the number of cars that passed through the intersection given different traffic flows. In Test 1, both Rule #1 and Rule #2 were tested, and it showed that one traffic yielding another was more effective in moving a fixed number of cars. Test 2 where only Rule #2 was used (due to the unrealities of one traffic flow forever waiting for the other) indicated that the stop sign is not ideal for large waves of traffic: because every car has to stop behind the stop sign, traffic flows with cars coming in short intervals caused the traffic to gradually pile up.


Although the research is complete, there are many steps that could be taken to further this project. For example, more roads can be added to this simulation to test a four-way intersection with four different directions of traffic flow. This will allow the testing of different rules for this intersection such as the actual rules in the US and many more custom rules that may provide a better solution. Another improvement to this project would be the consideration of physical motion such as acceleration and deceleration in traffic flow. Currently, a customized Rule 184, one that uses lists and the individual positions of variables in it, is used to model cars moving. With the addition of physical motion, this simulation can better replicate the real movements of cars. Finally, another step - this time, a rather large one - for the analysis of traffic would be to consider different types of intersections such as a roundabout or highway ramps.



Works Cited

  1. Higashi, Kohei, et al. “Rule 184 Fuzzy Cellular Automaton as a Mathematical Model for Traffic Flow.” ArXiv.org, 11 Apr. 2020, arxiv.org/abs/2004.05294.

  2. Nikitin, Nikolay, et al. “Efficiency Analysis of Roundabout with Traffic Signals.” Transportation Research Procedia, Elsevier, 26 Jan. 2017, www.sciencedirect.com/science/article/pii/S2352146517300728.

  3. Treiber, Martin. Microsimulation of Traffic Flow: Onramp, Traffic-Simulation, 2020, traffic-simulation.de/.

  4. “Wolfram Atlas: Rule 184.” The Wolfram Atlas of Simple Programs, Wolfram, atlas.wolfram.com/01/01/184/.

40 views0 comments

Comments


Post: Blog2_Post
bottom of page