It occupies about 15 pages (plus several pages of exercises and solutions). Knuth started working on TAOCP when he was a PhD student at Caltech:
> The program developed below simulates the elevator system in the Mathematics building of the California Institute of Technology. The results of such a simulation will perhaps be of use only to people who make reasonably frequent visits to Caltech; and even for them, it may be simpler just to try using the elevator several times instead of writing a computer program. […]
> The algorithm we will now study may not reflect the elevator’s true principles of operation, but it is believed to be the simplest set of rules that explain all the phenomena observed during several hours of experimentation by the author during the writing of this section. […]
> The elevator system described above is quite complicated by comparison with other algorithms we have seen in this book, but the choice of a real-life system is more typical of a simulation problem than any cooked-up “textbook example” would ever be.
It ends with:
> It is hoped that some reader will learn as much about simulation from the example above as the author learned about elevators while the example was being prepared.
And one of the exercises adds:
> It is perhaps significant to note that although the author had used the elevator system for years and thought he knew it well, it wasn’t until he attempted to write this section that he realized there were quite a few facts about the elevator’s system of choosing directions that he did not know. He went back to experiment with the elevator six separate times, each time believing he had finally achieved a complete understanding of its modus operandi. (Now he is reluctant to ride it for fear that some new facet of its operation will appear, contradicting the algorithms given.) We often fail to realize how little we know about a thing until we attempt to simulate it on a computer.
On one of the better teams I’ve worked with the water-cooler activity was trying to come up with an algorithm to describe the behaviour of the Coca Cola machine in the kitchen.
It was one of those clear plexiglass front machines where after punching in the coordinates of the item you wanted, a mechanical arm would move to the coordinates, take a drink, and place it in the delivery bay at the bottom.
While it would always get the drink you wanted, it would rarely go to the exact coordinates you specified. Ie, if there were three columns filled with coke, and you punched in the coordinates for the one on the far right, the arm may take a can from the center, or left column.
We would often wager a can of coke (“if I can’t find anything wrong in your PR, I’ll buy you a coke”), so we were perhaps drinking more soft drink than was medically advisable, but in our defence:
a) the machine was really cheap (AUD$1 or $1.5)
b) it was an excellent 10min break game
Eventually we thought they had it figured out we would gather and make our predictions, but occasionally there would be an upset that would throw a wrench into the model.
We got to a point where we just couldn’t reconcile the machine behaviour with any kind of coherent set of rules, then one morning we saw the delivery guy stocking it.
After chatting with him we learned our algorithm was more or less correct, but the internal state of the machine was prone to getting out of sync with the actual stock levels, so it would make the “wrong” choice near the end of the refill cycle. Then he gave the engineer talking to him a free energy drink (source of stock problems right there haha)
While we were no Knuths, I love that these kinds of games are so universal among engineers/devs. In fact, if I can get someone to tell me a similar story of theirs in an interview (for a technical role) I’m much more likely to consider them for the position. Curiosity is a powerful trait for a developer.
…and the (simple) algorithm for the machine is: Take from the column with the most stock, if there are multiple columns with the same stock level, take from the column furthest to the left.
"Programming is a good medium for expressing poorly understood and sloppily formulated ideas" is definitely on the list of my favourite programming quotes.
I'll often write out with pen and paper of how I think the flow of a model will go, it's always fascinating how much that diagram changes once I actually build the model. There are both drastic simplifications and increases in nuance based on experience with the system being modeled and where divergences occur.
Now, if there are multiple elevators but a single set of up/down buttons for them on each floor, that's where things get really complex really fast.
- The elevator has a "home floor" (the lobby/ground floor) that it returns to by default, if it has nothing else to do. (Apparently many elevators do this; see "Up peak" in the linked post or on Wikipedia https://en.wikipedia.org/w/index.php?title=Elevator&oldid=10... .)
- To set up such a discrete event simulation on a computer, you also need to model timing (how much time it takes to open and close doors, to move between floors with acceleration/deceleration, etc), and users (how many arrive at each floor and when, and where they want to go to, how long they wait before giving up).
- So you end up with a fair amount of state (the "up" and "down" call buttons on each floor, the buttons inside the elevator, whether the elevator is going up or down or neither) and control (when to open or close doors: what to do if someone presses a button while the doors are closing, etc).
- The purpose of that section of TAOCP is to show in detail how to use doubly-linked lists to simulate such things on a computer (which here means getting down to the level of memory layout and assembly code: MIX/MMIX). So overall there are ~5.5 pages of describing the algorithm, ~1.5 pages for memory layout etc, ~7 pages of assembly code, and a page of higher-level stuff mentioning programming languages and profilers etc.
I'm aware of two repositories on GitHub that reproduce this simulation in a higher-level language: https://github.com/meatfighter/knuth-elevator (700-odd lines of Go code including comments from TAOCP) and https://github.com/Quuxplusone/KnuthElevator (500-odd lines of C++14 code without the copied comments). (Learned of the latter via https://www.meetup.com/theartofcomputerprogramming/ a meetup for reading TAOCP.)
Also, this is a great talk if you want to know more about elevators: https://www.youtube.com/watch?v=ZUvGfuLlZus
You can catch it at:
https://archive.org/details/Defcon22_Talk29/DEF+CON+22+Hacki...
or
https://www.youtube.com/watch?v=oHf1vD5_b5I [01:00:15]
0. If they immediately blurt out something like "I know how elevators work", probably don't hire them.
1. You can find out what areas they're most interested in. Do they jump straight to the physical mechanics? The programming? The UI? The abstraction that they're solving a problem?
2. Eventually, they reach a point where they just have to say "I don't know". The rabbit hole really just keeps going with elevators. You could know this question is coming and we will still easily reach the knowledge boundary.
3. If they "don't know" you can ask them to guess how a system might work. Or give them time to research it and follow up with you later.
So if you just pick the floor then it waits 2 seconds before closing the door. Obviously the elevator waits for the door to get fully shut before it starts moving.
If you first press the "shut door" button and then the floor button, then the door shuts within any delays, which means the elevator starts moving 2 seconds earlier.
A game where you program the logic of elevators to move people around efficiently. Surprisingly complicated.
One of the ideas thrown around for achieving the objective was to somehow get ahold of an elevator key, stop it, and hide in there until the building closed.
I don't know if they actually did that, but it would've been hilarious to see them pop out like a scoobie doo villain and jack into an ethernet port while the janitor has no idea what's going on.
> Does not infect other passengers if the animal has an infection
I think this must be a mistranslation. There are very few infectious diseases that a human can get from being around a house pet. I think they mean allergies.
We got bored with that pretty quickly until, 4 gals form the girls floor decided they were going to camp out in there and set the Guinness record for the longest stay in an elevator. Some of the bigger dudes knew that we had hacked the elevator and asked us if we wanted to mess them up. Well... Of course. So we got on top and were listen to them yakkedy yak. Then we took it to between the 6th and 5th floors and locked it in place, then opened the upper doors on the 6th floor where a bunch of guys with big trash cans full of water were waiting.
We thought they were just going to douse them good. So we opened the ceiling trap door to the elevator with the lights off and those gals were screaming and squealing like crazy. Then come dude tossed a string of fire crackers in there followed by two giant Garbage cans of water right after that. Must have been at least a couple hundred gallons of water, who knows.
Then we set the thing to go to the first floor and jumped off. Waiting on the first floor where a bunch of people who were in on it with cameras to capture the whole things as the doors opened it was like the seas parting and flooding out as these poor drenched young ladies came floating out. Picture was on the front page of the school paper "Guinness Elevator Record Attempt Drenched" or something.
They called the cops and all that but no one squealed on us and it was all in good fun but to teach everyone a lesson they shut down the elevators for 3 weeks. Young people don't care, worth a climb of the stairs for all the fun!
BTW, I ended up marrying one of the gals on the elevator and yes I told her I was in on it, later. She loved that for some reason :)
Wiki lists a "Riot mode", which is just amazing if it's a thing.
However to get back to "airing the elevator out". Do you mean just not closing doors after serving a call? Maybe having someone timeout after serving a call to not move? Or actually installing fans to blow out the air?
When you did this, did the floor indicator show anything different?
And where (what country) was this?
This was at the University of Calgary, engineering buildings (circa 2000)
The thinking elevator,
so the makers proudly say,
will optimize its program
in an almost human way.
And truly, the resemblance
is uncomfortably strong:
it isn't merely thinking,
it is even thinking wrong.
(Piet Hein, 1973)> Does not infect other passengers if the animal has an infection
I'm glad that elevators are concerned about such a scenario.
https://allspecies.fandom.com/wiki/Bogdanoff_Twins
A fandom wiki about “all species” and it has just short of 1k articles about everything from these two guys to fictional species such as Alien.
https://monstercat.fandom.com/wiki/Crab_Rave
This one is specifically about the music label Monstercat. It has about 4k pages.
For example: https://www.youtube.com/watch?v=nE9x-S_3sdY
It's a very interesting community:
> watch for hours
The call time on the incline elevator… wow you weren’t kidding.
Also, at 5m40s is that a domestic clock being used for station timekeeping? Such a shame given the rest of the station design and the amount of time and money that went into it all. Details, people. Details :)
I may have acquired some Otis elevator power(?) tubes, but have no idea where to go for part schematics or identification. I'd love to build them into a project, but am not sure where to start.
It seems to be one of the more complete vim wikis and it's probably the most annoying wiki for a piece of open source software ever. I often go without using whatever information is on there just to avoid listening to my fans (heh) spin up.
Any idea what the purpose of that is? Price discrimination? Abuse prevention? "Well, the ancient elevator did it that way and we want the new one to be the same" backwards "compatibility"?
Maybe it was from a movie or something ...
Edit : Thanks! Found it - https://en.wikipedia.org/wiki/Elevator#Riot_mode
Basically, it excludes the ground level/publicly accessible floor, like a hotel lobby.
not to pick on a specific belief system, but it's quite interesting the lengths people go to follow the letter but not the spirit of things.
Of course, much like the tax code, there are gray areas where different accountants (rabbis) may interpret the rules differently. One place where the analogy diverges is that in Judaism, there are lots of areas where the earlier generations of rabbis acknowledge something to be technically allowed according to the divine rules, but they forbid it anyway, either because they felt there was some societal benefit to doing so, or because they felt that adding an additional prohibition would prevent people from accidentally breaking the divine rule [1].
[1] Of course, the analogy breaks down, because it's more complicated than this. There are plenty of areas where people are customarily stricter, even if something is ok by the letter of the law. This applies to Sabbath Mode on elevators, which many Orthodox Jews won't use, but won't necessarily say that it's prohibited.
[2] An example of this is the prohibition of eating milk and meat in the same dish. Technically, the divine rule is no cooking milk and meat together, but the rabbis added an extra rule of no eating them together to make sure that people wouldn't come to cook them together.
I would like to understand the reasoning behind the belief that even legal rules of divine origin would include mention of things human culture would have had no concept of, and human language no word for, in the time the rule was made — such that the rules would be "complete for all future time" rather than "those relevant as of the time of covenant."
Wouldn't even a god think it more optimal to hold off on telling us rules about e.g. which synthetic meats are kosher, until we invent such things?
It seems awfully suspicious to the validity of that interpretation, that there are plenty of specific/concrete prohibitions given amongst divine rulings, but of those, none are about things that were entirely mysterious at the time, written down "as spoken" without understanding, only able to be made sense of centuries/millennia later.
In fact — the Hebrew god is an intercessor god, not an absent god; don't they already "amend" their own previous rules whenever they communicate specific orders / demands / requirements to particular people? Does that not, by itself, disrupt the interpretation of the initial set of laws given being a perfect closed set, never to be updated, applicable to all future circumstances? Would a perfect body of divine law not already imply those orders / demands / requirements, such that there would be no need for further communication?
Would they have to wait till the burger cools down so that it doesn't melt the cheese? (Here I am concerned about carryover heating/cooking being considered cooking by law.)
I am endlessly fascinated by religious laws and their implications/consequences.
There are of also cases where a societal benefit outweighed new knowledge about biology. Spontaneous generation meant that it's ok to kill lice on the Sabbath and eat fish with worms in it (which nearly all fish do) so long as the worms are of the kind that hatch within the fish. Well lice don't spontaneously generate and the worm in question lives outside the fish, but are you really gonna tell people to not kill lice any day of the week and totally get rid of part of their diet? It's a fun bit of tradition I think.
Second, I am pretty sure the Talmud is not so precise to the point of specifically mentioning pressing pressing buttons on an elevator. So the analogy kind of doesn’t work there again.
Some exceptions are things necessary for normal life, that would be impossible to do in advance. A classic example is lighting a fire for heating (back when that was done with a pile of wood), and minor medical needs. (Major medical needs the Jew would violate the Shabbath and do himself.)
Getting high is not a necessity, and the fridge switch could have been taped before the Shabbath.
One could just as well state that if God had meant the loophole to be there, he would have mentioned it.
A big chunk of judaism has always centered about cultural preservation. In a way, the careful crafting of ridiculous loopholes is a stronger indicator about caring that the law exists --ie, presereving the culture-- than blindly following it. And so it's allowed and celebrated.
("What happens when a culture that is built on the notion of being an opressed people finds itself in a position of dominance" is an interesting question and left as an exercise to the reader.)
I don't see how "caring that the law exists" equals to "preserving the culture" (at least not see it in a good way), or how it's not "blindly following it".
Does using a device that allows you to avoid walking up many flights of stairs really violate the spirit of a law prohibiting work on the sabbath?
The other workaround I had heard for this is to have a non-Jew hired specifically to stand in the elevator and push buttons on behalf of Jews on the sabbath. But they'd still have to speak the floor so the attendant would know what button to push, right?
If so, what if an elevator had basic voice recognition? Speaking the floor number to a machine is no more work than speaking it to an attendant, right?
Maybe this rule interpretation was originally made back when elevators generally had attendants and did require some expertise to operate (e.g. to stop at the right spots)? And then didn't get rolled back when it became essentially trivial?
It’s not quite as you say. There are more specifics involved than just ‘work generally or kindling a fire’ - but few people except religious Jews would care about the details.
Also, depending on the counterweight and the current load of the elevator, adding an extra person to it might tax the motor less even when ascending.
Today, it is universally accepted in Orthodox Judaism that direct active interaction with electrical appliances is forbidden on Shabbat. However, one may benefit from and "use" devices and automated systems set in place before Shabbat, including light timers, fridges, and heating plates.
To be clear: nobody is "tricking" God by using a Shabbat elevator. Rather, this maintains the special nature of the day within the parameters established by centuries of tradition and scholarship ultimately based on God's commandments, while facilitating navigating our modern world.
https://www.reddit.com/r/atheism/comments/ev3gy/excerpt_from...
That's not the way observant Jewish people look at it at all. You're assuming that these workarounds are not "following the spirit", but according to them, the workarounds are as much a part of the spirit of the law as the law itself.
Perhaps it appears that way to you, but what do you know about the 'spirit' of Jewish law compared to generations of life-long practitioners and rabbis?
When I visited Korea, I've noticed companies tend to have exact 12-1PM lunchtimes, all at the same time. People raise eyebrows if you leave at 11:50 and return 12:50.
At 12PM, it's hard to grab an elevator going down, so people will press the "up" button to try to catch an empty elevator, then ride it to the top then down to the ground. Vice versa for 1PM.
It just seems so inefficient to do it that way? In theory, I guess the company sorta benefits from having everyone on/off at once, but doing it like that basically guarantees traffic jams.
can you say something though?
Park at top, open doors, wait for traffic down, return up.
Korea Lunch 1 would park at top for people leaving for lunch, 2 would park at bottom for people returning?