Wednesday, February 8, 2012

Boarding Airplanes Simulation

In lack of anything deep to write about, I decided, wait... In spite of the overwhelming amount of deep topics to write about, I decided to write about this project I'm doing in one of my classes: I'm writing an airplane boarding procedure simulator. It is only a small project, and it is due this Thursday. It is nothing big, just fairly interesting.

(Strangely, there has also been a request for technical material on the blog)

If you have ever travel by air on a regular basis, you most certainly have wondered at some point or another why boarding the plane isn't more efficient. Well, I certainly have. Whenever I have to wait for a guy to store his luggage in the overhead bin, and there is plenty of room behind him, I get this sense that I should have boarded first. But how much time can we possibly gain by boarding in a non-randomized order? Well, this simulator aims to compare different strategies.

To start off, let us create a plane with seats and an aisle, and then let the aisle extend out of the plane and up to that boarding arm hallway thing that takes passengers between the airplane door and the actual terminal building. Then we fill up this arm with a line of passengers; each passenger is given a ticket, either at random, or sorted by whatever algorithm.

Now that we have lined all the passengers up outside the aircraft, each passenger will try to move towards their seat; at first, however, only the very first person in line can actually move! So what do the other people do? Well, they wait until the person in front of them has moved away, which of course takes some time. Then the next thing to consider is when a man has reached his row, he will use extra time to sit down, holding up everybody waiting to get past this point, and also holding up those waiting to get to a row that is occupied by the line of people waiting to get past that man who was sitting down. Now, if the man has a window seat, it may take longer if there is another passenger sitting down at the aisle seat...

It all turns out to be a big scheduling problem, but it is also a somewhat interesting model; each individual person exists inside the plane (in the aisle or in a seat), but it is also the actions of the individuals that change the state of the plane. The individual persons themselves will schedule their own actions based on their target seat and their environment, and some actions (i.e. movement) will change the state of the plane as well as the passenger. Actually, it turns out that most actions are simply to schedule a rescheduling while waiting for something to happen. It is like, writing down in the calendar that one ought to update the calendar. It all got juggled up in my head, at least...
I do have it working by now, but not elegantly, and I haven't generated any interesting line orderings yet. We'll see how it goes. Also, it has clearly been a while since the last time I used Java, so referring to the notes of my old introductory course has been invaluable. So what is the most efficient way to board a plane? I might find out tomorrow.


  1. Here's my hunch: First of all, enforce the "only one piece of hand luggage" rule. Then
    board all passengers with window seats, from back to front, then passengers with aisle seats, back to front. Can it get any simpler?

  2. The simulation reveals that boarding from back-to-front takes a total of 2532 seconds, whereas boarding window-to-aisle (each seat letter back-to-front) takes 905 seconds. This is to say that boarding window-to-aisle is 2.8 times faster than boarding back-to-front. A completely random boarding procedure usually takes an around 1500 seconds.