AlgoViz

Design an elevator system

medium 90 min

Model a bank of several cars that answer hall calls and car calls.

Watch lesson5:05

Where it shows up

The same pattern appears across everyday software.

  • Linux mq-deadline disk scheduler

    Requests are served in batches in increasing sector order, like one sweep of a car. Each request also has a deadline, checked between batches, so that the sweep cannot delay one request without end.

  • PostgreSQL synchronised scans

    With `synchronize_seqscans` a big table scan may start in the middle and wrap around to meet one that is already running. Two readers share one ride, as two people share one car.

  • Open-RMF lift messages

    The open source robot framework describes a lift with a current floor, a destination, door state (closed, moving, open), motion state (stopped, up, down, unknown) and modes such as human, robot, fire, offline and emergency. Movement, doors and modes are three separate fields.

  • Elevator Saga

    A browser game in which you program the cars in JavaScript. Its API has `goToFloor`, an `idle` event and `floor_button_pressed`: an event driven version of our car.

  • Destination dispatch in tall buildings

    Passengers choose the floor at a keypad, touch screen or card reader and are sent to a car. Otis Compass is one such system. It groups people with the same target.

  • Accessible door timing

    The US Access Board's guide to the ADA standards says that a sensor that re-opens doors must work for at least 20 seconds, and that doors stay fully open for at least 3 seconds after a call. Door times are rules of law, not taste.

  • Fire service

    Real cars have phases of fire service. In phase one, started by a detector or a key switch, the car leaves normal service and goes to a recall floor.

  • Java `TreeSet`

    `higher`, `lower`, `ceiling` and `floor` answer the question of the next stop in O(log n). They are part of `NavigableSet`.