13
Traffic Lights Specification Niek

Traffic Lights Specification Niek. Overview Traffic lights are used everywhere Various algorithms: ◦Simple time-based traffic lights ◦Pressure sensors-based

Embed Size (px)

Citation preview

Page 1: Traffic Lights Specification Niek. Overview Traffic lights are used everywhere Various algorithms: ◦Simple time-based traffic lights ◦Pressure sensors-based

Traffic Lights Specification

Niek

Page 2: Traffic Lights Specification Niek. Overview Traffic lights are used everywhere Various algorithms: ◦Simple time-based traffic lights ◦Pressure sensors-based

Overview

Traffic lights are used everywhereVarious algorithms:

◦Simple time-based traffic lights◦Pressure sensors-based systems◦Connected systems (“green wave”)

We don’t bother:◦This is not an algorithm specification◦We’ll define a spec to check whether a traffic

lights system is correct◦Not whether it’s the most optimal solution

Page 3: Traffic Lights Specification Niek. Overview Traffic lights are used everywhere Various algorithms: ◦Simple time-based traffic lights ◦Pressure sensors-based

Assumptions

Placed at intersections◦Typically T-type or cross-type intersections◦Assumption: dedicated light/lane per direction◦No deadlocks shall occur◦Example:

Page 4: Traffic Lights Specification Niek. Overview Traffic lights are used everywhere Various algorithms: ◦Simple time-based traffic lights ◦Pressure sensors-based

Definition of an intersection

type Intersection := {Road}type Road := {Lane}

There is a relation between the number of roads at an intersection and the number of lanes per road:

Page 5: Traffic Lights Specification Niek. Overview Traffic lights are used everywhere Various algorithms: ◦Simple time-based traffic lights ◦Pressure sensors-based

Definition of lanes

type Lane := (label :: Label, conflicts :: {Label},color :: Color)

type Color := Green | Red

The label of a lane is unique in the scope of the intersection

The conflicts labels are the lanes which cannot be green at the same time as the current lane

Page 6: Traffic Lights Specification Niek. Overview Traffic lights are used everywhere Various algorithms: ◦Simple time-based traffic lights ◦Pressure sensors-based

Conflicting lanes example

Crossing lanes are not allowedNeither are lanes which arrive on the

same road

Page 7: Traffic Lights Specification Niek. Overview Traffic lights are used everywhere Various algorithms: ◦Simple time-based traffic lights ◦Pressure sensors-based

Enforcing unique labels

Labels are unique in the scope of the intersection:

type Intersection := {Road}type Road := {Lane}type Lane := (label :: Label, conflicts :: {Label}, color :: Color)

Page 8: Traffic Lights Specification Niek. Overview Traffic lights are used everywhere Various algorithms: ◦Simple time-based traffic lights ◦Pressure sensors-based

Conflicting lanes

If conflicting labels are specified, they must be part of the same intersection:

type Intersection := {Road}type Road := {Lane}type Lane := (label :: Label, conflicts :: {Label}, color :: Color)

Page 9: Traffic Lights Specification Niek. Overview Traffic lights are used everywhere Various algorithms: ◦Simple time-based traffic lights ◦Pressure sensors-based

Correctness

Conflicting lanes may not have a green light at the same time:

type Intersection := {Road}type Road := {Lane}type Lane := (label :: Label, conflicts :: {Label}, color :: Color)

Page 10: Traffic Lights Specification Niek. Overview Traffic lights are used everywhere Various algorithms: ◦Simple time-based traffic lights ◦Pressure sensors-based

Correctness (cont’d)

Intuitively: if a lane has a green light, all non-conflicting lanes should be green as well:

This is not the case, example on next slide.

type Intersection := {Road}type Road := {Lane}type Lane := (label :: Label, conflicts :: {Label}, color :: Color)

Page 11: Traffic Lights Specification Niek. Overview Traffic lights are used everywhere Various algorithms: ◦Simple time-based traffic lights ◦Pressure sensors-based

Correctness (cont’d)

Example:

In other words: an algorithm is required to select non-conflicting lanes with the highest “priority”◦E.g. Longest wait time/most cars

Page 12: Traffic Lights Specification Niek. Overview Traffic lights are used everywhere Various algorithms: ◦Simple time-based traffic lights ◦Pressure sensors-based

Conclusion

If a traffic lights system confirms this spec, no accidents will occur◦At least not due to conflicting lights

Whether or not the system is optimized, depends on the algorithm

Real-life issues which make the problem harder:◦Pedestrian paths/lights crossing the lanes◦Merged lanes/lights

Page 13: Traffic Lights Specification Niek. Overview Traffic lights are used everywhere Various algorithms: ◦Simple time-based traffic lights ◦Pressure sensors-based

Conclusion (cont’d)

01

54

2 3

Intersection = {{(0, {2, 4, 3}, Green), (1, {4}, Green)},{(2, {0, 4, 5}, Red), (3, {0}, Red)},{(4, {0, 1, 3}, Red), (5, {2}, Green)}}