Developing Data Products Course Project

Bill Seliger
May 11, 2015

Airline Revenue Optimization

This App uses the R lpSolveAPI package in a Shinyapp to optimize airline revenue based on two inputs from the user:

  • Demand for regular-priced seats
  • Demand for discount-priced seats

It then constructs a linear programming model using R code, solves the linear program with the lpSolveAPI package, and returns the objective - the maximum revenue given the selected demand for the two inputs.

Formulating the LP - Decision Variables

The LP is formulated with two decision variables

  • Number of regular-priced seats to sell
  • Number of discount-priced seats to sell

Formulating the LP - Constraints

The LP also has five constraints

  • Seats sold cannot exceed capacity of the plane (166 seats)
  • Regular price seats sold cannot exceed regular demand
  • Discount price seats sold cannot exceed discount demand
  • Regular price seats sold must be nonnegative
  • Discount price seats sold must be nonnegative

R code for formulating the LP

require(lpSolveAPI)
lprec <- make.lp(5, 2); regular = 150; discount = 100; invisible(lp.control(lprec, sense = "max"))
set.objfn(lprec, c(617, 238))
set.constr.value(lprec, rhs = c(166,regular,discount,0,0), constraints=seq(1:5))
set.constr.type(lprec, c(rep("<=", 3), rep(">=", 2)))
set.row(lprec, 1, c(1, 1), indices = c(1, 2))
set.row(lprec, 2, 1, indices = 1)
set.row(lprec, 3, 1, indices = 2)
set.row(lprec, 4, 1, indices = 1)
set.row(lprec, 5, 1, indices = 2)
dimnames(lprec) <- list(c("capacity","reg_demand", "discount_demand", "reg_positive", "disc_positive"), c("reg","disc"))

Viewing the LP formulation

print(lprec)
Model name: 
                  reg  disc         
Maximize          617   238         
capacity            1     1  <=  166
reg_demand          1     0  <=  150
discount_demand     0     1  <=  100
reg_positive        1     0  >=    0
disc_positive       0     1  >=    0
Kind              Std   Std         
Type             Real  Real         
Upper             Inf   Inf         
Lower               0     0         

Solving the LP

The solve() function solves the LP. Possible responses include:

  • [0] Optimal solution found
  • [1] the model is suboptimal
  • [2] the model is infeasible
  • [3] the model is unbounded
  • [4] the model is degenerate
  • [5] numerical failure encountered
  • [6] process aborted
  • [7] timeout
  • [8] the model was solved by presolve
solve(lprec)
[1] 0

The LP solution

## the objective is the optimal (maximum) revenue possible
get.objective(lprec)
[1] 96358
## the decision variables are the number of seats of each class the
## airline should sell to achieve the maximum revenue
get.variables(lprec)
[1] 150  16

To learn more about LP optimization

This problem is based on the lesson found here

MITx 15.071x The Analytics Edge

Airline Revenue Management

Information on the lpSolveAPI package can be found here

Package lpSolveAPI

lpSolveAPI Vignette