# Intersection

 David Bélanger dbelan2(à)cs.mcgill.ca Hesheng Chen hchen19(à)cs.mcgill.ca

## About the Work Distribution

Work has been equally divided between the team members. We work together to solve the problem, each member contribuing its ideas to lead eventually to a complete solution.

## Files

Links to files are found in the appropriate sections. All files can be found here.

## Petri Net Model

```File:
intersection.net
```

(internal - revision 1.19)

## Description of Model

1. Car Generation

We used a single car generator (located bottom left corner) that can generate an infinite number of cars. Car generated has then the choice of which direction to come from (N, S, E, W). Note that in our model the destination of a car is not chosen at generation time.

Each direction has a place for cars to wait before engaging themselves into the intersection. These waiting places before the intersection are labelled North, South, East and West respectively. The number of tokens in theses places represent the number of cars waiting.

Also, each road segment has an exit place. A single place could have been used but we prefered to use one for each road segment as it is closer to the reality and allows us to know the number of cars that exited each road segment.

3. Street Intersection

Four places modelling each quadrant (NW, NE, SW, SE) are used. Each token in a quadrant represents a car. (Note: There will never be more than one).

Our model obeys these 2 rules:

• No more than one car in the intersection: This is easily accomplished by using one token in the free place. To be able to enter the intersection, a car must acquire that token. When it exits, the token goes back in the free state.
• U-turns are not allowed: To do this, we first observed that a car can either exit the intersection or procede to the next quadrant. To avoid a U-turn (or worse several turns around the intersection), a car can change quadrant at most twice. To model this we use a place called MoveLeft. The number of tokens in it represents the numbers of moves (or change of quadrant) that the car is allowed. When the car exits the intersection, a flag token goes in Status. We need to reset the moves to 2 before a new car can enter the intersection. This is done by feeding back tokens in MoveLeft from MoveTaken before the token stored in Status can be moved to Free.

## Performance Metrics

Performance of the system modelled can be measured by the number of cars in the waiting places (queues). Note that depending on the car destinations, several cars could, in a real-life, be in the intersection at the same time, as long as they are not in the same quadrant at the same time. By allowing only one car in the intersection at any time, we have a lower performance. Note a road segment could have more traffic that the other. Then performance could the improved by using priorities for cars entering in the intersection.

## Animation

Movement in intersection

The trajectory taken by the car is knowned by the places the token travel through. To animate it, we would make the small car move smoothly (make the movement look continuous up to some point) from one quadrant to the other by computing intermediate position between the discrete events. The geographical position of the places in the Petri Net model correspond to a real life intersection. In an animated model, cars will be displays more or less where the places are.

Queuing

As opposed to the Petri Net where all cars (tokens) pile up in the same place to wait, an animation of the model would require drawing the cars in a line up.

Car Generation

Cars will appear as coming from outside the screens.

## Possible Improvement

We could have given priorities to some transitions to reduce the accumulation of cars in the queue places. Passing throught the intersection requires more steps (transitions firing) due to the "clean-up procedure" than generating cars. With equal priorities, cars will be produced faster than consumed by the interstion.