QuestionQuestion

Problem Description
LAX is the world's fifth-busiest airport. It is therefore impossible to manually coordinate all of the planes that are trying to land, make sure there is an open gate for each plane upon landing, and again coordinate the planes trying to take off again. LAX’s air traffic controllers are asking for the USC CS department to design a program to help them do this job.
The problem starts with N airplanes flying over LAX, waiting to land, unload passengers, board new passengers, and take off again. Each plane has only limited fuel remaining, allowing it to stay in the air for at most R minutes. A plane must begin its landing procedure before its fuel runs out. The plane will arrive at a boarding gate M minutes after starting its landing procedure.
It will then take S minutes to unload passengers, refuel, board new passengers, etc. before it is ready to take off again. If the plane spends more than C minutes at the gate, the waiting passengers will complain, which must be avoided at all cost. Once the plane leaves the gate, it will take O minutes for it to finally take off and for the inflight beverage service to begin.

Unfortunately, LAX does not have enough runways or boarding gates to allow all of the airplanes to land, board, and take off whenever they want. Due to the crowded airspace and the limited number of runways, there can be at most L planes landing and at most T planes taking off at the same time. Also, there are only G boarding gates, and each gate can accommodate only one plane at a time.
The problem facing the air traffic controllers is to assign each plane in the air a time when it should begin its landing procedure and a time when it should begin its takeoff procedure. Each plane must have enough fuel to stay in the air until its assigned landing time, a gate to stay at before its time to take off again, and an early enough take off time so that its waiting
passengers do not complain.

Input Format
The input file name is “input.txt”.
<AIRPORT INFORMATION>: contains 3 integers, L G T , separated by spaces. The first is the maximum number of planes that can be landing at the same time. The second is the number of boarding gates in the airport, each capable of serving only a single plane. The third is the maximum number of planes that can be taking off at the same time.
<NUMBER OF PLANES>: contains one integer N specifying the number of planes. The next N lines will provide the information about each of the planes currently hovering over the airport.
<PLANE 1>: contains 5 positive integers, R M S O C , separated by spaces. R is the maximum number of minutes that this plane can keep hovering based on its remaining fuel. M is the number of minutes it takes the plane to reach its gate after initiating its landing. S is the number of minutes it takes the gate crew to serve the plane (unload passengers, refuel, board new passengers, etc.). O is the number of minutes it takes the plane to complete takeoff after leaving the gate. C is the maximum number of minutes that a plane can stay at the gate before passengers start complaining.
<PLANE 2>: Same format as Plane 1.
…...
<PLANE N>: Same format as Plane 1.

Output Format
Your program must output an output file “output.txt”. You need to print out N lines containing the assigned landing and takeoff times (in minutes) for each plane. The problem starts at time 0.
<ARRANGEMENT PLANE 1>: Each line contains 2 integers, A B , separated by a space. A is the time (number of minutes from the start) that you have granted this plane to begin landing. B is the time (number of minutes from the start) that you have granted this plane to leave the gate and this plane start to take off.
<ARRANGEMENT PLANE 2>: Same as the format for Plane 1.
…...
<ARRANGEMENT PLANE N>: Same as the format for Plane 1.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import enum

class State(enum.Enum):
    in_air = 1
    landed = 2
    gated = 3
    servicing = 4
    take_off = 5

f = open("input.txt", 'r')
line = f.readline()
L, G, T = line.strip().split(" ")
L = int(L)
G = int(G)
T = int(T)
N = f.readline().strip()
N = int(N)

planes = []
while True:
    line = f.readline()
    if not line:
       break
    R, M, S, O, C = line.strip().split(" ")
    R = int(R)
    M = int(M)
    S = int(S)
    O = int(O)
    C = int(C)
    dic = {'R': R, 'M': M, 'S': S, 'O': O, 'C': C, 'active': True, 'arrival': 0, 'departure': 0,
          'state': State.in_air, 'time_taken': 0, 'wait_time': 0}
    planes.append(dic)

planes = sorted(planes, key=lambda i: i['R'])
time_lapsed = 0


def curr_landed():
    n = 0
    for p in planes:
       if p['active'] and p['state'] == State.landed:
            n += 1
    return n


def curr_gated():
    n = 0
    for p in planes:
       if p['active'] and p['state'] == State.gated:
            n += 1
    return n


def curr_servicing():
    n = 0
    for p in planes:
       if p['active'] and p['state'] == State.servicing:
            n += 1
    return n


def curr_take_off():
    n = 0
    for p in planes:
       if p['active'] and p['state'] == State.take_off:
            n += 1
    return n


def check_landings():
    global time_lapsed
    max_landing = L - curr_landed()
    max_gates = G - curr_gated()
    max_plane_to_land = min(max_landing, max_gates)
    land_count = 0
    waiting_time = 0

    w = []
    if max_gates...

By purchasing this solution you'll be able to access the following files:
Solution.txt and Solution.py.

$75.00
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats