Airport Simulator

[Home]   [Puzzles & Projects]    [Delphi Techniques]   [Math topics]   [Library]   [Utilities]

 

Search

Search WWW

Search DelphiForFun.org

As of October, 2016, Embarcadero is offering a free release of Delphi (Delphi 10.1 Berlin Starter Edition ).     There are a few restrictions, but it is a welcome step toward making more programmers aware of the joys of Delphi.  They do say "Offer may be withdrawn at any time", so don't delay if you want to check it out.  Please use the feedback link to let me know if the link stops working.

 

Support DFF - Shop

 If you shop at Amazon anyway,  consider using this link. We receive a few cents from each purchase.   Thanks.


Support DFF - Donate

 If you benefit from the website,  in terms of knowledge, entertainment value, or something otherwise useful, consider making a donation via PayPal  to help defray the costs.  (No PayPal account necessary to donate via credit card.)  Transaction is secure.

Contact

Feedback:  Send an e-mail with your comments about this program (or anything else).

Search DelphiForFun.org only

 

 

Problem Description

This Airport Simulation problem is from one of my favorite books "Data Structures in Pascal" by Ellis Horowitz and Sartai Sahni.  Here's an abbreviated description:

Simulate an airport landing and takeoff pattern. The airport has 3 runways, two primarily for landing and one mainly for takeoffs.  There are  two arrival holding pattern queues for each of runways 1 & 2 and three departure queues, one for each runway.  The queues are to be kept as close to the same size as possible.

At each time step, 0-3 planes may arrive at the landing queues and 0-3 planes may arrive at the takeoff queues. Each arriving plane has from 0 to 20 time units of fuel remaining. Each runway can handle one takeoff or landing at each time slot. Runway 3 is to be used for takeoffs, except when a plane is low on fuel. At each time unit, planes in any landing queue whose remaining air time (fuel level) has reached 0 must be given priority over other takeoffs and landings. If  one plane is in this category, Runway 3 is to be used. If more than one, then the other runways are also used (at each time at most 3 planes can be handled in this way).  Arriving planes must be placed at the end of queues. 

The output should clearly indicate what occurs at each time unit:  queue contents, average wait times, average fuel remaining on landing, and number of planes landing with no fuel reserve.  Use a random number generator to generate the inputs. 

Background & Techniques

I wrote this program this week thinking that it would make a good simple introduction to discrete event simulators.    I turned to be not so typical - discrete event simulators usually have a "future events" queue with timestamps that drive the simulation.  This problem has a fixed time stamp increment  with a random number of events occurring for each step.  But it's an interesting exercise anyway.   

This problem is from the referenced book at the end of the chapter on linked lists. Queues are particular kind of lists where new items are always added to the tail end of the list and retrievals are (normally) from the front of the list.  

 List processing these days with Delphi , is simplified  since several list processing components are included.   I created objects TQObj and TRunwayObj  derived from TListBox in order to combine display capabilities with the other data fields.  The Items property of TListbox is a TStrings list object .   

I suppose that TQobj and TRunwayObj should be installed as visual components, but I dislike cluttering up Delphi with components that will probably never be used in another program.  I  solved the problem of getting display properties for a non-component by visually designing with Listbox components  to represent the queues and runways on the form.  These are  passed to the Create constructors for queues and runways, copying the visual properties (parent, location, size, font, and color)  and then freeing the listboxes.   

I also defined a TPlane object to contain information about arrival time,  id#, and fuel remaining.  Items (TStrings) has an Objects array that holds the plane objects while they are wait to land or takeoff.  The displayed strings in TQObj are the plane Id numbers.    For the runways, processing statistics for that runway are updated for display at each time step. 

The queues and runways are placed in arrays for ease of coding.   Most of the action is in the TimeStep procedure, if you understand it, the rest is mainly bookkeeping to accumulate and display statistics.    A second unit contains a memo object witht the complete problem description.

The program contains about 450 lines of code, just over my limit for Intermediate, so we'll call it an advanced.  

Running/Exploring the Program 

bulletDownload Source
bulletDownload executable 

Suggestions for Further Explorations

 It would be interesting to see the effect of changing the processing algorithm.    Notice particularly that maximum takeoff delays can be quite long for planes leaving from runways 1 or 2.   Maybe planes should be added to the departure queue with the shortest total wait time, not the fewest number of planes waiting.    Any other possibilities? 
It would be interesting to forgo the graphic layout and see the effect of additional runways,
There are 2 holding patterns for each of the 2 landing runways.  I don't see off hand that that is any better than one holding pattern for each runway.  Maybe I'll check it out one day.    If you answer this question first, let me know.
 
  [Feedback]   [Newsletters (subscribe/view)] [About me]
Copyright 2000-2017, Gary Darby    All rights reserved.