[PDF version of this document]
CS 522\\ Assignment 5

CS 522
Assignment 5

Jean-Sébastien Bolduc
(jseb@cs.mcgill.ca)

16 December 2002


Requirements for the assignment are described on the assignment web page. The solution consists of the two files:

The file DEVS.py is also required, but hasn't been modified.

Description

The coupled-DEVS connects the atomic-DEVS in the obvious manner. We use the default select function.

As for the simulator (file Simulator.py), it has been modified as suggested so the termination condition is based on the Statistics DEVS' numCars attribute.

Use

To run the simulation, use the following command line:

> python Traffic.py -h

to display help information, or
> python Traffic.py [s:int] [n:int] [r:int | -debug]

where If the -debug flag is not used, several experiments will be performed for various traffic densities (traffic densities specified by the list MEANS in the code). The output then consists of three columns (mean, average transit time, std deviation of transit times).

If the -debug flag is used, only one experiment is performed, with a traffic density corresponding to MEANS[0]. The output is then a detailed description of the simulation is progress.

By default, MEANS = [1.5, 2.0, 2.5, 3.0, ... 29.5, 30.0]

Example

Below is the output obtained by typing python Traffic.py s:2 n:2 -debug:

* * * * * * * * * *  CLOCK: 0.925550

Generator B : create < ID:1, aggr:1, created:0.925550>
Queue B : receive < ID:1, aggr:1, created:0.925550>
Queue B : send authorization request (1)
Junction : receive authorization request from Queue B (1)

* * * * * * * * * *  CLOCK: 1.025550

Junction : send authorization to Queue B
Queue B : receive authorization
Queue B : send < ID:1, aggr:1, created:0.925550>
Junction : receive < ID:1, aggr:1, created:0.925550> from Queue B

* * * * * * * * * *  CLOCK: 1.554002

Generator A : create < ID:2, aggr:7, created:1.554002>
Queue A : receive < ID:2, aggr:7, created:1.554002>
Queue A : send authorization request (7)
Junction : receive authorization request from Queue A (7)

* * * * * * * * * *  CLOCK: 1.766945

Generator B : create < ID:3, aggr:5, created:1.766945>
Queue B : receive < ID:3, aggr:5, created:1.766945>
Queue B : send authorization request (5)
Junction : receive authorization request from Queue B (5)

* * * * * * * * * *  CLOCK: 3.164434

Generator A : create < ID:4, aggr:5, created:3.164434>
Queue A : receive < ID:4, aggr:5, created:3.164434>

* * * * * * * * * *  CLOCK: 3.713996

Generator A : create < ID:5, aggr:5, created:3.713996>
Queue A : receive < ID:5, aggr:5, created:3.713996>

* * * * * * * * * *  CLOCK: 4.144591

Generator B : create < ID:6, aggr:9, created:4.144591>
Queue B : receive < ID:6, aggr:9, created:4.144591>

* * * * * * * * * *  CLOCK: 4.820522

Generator A : create < ID:7, aggr:4, created:4.820522>
Queue A : receive < ID:7, aggr:4, created:4.820522>

* * * * * * * * * *  CLOCK: 5.733151

Generator B : create < ID:8, aggr:2, created:5.733151>
Queue B : receive < ID:8, aggr:2, created:5.733151>

* * * * * * * * * *  CLOCK: 5.816533

Generator A : create < ID:9, aggr:10, created:5.816533>
Queue A : receive < ID:9, aggr:10, created:5.816533>

* * * * * * * * * *  CLOCK: 6.025550

Junction : output < ID:1, aggr:1, created:0.925550>

* * * * * * * * * *  CLOCK: 6.125550

Junction : send authorization to Queue A
Queue A : receive authorization
Queue A : send < ID:2, aggr:7, created:1.554002>
Junction : receive < ID:2, aggr:7, created:1.554002> from Queue A
Queue A : send authorization request (5)
Junction : receive authorization request from Queue A (5)

* * * * * * * * * *  CLOCK: 7.230760

Generator B : create < ID:10, aggr:5, created:7.230760>
Queue B : receive < ID:10, aggr:5, created:7.230760>

* * * * * * * * * *  CLOCK: 8.088203

Generator A : create < ID:11, aggr:8, created:8.088203>
Queue A : receive < ID:11, aggr:8, created:8.088203>

* * * * * * * * * *  CLOCK: 9.018014

Generator B : create < ID:12, aggr:9, created:9.018014>
Queue B : receive < ID:12, aggr:9, created:9.018014>

* * * * * * * * * *  CLOCK: 9.148306

Generator A : create < ID:13, aggr:4, created:9.148306>
Queue A : receive < ID:13, aggr:4, created:9.148306>

* * * * * * * * * *  CLOCK: 10.355048

Generator A : create < ID:14, aggr:1, created:10.355048>
Queue A : receive < ID:14, aggr:1, created:10.355048>

* * * * * * * * * *  CLOCK: 10.775091

Generator B : create < ID:15, aggr:3, created:10.775091>
Queue B : receive < ID:15, aggr:3, created:10.775091>

* * * * * * * * * *  CLOCK: 11.125550

Junction : output < ID:2, aggr:7, created:1.554002>

Mean Transit Time : 7.335774
Std Deviation Transit Time : 3.161862

Results

We plot the average transit time in function of the mean m (uniform distributions of Inter-arrival times for cars on both lanes are uniformly distributed in [m-1, m+1] ).

In figure 1, we counted 100 cars, and we did 10 experiments at every point. We clearly see that when the traffic gets more important (i.e., when the mean m gets smaller) the Zipper strategy is more interesting.

avgA.png

Figure 1: 100 cars, 10 experiments

To evaluate the impact of the number of cars and the number of experiments at each point, we did two extra experiment. In figure 2, we counted 200 cars and did 10 experiments at every point, whereas in figure 3 we counted 100 cars and did 5 experiments at every point.

We note that even if the number of cars and the number of experiments at each point vary, the results are qualitatively the same.

avgB.png

Figure 2: 200 cars, 10 experiments

avgC.png

Figure 3: 100 cars, 5 experiments

For reference, we plot in figure 4 the standard deviation associated with the transit time as a function of mean, for the same experiment as in figure 1.

stdA.png

Figure 4: Standard Deviation




Translated from TEX by TTH, version 3.02 (minor customizations by HV). On 16 Dec 2002, 10:16.