Traffic Lights Specification Niek. Overview Traffic lights are used everywhere Various algorithms:...

Preview:

Citation preview

Traffic Lights Specification

Niek

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

Assumptions

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

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:

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

Conflicting lanes example

Crossing lanes are not allowedNeither are lanes which arrive on the

same road

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)

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)

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)

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)

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

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

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)}}

Recommended