ICS 311 Fall 2006 Matt Freeburg freeburg@hawaii.edu Flight Itinerary Problem Formulation A schedule of flights between airports can be viewed as a weighted, directed multigraph, with the vertices representing the airports, the directed edges representing flights between them, and the weight of each edge representing the flight time of the corresponding flight plus the layover time at the departure airport. A path between a starting airport and a final destination airport represents a flight itinerary, with the total time of the itinerary being the total weight of all the edges in the path. As will be seen in the model below, this weight includes the time elapsed between a given start time and the departure of the first flight. For two edges e and f to be considered adjacent, the second edge f must originate at the same vertex that the first edge e terminates at, as in a typical directed graph. This constraint ensures that the next flight in the itinerary departs from the same airport that the previous flight arrived at. Additionally, we require two more constraints to determine adjacency. First, the flight represented by f must depart at a time that is later than the time at which the flight represented by e arrived. Secondly, the difference between the arrival time of e and the departure time of f must be great enough to physically allow the passenger to travel from the arrival gate to the departure gate. Given the above described graph and constraints, a starting airport, a final destination airport, and a starting time of the trip, we can attempt to find an itinerary of minimal total time elapsed since the given start time. We present the following model of the problem: Input: A weighted, directed multigraph G = (V, E) such that: 1) a set V of nV vertices with each vertex vi (1 ≤ i ≤ nV) corresponding to an airport, where nV is the total number of airports 2) a set E of nE edges, with each edge ei (1 ≤ i ≤ nE) denoted by (u, v), with u as the departure airport and v as the arrival airport (u, v in V), and each edge corresponding to a single flight, where nE is the total number of flights 3) a starting airport vs and final destination airport vf (vs, vf in V), and a starting time ts 4) a function A(e) that returns the airline ai (1 ≤ i ≤ nA) for edge e, where nA is the total number of airlines 5) a function Td(e) that returns the departure time of the flight corresponding to edge e 6) 7) 8) 9) a function Ta(e) that returns the arrival time of the flight corresponding to edge e a function C(v, a, b) that returns the minimum allowed layover time at airport v (v in V) with arriving airline a and departing airline b the weight w(f) of an edge f is defined as w(f) = ((Ta(f) – Td(f)) + (Td(f) – Ta(e)) = Ta(f) – Ta(e), where e is the edge previous to f in a path on G (e, f in E) two edges e and f (e, f in E) are considered adjacent iff i) e = (x, y) and f = (y, z), and ii) Td(f) – Ta(e) ≥ C(y, A(e), A(f)) Output: A path P = {e1, e2, e3, … , em}, an ordered sequence of m edges beginning at vs and ending at vf (e1 = (vs, x) and em = (y, vf)), where the total weight of P is minimized among all possible such sequences of all possible lengths beginning at time ts, with the total weight given by: m W(P) = ∑ (Ta(ei) – Ta(ei-1)) i=1 where Ta(e0) = ts. This model has some important features. First, there is one vertex for each airport and one edge for each flight. There may be more than one flight in the same direction between the same two airports, either at different times or the same time, with the same airline or different airlines. Flights that occur at a regular periodicity have an edge for each instance of the flight during the entire period of the flight schedule. So if a flight occurs daily at 7am, and the flight schedule represented by E covers a period of one week, then there will be 7 edges representing the daily instances of that flight. Second, the times Ta(e), Td(e), and ts are all absolute times elapsed from some arbitrary, defined start point in the past. Taking differences between these times gives a time duration between the two events they mark. In the edge weight function w(f), the first term of the sum is the duration of flight f, and the second term is the layover time between f and the previous flight e. The layover term appears again in the adjacency constraint in point (9) of the input specification. Point (9) takes care of all three of the constraints mentioned previously. The first part of point (9), that e = (x, y) and f = (y, z), is somewhat redundant to the definition of a directed graph but is provided for clarity, and it ensures that the departure airport (y) of the next flight (f) in an itinerary is the same as the arrival airport of the previous flight (e). The second part of point (9) ensures both that flight f departs sometime after flight e arrives (since C must be greater than or equal to 0), and that there is enough time to travel between the two gates in question (since the layover time must be greater than or equal to C, the minimum allowed layover time). By this problem formulation, the flight itinerary problem is very similar to finding the shortest path on a weighted, directed multigraph, with the important difference that the weight of an edge depends on the previous edge in the path. Because of this, the starting condition Ta(e0) = ts is necessary (since there is no previous edge for the first edge in the path). Well-established mathematics and algorithms for the related shortest path problems will likely provide a good starting point for solving the problem described in the above specification. Matt Freeburg freeburg@hawaii.edu Flight Itinerary Problem Formulation - Summary Input: A weighted, directed multigraph G = (V, E) such that: 1) a set V of nV vertices with each vertex vi (1 ≤ i ≤ nV) corresponding to an airport, where nV is the total number of airports 2) a set E of nE edges, with each edge ei (1 ≤ i ≤ nE) denoted by (u, v), with u as the departure airport and v as the arrival airport (u, v in V), and each edge corresponding to a single flight, where nE is the total number of flights 3) a starting airport vs and final destination airport vf (vs, vf in V), and a starting time ts 4) a function A(e) that returns the airline ai (1 ≤ i ≤ nA) for edge e, where nA is the total number of airlines 5) a function Td(e) that returns the departure time of the flight corresponding to edge e 6) a function Ta(e) that returns the arrival time of the flight corresponding to edge e 7) a function C(v, a, b) that returns the minimum allowed layover time at airport v (v in V) with arriving airline a and departing airline b 8) the weight w(f) of an edge f is defined as w(f) = ((Ta(f) – Td(f)) + (Td(f) – Ta(e)) = Ta(f) – Ta(e), where e is the edge previous to f in a path on G (e, f in E) 9) two edges e and f (e, f in E) are considered adjacent iff i) e = (x, y) and f = (y, z), and ii) Td(f) – Ta(e) ≥ C(y, A(e), A(f)) Output: A path P = {e1, e2, e3, … , em}, an ordered sequence of m edges beginning at vs and ending at vf (e1 = (vs, x) and em = (y, vf)), where the total weight of P is minimized among all possible such sequences of all possible lengths beginning at time ts, with the total weight given by: m W(P) = ∑ (Ta(ei) – Ta(ei-1)) i=1 where Ta(e0) = ts. Important Points: - vertices represent airports - directed edges e = (u, v) represent flights from airport u to airport v - there may be multiple edges in the same direction between u and v, at different times or at the same time - daily or other periodic flights have one edge for each instance - edge weight is layover time plus flight time - the weight of edge f depends upon both f and the previous edge e - the constraints in point (9) of the input determine which edges are adjacent for the purposes of forming a path - times Ta(e), Td(e), and ts are all absolute times elapsed from some arbitrary, defined start point in the past (time points) - differences between times are durations (time lengths) - minimum layover time C is always greater than or equal to zero - the initial condition Ta(e0) = ts is necessary to find the total weight W(P) - the number of edges m in a path may be different for different paths that are evaluated in the minimization process - existing mathematics and algorithms provide a starting point for solving the problem