An airline can reconfigure the seating in an aircraft to respond to demand and to maximise revenue.
Question:
Class | No. of Seats | Row separation | Revenue per Seat | Minimum Rows | Maximum Rows |
---|---|---|---|---|---|
First | 4 | 1.98m | 9,541 | 0 | 3 |
Business | 8 | 1.93m | 6,133 | 3 | 20 |
Premium Economy | 10 | 0.86m | 692 | 2 | 41 |
Economy | 10 | 0.78m | 404 | 5 | 48 |
The aircraft the company uses have 45 metres of available space and a legal limit of 374 passenger seats.
One possible valid configuration is:
- 12 first class seats (taking up 3 rows and 5.94 metres)
- 56 business class seats (taking up 7 rows and 13.51 metres)
- 190 premium economy seats (taking up 19 rows and 16.34 metres)
- 110 economy (taking up 11 rows and 8.58 metres)
This configuration is valid as the total length is 44.37: there is no room for additional rows of seating. The number of passenger seats (368) is below the maximum of 374.
A. Write brute-force algorithm, in English, which will create list all of the possible configurations of seat rows for this aircraft. You may assume the constraints above have been defined. Step-by-step English algorithms
B.The code segment below defines a class which implements an abstract data type, Configuration, which represents a single configuration of the aircraft, storing the number of seats of each class.
Write a Python function to implement the function verify which satisfies the following specification: Function: verify Inputs: possible_configuration, a Configuration Preconditions: true Output: is_valid, Boolean Postconditions: is_valid is True if number of all classes of seats within possible_configuration are within the defined minimums and maximums and the total length required does not exceed the total length available and the number of seats does not exceed the maximum number of seats allowed. Otherwise, is_valid is False.
There are two tests at the end of the code you can use to test your code. You should add more tests yourself.
#Revenue for each seat class FC_REVENUE = 9541 BC_REVENUE = 6133 PE_REVENUE = 692 EC_REVENUE = 404
#Number of seats in each row for each class FC_SEATS_ROW = 4 BC_SEATS_ROW = 8 PE_SEATS_ROW = 10 EC_SEATS_ROW = 10
#Separation of each row for each class FC_SEP = 1.98 BC_SEP = 1.93 PE_SEP = 0.86 EC_SEP = 0.78
TOTAL_LENGTH = 45 #Total plane length MAX_PASS = 374 #Maximum passengers allowed
#Mininum rows allowed FC_MIN_ROWS = 0 BC_MIN_ROWS = 3 PE_MIN_ROWS = 2 EC_MIN_ROWS = 5
#Maximum rows allowed FC_MAX_ROWS = 3 BC_MAX_ROWS = 20 PE_MAX_ROWS = 41 EC_MAX_ROWS = 48
class Configuration: def __init__(self, fc_seats: int, bc_seats: int, pe_seats: int, ec_seats: int) -> None: """ Create a new Configuration of seats """ self.fc_seats = fc_seats self.bc_seats = bc_seats self.pe_seats = pe_seats self.ec_seats = ec_seats
def get_fc_seats(self)->int: """ Return the number of first class seats in the configuration. """ return self.fc_seats
def get_bc_seats(self)->int: """ Return the number of busness class seats in the configuration. """ return self.bc_seats
def get_pe_seats(self)->int: """ Return the number of premium economy class seats in the configuration. """ return self.pe_seats
def get_ec_seats(self)->int: """ Return the number of economy class seats in the configuration. """ return self.ec_seats
#Write your code here
#Finish writing your code here
conf1 = Configuration(12,24,50,90) #Valid conf2 = Configuration(4,3,3,3) #Invalid if verify(conf1) == True: print("Test 1: Valid") if verify(conf2) == False: print("Test 2: Valid")
C. The airline wishes to know how much revenue a particular configuration generates. Explain how you would adapt the class in part (b) to provide this information
D.Due to COVID-19 restrictions, each passenger must have at least 1.9 metres front-to-back space between them and the next passenger. There may be no more than 4 passengers in any one row. Explain how you could determine the viability of the aircraft being able to be flown at a profit. List any assumptions that you have made in providing your answer.
Management Science The Art of Modeling with Spreadsheets
ISBN: 978-1118582695
4th edition
Authors: Stephen G. Powell, Kenneth R. Baker