{'fraction_non_alphanumeric': 0.025083544711519103, 'fraction_numerical': 0.007730402222490639, 'mean_word_length': 4.733610341643582, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Towards the Next Generation Airline Revenue Management: A Deep Reinforcement Learning Approach to Seat Inventory Control and Overbooking

Revenue management can enable airline corporations to maximize the revenue generated from each scheduled flight departing in their transportation network by means of finding the optimal policies for differential pricing, seat inventory control and overbooking. As different demand segments in the market have different Willingness-To-Pay (WTP), airlines use differential pricing, booking restrictions, and service amenities to determine different fare classes or products targeted at each of these demand segments. Because seats are limited for each flight, airlines also need to allocate seats for each of these fare classes to prevent lower fare class passengers from displacing higher fare class ones and set overbooking limits in anticipation of cancellations and no-shows such that revenue is maximized. Previous work addresses these problems using optimization techniques or classical Reinforcement Learning methods. This paper focuses on the latter problem - the seat inventory control problem - casting it as a Markov Decision Process to be able to find the optimal policy. Multiple fare classes, concurrent continuous arrival of passengers of different fare classes, overbooking and random cancellations that are independent of class have been considered in the model. We have addressed this problem using Deep Q-Learning with the goal of maximizing the reward for each flight departure. The implementation of this technique allows us to employ large continuous state space but also presents the potential opportunity to test on real time airline data. To generate data and train the agent, a basic air-travel market simulator was developed. The performance of the agent in different simulated market scenarios was compared against theoretically optimal solutions and was found to be nearly close to the expected optimal revenue.


A. Motivation
Few markets are as fiercely competitive as the current air travel market. This heightened competition dates back to the deregulation of the airline industry in 1978, which allowed US airlines to freely set up their route network and quote fares for their itineraries. Since then, airline corporations have been relying on Revenue Management (RM), a decision support system designed for maximizing the total expected profits generated from all their flights [1]. RM systems use differential pricing to determine a range of fare classes and their fare levels to exploit the differences in WTP of passengers in any given Origin-Destination (O-D) market. A combination of varied restrictions and service amenities is used to create separate fare classes. Then, for a given set of fare classes, aircraft capacity and schedule, RM systems use yield management or seat inventory control for allocating seats to each of the fare classes to protect seats of higher fare class passengers from lower ones. Also, in order to prevent losses in revenue due to certain customers cancelling their tickets or not showing up, airline corporations overbook their seats. But, if the overbooking process is not done optimally, it leads to situations where the number of passengers showing up for the flight is more than the seats in that fare class. Subsequently, a few passengers have to be denied boarding. This leads to airlines facing losses in at least one of the two ways. Firstly, the displaced passenger(s) have to be compensated for their distress in the form of expensive vouchers. Secondly, if the passenger isn't adequately compensated it leads to a goodwill cost [4]. These two costs combined is referred to as the bumping cost in this paper.
The combined problem of seat inventory control and overbooking has been examined in this paper. Conventional seat inventory control techniques and overbooking models are strongly affected by the accuracy of the forecasting process and the mathematical modeling approach. Modeling the problem as an MDP and using Reinforcement Learning (RL) can overcome the limitations of conventional yield management techniques for it doesn't require any modeling or forecasting. Additionally, the convergence to optimal solution is an inherent property of RL. However, this typically requires huge amounts of data to train the agent [11]. This paper overcomes this barrier by implementing a Deep Q-Learning (DQL) Network which can learn by interacting with competitors and customers.

B. Related Work
Howard addressed the overbooking problem assuming the airline didn't divide the cabin into different fare classes. The problem was modelled as a Markov Decision Process (MDPs) and the optimal policy was found using the value iteration algorithm. However, the computational limitations of the value iteration algorithm made this technique unfeasible to implement on large problems [2]. Brumelle et al. tackled the seat allocation problem for several fare classes using the Expected Marginal Seat Revenue (EMSR) technique, a popular model used by the airline industry. The problem was formulated on the assumption that ticket requests for high fare classes are placed after the requests for lower fare classes have been made [5]. Lee et al. explored the seat inventory control pertaining to airlines. The problem of optimally deciding on booking requests for a booking class at a specific time was investigated. Dynamic programming was implemented to arrive at an optimal policy. Also, they discarded the assumption made earlier regarding arrival patterns. However, they do include overbooking, cancellations and no-shows in their model [6]. Subramanian et al. also addressed the seat allocation problem for several fare classes while taking into consideration the possibility of overbooking, cancellations and absentees on the day of the flight. The problem was modeled as a discrete time Markov Decision Process and an exact solution was found using dynamic programming through backward induction. The algorithm was implemented on a real-life airline dataset confirming its computational feasibility. However, their model was based on the assumption that probability of cancellations wasn't dependent on fare-classes [3]. Gosavi et al. formulated a similar problem with two major differences. They didn't assume that cancellation was independent of fare classes. Additionally, the problem was modeled as a Semi Markov Decision Process (SMDP) instead of MDP. They developed a novel algorithm λ-SMART to solve the SMDP. The algorithm was compared against EMSR and it was found to outperform EMSR [4].
The remainder of our paper is organized as follows. The theoretical basis of our work has been described in the background portion. Thereafter, the problem description section elaborates on the MDP formulation and the simulator used to generate our data. Subsequently, the techniques used to solve the MDP and the outcomes are given in the solution and results sections.

A. Markov Decision Process
A Markov Decision Process [13] is generally composed of four components: a set of all the states referred to as state space , ( ∈ ), a set of all actions given by the action space , ( ∈ ), a reward function , and a transition function ( , , ′ ). At time , the agent chooses a specific action depending upon the current state, following the Markov assumption. Subsequently, the agent probabilistically progresses into a new state according to the action taken and the present state which results in the agent receiving a reward . A discount factor is generally included in this process that so that immediate rewards are valued more than rewards that could be obtained in the future. It also prevents the sum of rewards from becoming infinite. The solution of an MDP is a policy , which deterministically maps the state to an action.

∶ S → (1)
Therefore, the optimal policy * for a MDP can be defined as one that leads to the attainment of maximum cumulative expected rewards [12]. (2) B. Q-learning Q-Learning [7] is a popular technique to determine the value of performing an action while in a specific state. The algorithm iteratively returns Q-values by implementing incremental estimation in the direction of the observed reward and estimating future rewards from the subsequent state ′. In order to ensure that the model converges to the optimal value, some amount of exploration is required depending upon the known information of the environment [12]. The optimal action at each state is the one that maximizes the state-action value.

C. Neural Networks
Many real-world problems have a large state space, where it is impossible to record values for every state and action pair. Furthermore, the agent would not be able to visit all states. So, state-action values that have not been encountered needs to be generalized. This can be done using neurons, also known as perceptrons, to approximate the state-action values [8]. A perceptron consists of three components: input nodes 1: , weights 1: and output node . Combining the idea of approximating state-action values using perceptrons and training the agent with Q-learning resulted in a popular approximation method known as perceptron Q-learning.
An inherent drawback of perceptron is that it can model only linear functions. However, a set of perceptrons can be combined to form a neural network which can approximate nonlinear functions. Non-linearity is introduced using activation functions. Sigmoid, Tanh and ReLU are commonly used activation functions. A neural network possesses an input and an output layer with hidden layers between them. The backpropagation algorithm is usually used with neural networks for mitigating the loss function, given by the temporal difference error, to learn the appropriate features and weight [12]. According to the universal function approximation theorem, a feed-forward neural network with one hidden layer, given sufficient neurons and mild assumptions on the activation function, can approximate any real continuous function. Cybenko was one of the pioneers in proving this theorem for sigmoid activation functions [14].

D. Deep Q-Learning
Like perceptron Q-learning, DQL also combines the idea of using an approximator and Q-learning. But, instead of using a perceptron, a deep neural network is used. Equivalent to a multilayer perceptron, the deep neural network has several hidden layers, resulting in a large number of biases and weights as its parameters. Q-learning with backpropagation is used to update the parameters of the neural network such that the loss function is minimized [10]. Since the generation of the succeeding Q-values and the updating of the present Q-values is done by the weights of the same network, other Q-values estimates in the state-action space can also get erroneously updated [9]. DQL mitigates this issue by employing the following approaches. Firstly, the set of experiences are stored and during training they are sampled uniformly. Secondly, the primary network is updated by a different network, preventing the performance issues that arise when the generating and updating is done by a single network. Lastly, every parameter is provided with a robust learning rate, alpha, which is updated after taking into account its preceding values [10].

A. Problem Statement
For every flight, the optimal seat allocation and overbooking limits for each fare class needs to be determined such that revenue is maximized. Uncertainty in customer booking request arrivals of each fare class in each flight makes this problem a stochastic one. Moreover, customers typically request bookings at different times prior to any given flight departure. For each booking request, the airline can either accept or deny it. So, a series of actions need to be taken at different points in time till the date of departure, which makes this problem a sequential decision making one. Taking these facts into account, the seat inventory control and overbooking problem has been modeled as a MDP, where the agent does not know the transition and reward models. To find the optimal policy, the agent needs to learn through experience represented by state transitions and received rewards. The data to generate this experience is obtained using an air travel market simulator.

B. Air Travel Market Simulator
In order to train the agent, an environment was created to simulate the arrival of passengers of different classes wishing to book tickets for the flight. Customers are allowed to reserve seats 1000 days prior to the flight departure. Each class of passengers was simulated as an independent Poisson process. Each test case can specify the expected number of passengers to arrive for a given class. In order to simulate their arrival an exponential distribution is sampled whose mean is the ratio of total time to expected number of passengers. Sampling the exponential distribution gives a list of inter-arrival times, which can them be assembled into a list of timestamps at which passengers arrive. This process results in the number of passengers from each class being distributed according to a Poisson distribution. If a passenger arrives, then the cancellation probability will randomly set whether or not the passenger will cancel at a later time. The time at which the passenger cancels is uniformly distributed along the remaining time before the flight. Therefore, each episode or flight will consist of a list of potential passengers, their class, their booking time, if they will cancel, and if so at what time they will cancel.
Given this data the optimal reward possible can be computed. The optimal policy will be to accept all of the passengers from the highest fare class, and then the lower fare classes in descending order until the capacity is filled or all of the passengers have been accepted. The optimal reward is then just the fares applied to these passengers. The agent cannot achieve the optimal reward as it requires knowledge of future cancellations and future arrivals, however this can be a useful metric to gauge how well the agent is performing.

State Space
The state space ( ) vector contains the information generated during the booking process regarding the airline seats. It includes the travel class of the latest customer ( ), seats that have been sold for the nth class ( ) and the time remaining for the ticket booking process to end ( ).

= ( , 1 , 2 , … , , )
A typical state can be illustrated by the following example. A customer requests a middle class seat 40 days prior to the departure. Additionally, the inventory shows that the number of seats booked in the high, middle, and low fare class are 2, 20 and 20 respectively. In this case, the state space can be given by (2,2,20,20, and 40). The state variable is continuous while the rest is discrete.

Action Space
At every time step, exactly one of the two decisions, accept +1 or deny −1 can be made. The action space ( ) is given by:

Model Dynamics
The state space gets updated by the occurrence of any one of the following events: 1) customer arrival, 2) cancellation and 3) flight departure ( = 0). Once the terminal state is reached, all actions will lead to the ending of the episode. Actions need to be taken only when a passenger arrives. The agent is said to be in a decision-making state at that instance. When a booking request is accepted, the seat for the corresponding fare class gets incremented by one. When it is denied, the seat for the corresponding fare class gets decremented by one. In both cases, several cancellations in each fare class, following an uniform distribution, may have occurred since the last decision-making state. The corresponding number of seats must be deleted from the corresponding fare classes to get the updated state.

