Sunday, March 27, 2011

Event Flow Chart and Avoiding Jams

I have drawn up three diagrams to explain some of my the topics covered in my last post better.

This is a diagram of two intersection nodes. Suppose a car needed to get from intersection 2 to the intersection that is west of intersection 1; we will also suppose that the number of time steps required to get from the end of an incoming queue to the center of an intersection and the number of time steps required to get from the center of the intersection to the front of the outgoing queue, is 5. The car would exit the west outgoing queue of intersection 2 and enter the incoming queue of intersection 1 which would schedule a choose direction event for 5 time steps in the future. When the car got to the center of intersection 1 (this is represented by the execution of the choose direction event), it would realize that there was no room to enter the west outgoing queue, or any other queue for that matter, so the car would schedule a departure event to go east for 5 time steps in the future, which would put the car in the east outgoing queue of intersection 1. It would also schedule an arrival event for intersection 2 for the 5 time steps in the future. This cycle may go on once or twice in hopes that one of the jams in intersection 2 will subside. However, if the jams do not subside, the car will have to choose a different direction to avoid the jams. 

This is a diagram of many intersection nodes all in a configuration and how the previously described algorithm can be used to avoid a jam, as well as how to avoid a livelock for the entire model. The car will begin by attempting to go south the east, after a few tries it will go either west or north (west in this case) and then go south. The car will then try to go east again when it is nearest to its destination, and when it realizes that it cant, it will go south again, then east and then north. A car's final destination is determined by the total number of spaces north or south and east or west, it has remaining to move. Therefore the algorithm to determine where the car should move from a particular intersection becomes very simple, the car should either towards its destination in the vertical or horizontal directions. If neither of these two options are available, the car must pick a different direction at random and move there in an attempt to avoid the jam.
The flow chart above describes the events that are scheduled in order to accomplish the algorithm aforementioned. The colors indicate which intersection to the particular event is scheduled for, and the arrows indicate which event (and intersection) the even was scheduled by. Starting at the event indicated "start", the arrival event schedules a direction choice which schedules a departure. An arrival is then scheduled on the blue intersection which goes through the same process as the red intersection and sends the car back. This may happen a few times before the red intersection schedules an event to send the car to a different intersection. 

I hope to have this coded up by next week, and if all goes well I should have some performance results within the next two weeks.

-J

No comments:

Post a Comment