Elevator Instructions—Bagel&Coffee

Before we start, there are some questions to ask. How many floors are there in this building? Is there only a single elevator such as in the Administration Building, or two elevators such as in the Finance Building? Are there pairs of elevators such as in hotels or casinos, where when one is leaving their parking garage, they enter an attached vestibule with pairs of elevators flanking both sides?

I could conceive of people smart enough to program an elevator to dynamic and automatically be able to work in whatever building it is installed into. I should mention that a dynamic program that needs no modification and figures everything out on its own, is probably above my abilities, especially in the case of a building with many elevators.

It was not against the rules of this assignment to study elevators in the wild, so I observed the behavior of the elevators in the Finance Building for 20 to 30 minutes while eating breakfast. I will be writing instructions based on their specific use-case and using their environment to fill in the environment for the questions I asked earlier. Four floors, two elevators, 3 Up-Buttons, 3 Down-Buttons.

Lastly there are some assumptions. Mechanically, the elevator is properly indexed, whereby it stops at specific intervals that align its floor with the building’s floor to be perfectly leveled (aka you won’t trip), and that at these intervals there is a sensor that can detect if there is an elevator at that sensor’s floor (This could be as easy as installing a laser, and when the laser is broken by the elevator passing though, the sensor will send a signal to a central control system, though I suspect that elevators are advance enough to not need the laser detection system from Mission Impossible 2). The sensors will hold a Boolean value of True or False. The elevator shaft will have a sensor at each floor that will register as True if the elevator is at that proper position in front of the sensor to unload its passengers and False if it does not detect an elevator. Then all of this is applied per elevator and elevator shaft.

Instructions

Start up (initialize software, hardware calibrates)

When in idle state, listen on all wires for summons via button presses.

*1st Floor Up Button pressed*

Get the value of the button pressed in.

Info returns as Up Button One. (Find which wire is hot.)

Add to Que Log. (In case buttons on multiple floors are hot, we need to make a first come first serve wait-line.)

Address Que Log in order of summons received. (In this case we will simply only have one item in que to read, which will be the summons to floor one)

(The next several steps below are to add to optimization, in this case reduce wait times by finding the elevator closest to your location, to then send to you.)

Run though Idle Elevator Array, get the location of which floor every idle elevator one is at. Store values in temporary At Floor Array.

Run though At Floor Array, determine the difference between the floor elevator one is at and the floor of the button press, determine the difference between the floor elevator two is at and the floor of the button press. Store the value of these differences in Array Difference. (This can yield positive or negative values depending if the elevator being evaluated is above or below the target floor.)

Perform a search of Array Difference and return the address of the cell with the lowest value as an absolute (remove negative values). Take note of the address of the lowest absolute value returned, and summon the elevator the same address in the Elevator Array

(Arrays can have their values or the subscript that points to the cell in an array where a value is held back to requesting lines of code. The key here is to line up all arrays so you can match values in meaningful ways. Example Elevator [two]’s current floor stored in Idle Elevator Array’s address [two]. At Floor Array’ address [two] stores where Elevator [two] is at. The difference for elevator [two] is stored in Difference Array at its address [two]. You can organize all arrays so that you can see relevant information about an elevator of the same “suffix” as a key.)

To the “winning elevator”, using your non absolute value as a guide, if you had a positive number in the address of the Difference Array, please ascend to the target floor of the summon. If your value was a negative value in the Difference Array, please descend to the target floor of the summon.

While an elevator is descending it receives the Descending Status attribute. Elevators are to read only the down button presses in the Que Log at each floor. If the floor they are at matches to a floor where a Down Button has been pressed, then stop at that floor, open doors, then proceed to normal operation.

While an elevator is ascending it receives the Ascending Status attribute. Elevators are to read only the Up button presses in the Que Log at each floor. If the floor they are at matches to a floor where an Up Button has been pressed, then stop at that floor, open doors, then proceed to normal operation.

If your value in Difference Array was 0 and elevator was idle from the start, skip ahead to opening your doors since you are idling at the correct floor already. (Chances are if this is the first summon of the day, after a restart, the elevators will already be at floor 1 by default and can skip steps to opening doors.)

When the elevator using a request via the Que Log arrives at the floor it was originally intended to, send message back to the que log, so that it may remove this request from the Que Log.

Open Door protocol

Open doors, pause for 10 seconds, close door.

Interruption

If interruption panel between doors is receives pressure re open doors, pause for 10 seconds, close door. Loop until doors close successfully.

