transcript

Spanning Tree - The Science Behind Elevators

Thumbnail of the video “Spanning Tree - The Science Behind Elevators”
Download Markdown
Community upload. AI output has not been independently verified.

The Elevator

When elevators and buildings started being controlled by computers instead of controlled by people, they needed algorithms to determine how those elevators should work. An idle elevator can see which floors have passengers waiting, but if multiple floors have waiting passengers, what should an ideal elevator do? Answering that question requires answering what we mean by an ideal elevator.

Maybe an ideal elevator is one that minimizes wait times, in which case you might follow an algorithm like this: go to the nearest floor that has a passenger waiting and take them to their destination, picking up any other passengers along the way going in the same direction. But this strategy has a problem. In a tall building where lots of passengers are going back and forth between the first and second floors, someone waiting for the elevator on the top floor might get stuck there. That could happen because an elevator that always picks the nearest passenger will always stick to the first and second floors, where there are nearby passengers waiting, potentially ignoring floors that are further away.

So an optimal elevator should also ensure that every passenger is eventually serviced in a reasonable timeframe. A simple way to do that is just to have an elevator that follows a fixed pattern: start at the first floor, go up to the top floor, picking up any upward-bound passengers along the way, then go back down to the first floor, picking up any downward-bound passengers in the process, repeated indefinitely. This elevator will always service every passenger.

Multiple Elevators

This algorithm, which literally happens to be named the elevator algorithm, is also useful in computer systems. When trying to read data from some hard drive, the disk's arm can move in one direction servicing all of the requests it encounters, and then switch directions once it reaches the end. But we can improve on this algorithm. If the elevator is traveling up but there's nobody in that direction waiting, we can stop traveling up, turn around, and start traveling down instead. We've made this elevator a little bit more efficient.

Of course, the real way to make transport in this building more efficient is to add more elevators. Using this same elevator algorithm across multiple elevators is actually not so efficient. If two elevators find themselves traveling in the same direction, they might end up neck-and-neck and not actually that much better than just a single elevator. So some elevator systems communicate with one another. If one elevator is servicing requests going up, it can tell another elevator to start heading down. Some systems assign elevators to separate zones of floors they're told to prioritize, and some elevators are designated as Express elevators that get people back and forth between popular floors only, ignoring less popular floors and optimizing for the most common types of transit.

There are other factors they might optimize for too, not just minimizing wait time but also minimizing time spent in the elevator, avoiding overcrowding, minimizing energy usage, and more. Since different buildings have different sizes and different patterns of when people request elevators at different floors, it's tough for people to come up with a good algorithm that works well all the time across lots of different buildings.

A Modern Approach

It's for that reason that a popular approach has been to let the computer decide on its own algorithm using reinforcement learning. A computer operating the elevator system can try one scheduling algorithm, see how well it performs, and then make adjustments over time to make the algorithm better and better for that particular building's needs. This can mean making sure elevators are always at the lobby when people are likely to enter, preventing any one person from waiting too long, and adjusting to optimize for the time of day, for example.

The algorithmic revolution that happened with elevators is happening elsewhere too, from cars and construction to markets and medicine and more, anywhere that human-guided decision making becomes computerized. It's worth thinking about how the computers are making those choices. Even still, there's no universally agreed-upon, perfect solution for how elevators should operate. How would you manage an elevator system? What would you prioritize, and how would your elevators decide what to do?