Reward Function and Discount
The reward function gives back the fare associated with the passenger's class if accepted or zero reward otherwise. Also, if a passenger has canceled since the last decision, then the fares of the passengers that cancelled will be subtracted from the reward. At the time of departure, if there are more passengers booked than there is capacity on the plane, then the airline will have to bump some of the passengers in descending order of fare classes. Higher-class passengers will be bumped first as they are typically not flying on a multi-leg itinerary. The cost of bumping a passenger is considered to be some multiple of the passenger fare. This multiplication factor will be adjusted to test different cases. The fares for each class have been set at $300 for the high class, $200 for the middle class, and $100 for the lowest class. These fares for each class ( ) were set based on a flight from Chicago to New York, whose fares ranged from $100 -$300. The rewards received for each action are given below, where represents the number of cancellations that has occurred since the last state, the bumping cost, and the number of passengers bumped of fare class .

IV. Solution Method
In order to learn a policy for seat inventory control and overbooking, a DQL agent was trained and tested in an air travel market simulator as depicted in Fig.1. We implemented DQL using the Keras [15] and Keras-rl [16] packages in Python. Keras is a high level neural network package for Python, and Keras-rl is a reinforcement learning package built on top of Keras. In Keras we created a neural network model. The neural network consists of an input layer, several hidden layers, and an output layer. The input layer contains one node for each variable in the state space. The output layer has one node per action. The hidden layers then connect the input and output layers with various weights and activation functions. The neural network is approximating the function Q needed for Q-learning. Based on the output of the neural network the agent can decide which action to take. The first 6 hidden layers in our model were an alternating series of dense and Relu activated layers. Each layer contained 16 nodes. The last hidden layer has only two nodes that linearly activate the output layer. The structure of the neural network is depicted in Fig. 2.
In Keras-rl, we were then able to define a DQL agent that would use the model to learn the proper policy. We set the exploration policy of the agent to be a linear annealed epsilon-greedy policy. In an -greedy policy, the agent chooses a random action with probability  or chooses greedily with probability (1-). In the linear annealed version of this policy the value of epsilon changes as the agent learns. In our case epsilon started at 1 and then linearly decreased to 0.1. So, the search policy started as purely randomly choosing actions and then ended choosing in a mostly greedy approach. The Keras-rl agent then interacts with the data generated previously to update the neural network according to the Q-learning algorithm.