Floor selected using internal Elevator buttons.

*The button for Fourth Floor was pressed*

When an internal button is pressed save this value into a variable known as Anchored Floor, evaluate whether the number of the button pressed has a higher or lower value than the floor the elevator is currently stationed at. If the floor selected has a higher value than the current floor the elevator is at, then use ascend. If the value of the floor selected is lower than the current floor, then use descend.

If multiple buttons to select floors have been pressed (those jerks that press every button in the elevator to ruin everyone else’s day or as a prank) then the internal Floor Que will come into use, whereby each floor the specific elevator needs to stop at will be logged (This log is not to be confused with the system wide Que Log which is in conversation with all elevators).

While en route to the Anchor Floor, inherit Ascending Status if ascending, and Descending Status if instead descending.

As before, the elevator will look at the Que Log on its way, stopping for appropriate passengers along the way to the Anchored floor (in this case ascending Up Button pressers we encounter while going up to the fourth floor); however, the elevator will additionally look at its own internal Floor Que for floor requests matching the floor it is at, and will stop at these floors and open its doors. When the doors close, remove the request from the internal Floor Que and the system wide Que log. (There may be a chance the elevator is full and someone can’t fit in, sorry my dude, you will have to press the up or down button again a get back into que. If your company is experiencing many traffic jams, try installing more elevators.).

Once the elevator has reached the Anchored Floor it will open it will stop and open its door, wait ten seconds, then close doors. With the strategy I am using with Anchor Floors, on the Elevators way up, it may have had opportunities to disgorge its passengers along the way (and removing request for summons from ques). The elevator will look at the next request in its Floor Que and assign that as its new Anchor Floor. It will follow all previous instructions until it has exhausted its floor que, at which point it becomes an Idle elevator and will go back to the beginning of these instructions.

(For example, passengers embark on an elevator at floor two. A businessman presses floor 4. Then a snot nose kid decided it’s funny to press all the buttons in, first pressing 1, then 2, then 3, then 4. The floors are logged in the order they are pressed: 4, 1, 2, 3. An elevator button can only be responsive one time, the kid pressing 4 again does nothing, the button will not be useful again until the 4th floor upon which it reactivates. The Elevator takes the first number in que 4, and heads up to that floor. It stops at 3 opens, and removes 3 from the que. The que now looks like 4,1, 2. The Elevator arrives at floor 4, the business man gets off, the que now looks like 1, 2. The elevator having achieved its goal of getting to the Anchored Floor, now looks at its internal que, and selects the next anchor floor, that being 1. The floor descends from the top floor and stops to open at 2. The que updates to 1. The elevator goes down to floor 1, the kid gets off and lives happily ever after. The elevator now returns to idle state.)

Optimization

To reduce wait times. Elevator one, after idling for 1 minute, returns to the ground floor. Elevator 2 after idle for 1 minute, does nothing. (If someone wants an elevator at floor 1, one of the most popular floors for new people to arrive, there will hopefully be one waiting for them already. Elevator 2 will on average be on floor 3, thus reducing wait times for popular floors people are already on such as 2 3 or 4. If elevator 1 and 2 was recalled when in idle state, than wait times for floors 1 and 2 would be low, but wait times for floors 3 and 4 would be high.)

Even with this system there still is some issues, for example having someone stand in the elevator door, would cause an infinite loop of opening and closing and effectively take the elevator out of commission, but there is not much, and elevator can do about that without its programmer going to jail. Additionally, I would need to run tests or simulations to see if the “logic” for two separate ques interfere with each other in unforeseen ways.

This entry was posted in Bagel&Coffee, Elevator Instructions. Bookmark the permalink.

1 Response to Elevator Instructions—Bagel&Coffee

  1. davidbdale's avatar davidbdale says:

    Your work is astonishing and very much appreciated, Bagel&Coffee. I love the accidental poetry of language forced to address particular audiences. Here, I’m particularly fond of “Loop until doors close successfully” for the way it condenses several contingencies into 5 words.

    Also: “The Queue Log is in conversation with all elevators.”

    Bravo to you for field research and for taking on the needlessly added challenge of instructing a two-elevator array. I presume you do this for your own entertainment, but if it’s for mine, too, then thank you again. It was thrilling to watch the elevator weigh the competing Queues.

    I do question the relevance to the elevator’s operation of the significance of stating that the “floors are logged in the order they are pressed.” Clearly the elevator does not respond to requests in that order, so what is the significance, to anyone, of the logging-in order?

Leave a reply to davidbdale Cancel reply