Skip to content Skip to sidebar Skip to footer

Determine Waiting Times Between Plane Arrivals Python

I'm writing a program, that takes 200 planes distributed with the poisson distribution over 12 hours and these planes need to land at an airfield that only has 1 runway. I use the

Solution 1:

This is a single-server queueing system, where the server is the runway. General discrete event systems such as this can be programmed using event scheduling, based on a priority queue to determine what's the next thing to happen. You can read the PDF file at this github repository for a fairly complete discussion.

However, the single server queue has purely sequential logic and can be implemented as a loop using the following recurrence relations:

  • arrival_timei ← arrival_timei-1 + interarrival_timei
  • start_landing_timei ← max(arrival_timei, finish_landing_timei-1)
  • finish_landing_timei ← start_landing_timei + landing_timei

In words, from a plane's perspective

  1. you have an arrival event interarrival_time time units after the last plane arrived (this is your Poisson process);
  2. you can start landing procedures either when you arrive, or when the previous plane finishes landing, whichever comes later; and
  3. the landing is actually completed landing_time time units after you started landing.

You can initialize the imaginary zero'th airplane's arrival_time and finish_landing to be 0.0, put the logic outlined above in a loop, and iterate through either the specified number of aircraft or until the stopping time is reached. Since the logic is purely sequential, you can lose the indices and just recycle the variables. In pseudocode, and assuming that interarrival_time() and landing_time() are iterators which cough up the corresponding next value on demand:

N = 200    # number of airplanes
arrival_time = finish_landing = 0.0
N times:
    arrival_time += interarrival_time()
    start_landing = max(arrival_time, finish_landing)
    finish_landing = start_landing + landing_time()

The aircraft's delay is either start_landing - arrival_time if you're interested in how long the plane spent "in line", or finish_landing - arrival_time if you want to know how long the plane was "in the system". Place the corresponding statement in the appropriate location in the loop, and use the resulting data however you see fit.


Post a Comment for "Determine Waiting Times Between Plane Arrivals Python"