As shown in Figure 1 at a high level of abstraction, two lanes (A and B) join into a single lane.
For each lane, considered of a certain length, the car inter-arrival time is sampled from a uniform distribution. The leftmost blocks denote car arrival (similar to a GPSS GENERATE block).
The two lanes act as infinite capacity carriers of cars: when a car arrives on a lane, it queues in that lane (in order of arrival) until it can enter the junction road segment. The physical position of cars is not considered, only their ordering.
If the junction is free and only one of the lanes has at least one car in it (lane A for example), then the car at the head of lane A can go right through. Actually, to make the model more realistic, we introduce some time delays:
If the junction is free and both lanes have at least one car in them, we must decide on a strategy to select a car to enter the junction. You will experiment with two strategies.
Each car (its driver, actually) is assigned, upon creation, an ``aggressiveness factor''. This factor is an integer between 1 and 10, inclusive. The higher the number, the more aggresive the driver. If there is a car at the head of both lanes, the one with the highest aggressiveness factor go through the junction. In case of a tie, one is chosen randomly.
Before the car enters the junction, the driver needs to spend a small
amount of time to check that the other lane is not empty,
to make eye contact with the other driver, and to intimidate him/her
into letting himself/herself pass. The smaller
the difference between the aggressiveness factors of both drivers,
the longer the intimidation time ti is.
We will use the formula
|
In this strategy, cars from either lane alternate strictly. Each driver always lets at most one car from the other lane go first such that there is strict alternation. Waiting to let a car from the other lane go first is of course only done if both lanes have a car in them. As no time is spent on intimidation in this strategy, drivers only spend the regular time e checking the other lane and the junction before entering the junction.
With both strategies, recall that a car remains in the junction for a time K.
The transit time of a car is the time between its creation and its departure from the junction.
The average transit time is computed for a sufficiently high number of cars going through the junction.
You will compute the performance metric average transit time for various traffic loads for both scenarios.
In all cases, e = 0.1 s, K = 5.0 s, a = 6
Uniform distributions of Inter-arrival times for cars on both lanes are uniformly distributed in [m-1, m+1] with m varying from 1.5 to 30.
Plot average transit time as a function of mean inter-arrival time for both scenarios and draw conclusions.
We would like to change that condition so that the simulation terminates when a specified number of cars have passed the junction. For this you will need to modify slightly the method Simulator.simulate. It is easy to do if your Statistics DEVS has an attribute that counts the cars as they pass: if this attribute is called X, it can be checked from the method with self.model.statDEVS.X, where statDEVS is the coupled-DEVS attribute to which the Statistics DEVS instance is assigned.
You will use the PythonDEVS simulator found on the MSDL DEVS page.
You need DEVS.py and Simulator.py. template.py is a meaninful starting point. Queue.py demonstrates how to model a cascade of processors (of jobs) in PythonDEVS. An outdated version of this example is given in a report. This report gives background information on the implementation of the DEVS simulator.