V. Results
Several different test cases were used to evaluate the solution method. In all of these cases the capacity of the plane is 80 and the expected number of passengers wanting to book is 100. This forces the agent to always have to deal with overbooking and accepting everyone will not be a viable policy. Three different class distributions of passengers were tried. The three different class distributions are [10,30,60], [60, 30, 10], [33,33,34]. For example, [10,30,60] means that on average 10 high class passengers, 30 middle class passengers, and 60 low class passengers will want to book. Again, each of these is modeled by a Poisson process, so each episode will vary in the actual number of passengers. We tried three different cancellation rates, 0%, 10%, and 20%. Also, we varied the cost of bumping passengers who were overbooked. We examined the cases where the cost was 1.5, 2.0, and 2.5 times the fare cost.
For each of these cases, 2400 episodes of data were generated and the agent was trained on these data sets. After training, the performance of the agent was evaluated against the optimal performance. Despite having any knowledge of the number of passenger arrivals of each fare class, the agent was still able to learn from experience and achieve near optimal results. The reward is expressed as a percentage of the optimal reward that the agent achieved, so for a reward of 0.87, the agent achieved 87% of the maximal reward. The average acceptance describes what percentage of the passengers were accepted. We know that without cancellations the flight can only accept 80% of the interested passengers on average. Therefore the acceptance rate should be around 80% plus the cancellation rate, so that the final number of passengers is equal to the capacity. The average overbooking describes the percentage to which flight was either under or overbooked. Theoretically, the reward is maximal when the plane is just filled to capacity without any passengers getting bumped. If the plane is overbooked then average overbooking will be positive and there will be some bumping cost.
A couple of interesting results can be seen from the table below. First, in most cases the agent is able to achieve nearly 90% of the optimal reward. The acceptance rate shows that the agent was able to learn to overbook in such a way that the plane would be full after cancellations. The agent accepted 80% when no cancellations occurred, approached 90% when 10% of passengers cancelled, and accepted around 94% of passengers when the cancellation Q(s, a+1) Q(s, a-1)

