Quoth Ben_Who
View Post
The standard elevator algorithm is very simple - it only needs to track the current position of the car, which buttons are currently activated (inside and outside), and a flag which says whether it's currently going up or down. So it will go up, stopping at every floor with the internal button or the external "up" button lit, until it runs out of requests in that direction. Then it will look for the topmost "down" request and service that, continuing down from there until it runs out again. It's so simple that for many years, the elevator controller was the jargon shorthand for an extremely small and limited computing environment.
There are variations on this theme, some handling multiple shafts efficiently (so two cars don't try to service the same external call at the same time), some which service only "up" or only "down" requests at particular times of day, etc. There are also variants for use on hard disks instead of actual elevators, which allow resetting the direction flag periodically so that processes don't starve each other of data. And then there's the one which disables the buttons entirely on the Jewish Sabbath.
There are a few new designs which put the numbered floor buttons on the outside, rather than merely allowing you to select a direction. It then directs you to a particular shaft which will service that floor. This allows the system to optimise traffic much better, by having each car stop at fewer floors on the way to the furthest one. This of course works best with several long shafts, so I haven't seen any over here where the buildings are not very tall.
Comment