constraints

Logo

Materials for a constraint programming course

View the Project on GitHub xoolive/constraints

Airline staffing problem

Original lab session by Gérard Verfaillie.

This problem is about the staffing of an airline, i.e. assigning pilots and crew members to scheduled flights using a Constraint Satisfaction/Optimisation Problem (CSP/COP) solver (here facile). Three instances of the problem are given.

As a pure CSP modelling fails for the larger instance, we will solve it using a combination of CSP and Mixed-Integer Linear Programming modelling. You may refer to past classes with the PuLP library for basic usage.

Problem description

An airline operates a given set of flights between pairs of airports. Each flight must be staffed with two pilots and enough cabin crew members depending on the type of aircraft.

Each staff member must start its trip from his hometown (not before 12 am) and be back home in the evening (before 12 am). They must not fly more than a maximum number of flights per day, and more than a maximum amount of time out of home (from first take-off time to last landing time in addition to commuting time).

Each staff member may fly as a passenger if they just need to be transferred to another airport/city. They may as well be assigned to just stay home.

We will first search for a solution to this problem, then find the optimal solution that will maximise the money made by the airline by minimising the number of passenger seats assigned to staff.

Problem data

The following data are given:

Warning.

Index 0 in the tables printed below means “no flight”, associated to “no airport” and “no city”.

from airlines import tiny, small, normal
>>> tiny
{
    'Dda': 2,
    'Dmax': 7,
    'Dt': [[0, 0, 0], [0, 2, 25], [0, 25, 2]],
    'Dtinf': 25,
    'Dv': [0, 2, 1],
    'Na': 2,
    'Ne': 5,
    'Nec': [0, 2, 2],
    'Ni': 2,
    'Np': [0, 80, 80],
    'Nv': 2,
    'Nvmax': 2,
    'Ov': [0, 1, 2],
    'Pr': [0, 100, 100],
    'Ta': [0, 9, 13],
    'Td': [0, 8, 12],
    'Ty': [1, 1, 0, 0, 0],
    'Va': [0, 1, 2],
    'Vh': [1, 1, 1, 1, 2]
}

Paper and code submission

This project consists of two parts. You may submit one report for both parts, but please write two Python scripts.

Part 1: Basic resolution

First, define the variables of the problem. You may associate a variable to each flight taken by a staff member on a given day.

Part 2: A more efficient modelling with CSP and MILP

Since bigger instances will require too much computing time, let’s try something smarter:

  1. First use a CSP solver to compute all possible paths between cities;
  2. Then compare performances between a CSP and a MILP solver as we no longer assign staff members but groups of staff members to each path.

Warning.

Three instances are given (tiny, small, normal). Start debugging with the small instance; when it works, try the normal instance: you will be graded based on the results of the normal instance.