State Variables
Hidden Layers rate was 20%. Also, as the cost of bumping increased the overbooking of the plane tends to decrease. This makes sense as the agent should be more reluctant to overbook as it becomes more costly to bump passengers. The average reward also tends to decrease as the overbooking cost increases, because the agent is unable to fill the plane with all booked passengers.  Figure 3 shows how the agent learns during the course of training for the case where the bumping cost factor is 1.5, the cancellation rate is 0.1, and the fare class distribution is [10,30,60]. The red line in the plots represents the moving average. Predictably, at the start of training, the agent underperforms, achieving about 60% of optimal revenue by filling up the aircraft to about 60% and accepting 50% of booking requests. However, as the training progresses, the agent starts learning from experience as reflected by the results increasing towards the optimal values. A variability of about 20% in the quantities was observed throughout the training. It can be noted how the load factor levels out around 100% and the acceptance rate around 90%. This is because accepting 90% of the passengers will give about 80 passengers which just fills the flight to capacity. The seat allocation plot shows how the agent varied the seat inventory for each fare class with the number of training episodes.

VI. Conclusion
In this paper, a deep RL approach was used for airline RM in a single O-D market. The DQL agent achieved nearly optimal results in solving the airline seat inventory control and overbooking problem. A basic air travel market simulator was developed to model the demand distribution for multiple fare classes, concurrent arrival of passengers of each class with random cancellation in a given O-D market. A deep neural network was created to act as a global approximator of the Q function, and DQL was used to train an agent to make decisions about accepting or denying passengers' booking requests. The neural network was used to capture the nonlinearities of the Q-function in the large continuous state space. The agent was tested on numerous market scenarios. On average, the agent achieved up to 92% of the theoretically optimal reward and it was able to overbook properly so that the flight would be full after cancellations. The performance of the agent depended strongly on the bumping cost, and as the bumping cost increased the agent tended to be more conservative in accepting booking requests.
To embrace the full scope and range of aspects of the real-world airline RM problem, we are currently working towards training the agent on a network of interconnected O-D markets to tackle dynamic pricing along with seat inventory control and overbooking. The new set of actions allows the agent to vary the fares of the fare products with time till departure. Also, the action of denying booking requests has been replaced with withdrawing fare products for a given period of time. Using experience replay, other RL algorithms such as SARSA are being tested out. We expect our approach will reproduce similar successes in this endeavor as were achieved in this paper.

Episode Episode
Episode Episode Percentage of optimal reward Load factor Number of seats in each class Percentage of arrivals accepted