taocp

This site has no text of the book. Keep your own copy of TAOCP next to it. See what is checked.

Exercise · Volume 1 · 2.2.5-4

Exercise 2.2.5-4

not stated yet in Lean solution written

Rating24
KindInformal: the exercise has no formal statement, so Lean does not state it from the written solution
SectionSection 2.2.5 of Volume 1

The task

Say when the elevator would behave differently if the activity E9 were removed, and whether it could visit floors in another order.

The exact wording is in your copy of the book.

Hints

Open one hint at a time. Try the exercise again after each.

Hint 1

E9 is started in step E3 with a delay of 300 units, and E6 cancels it. What can keep the elevator from reaching E6 for 300 units?

Solution

Show the solution

Activity E9 sets D2←0D2 \leftarrow 0 and calls the DECISION subroutine. It starts 300300 units after the doors have opened, and it is cancelled when the elevator starts to move. Only if the doors stay open that long does E9 act at all.

That happens when many people get out, one after another, since step E4 spends 25 units on each. With twelve or more people at one floor the doors are open for 300300 units or more. If the state is NEUTRAL\mathrm{NEUTRAL} during this time, which happens when the elevator turned neutral at E2 although calls for other floors exist (see Exercise 3), E9 starts DECISION while nobody has yet entered. DECISION sets the state toward the lowest floor with a call, since the state is neutral. Then the elevator has a direction before the first person at the floor has chosen one.

Without E9 the state would remain NEUTRAL\mathrm{NEUTRAL} until somebody gets in, and in step U5 the first person to enter would set the direction by the chosen floor. So the elevator can really go in another direction, and so visit floors in another order. Suppose calls from floor 00 are waiting and the first person who gets in wants to go to floor 44. With E9 the state is GOINGDOWN\mathrm{GOINGDOWN}, and the elevator visits floor 00 first. Without E9 the person sets GOINGUP\mathrm{GOINGUP} and floor 44 comes first. The case is rare, and the author of the text calls it the most puzzling observation made on the real elevator.

Remarks

The variable D2D2 has another use: it makes the arrival of a new call run DECISION in step U2 when the elevator has stood still for 30 seconds or more.

This solution is drafted, and a person has not reviewed it yet. The source.

In Lean

not stated yet The exercise is not stated in Lean yet.

The status is computed from the Lean build. The node of the map.

Something is wrong? Report it.