
Problem I: Monte Carlo Simulation
A) Overbooking Penalty
The above code performs a Monte Carlo simulation to determine the optimal number of
excess tickets that an airline should sell for a flight.
First, the code defines several parameters including the profit per ticket (Profit), ticket price
(Tixprice), the loss due to overbooking penalty for each overbooked seat (Loss), and the seat
capacity of the airplane (Seatcap).
Next, the code defines the simulate_revenue() function, which takes as input the number of
tickets sold and returns the revenue generated by a single flight. The function simulates the
number of passengers that will show up for the flight by binomial distribution, calculates the
revenue generated by selling tickets, and subtracts the penalty for overbooking if necessary.
The run_simulation() function is then defined, which takes as input the number of simulations
to run (num_simulations) and the range of values to test for the number of excess tickets sold
(num_tickets_range). The function runs the simulate_revenue() function for each value in the
range and calculates the mean revenue over all simulations. The mean revenue for each value
in the range is then appended to the results list.
Finally, the code runs the run_simulation() function with a range of values for the number of
excess tickets sold and plots the expected profit as a function of the number of excess tickets
sold. The optimal number of excess tickets is found using np.argmax() to find the index of the
maximum value in the results list, and print the result. The result is shown in the figure below.
Figure 1 Optimal number of excess tickets to sell
Thus, given the present circumstances, I plan to convince the boss to increase the number of
tickets sold by 20 each time, which would result in the highest possible profit of approximately
$44367.335 when assuming a passenger attendance rate of 90%.