Disclaimer: you indicate no problem with your DEQ class, so I didn’t read through it.
It may help to draw pictures:
Arriving airplanes
^__A_ ------------------------
V ^__A_ ^__A_ ^__A_
V V V Airplanes leaving the queue to land
------------------------ ^__A_
Airplanes in Queue V
============================== |
Other information associated with each airplane:
• Time the airplane arrives (and enters the queue)
• Time the airplane begins to land (and exits the queue)
Needed:
• Random arrival time, normal distribution spanning ∆T minutes
• Time it takes to land ("service time"), TLanding
• Simulation time: Tmax
Queue/dequeue:
• Planes queue when they arrive
• Planes dequeue when they begin to land
Hypothesis:
Given two runways, you should be able to land 2 airplanes every TLanding minutes.
So then, to avoid congestion in the sky (buildup in the queue), you should ideally have an
airplane arriving every (TLanding / 2) minutes, on average.
More than that and the queue will fill up.
Less than that and the queue will empty.
Hints:
You’ll need a
running average. The average is (sum of time each airplane spent in queue) / (number of airplanes that went through the queue). To keep a
running average, save that division for last. Hence, you will need two pieces of information to update each time you dequeue a plane.
For the simulation, you will need to keep track of the time == the number of minutes that have passed since the beginning of the simulation.
Do it in two passes:
1. arrive and enqueue a bunch of planes
(generate a whole bunch of ∆T (and enqueue) while their sum < Tmax)
2. land all the planes in the queue
(update the current time to the next available runway time,
dequeue a plane and update the running average,
reset the runway’s next available time to the (current time + TLanding))
while current time < Tmax
Compute the average and display it to the user.
Your assignment does not give instructions on what to display to the user, but the average is minimal. You might also want to display the number of airplanes still in the queue at the end of the Tmax time.
Check that various runs work as hypothesized above.
Hope this helps.