CS 573: Algorithms, Fall 2013 Airline Scheduling Problem Network Flow IV - Given information about flights that an airline needs to provide, Applications II generate a profitable schedule. Lecture 15 Input: detailed information about “legs” of flight. 1 October 17, 2013 F : set of flights by 2 Purpose: find minimum # airplanes needed. 3 Sariel (UIUC) CS573 1 Fall 2013 1 / 57 Sariel (UIUC) CS573 2 Fall 2013 2 / 57 Example Flight scheduling... (i) a set F of flights that have to be served, and (ii) the corresponding graph G Use same airplane for two segments i and j : 1 representing these flights. (a) destination of i is the origin of the segment j , 1: Boston (depart 6 A.M.) - Washing- (b) there is enough time in between the two flights. ton DC (arrive 7 A.M,). Also, airplane can fly from dest ( i ) to origin ( j ) (assuming time 2 2: Urbana (depart 7 A.M.) - Cham- 2 constraints are satisfied). paign (arrive 8 A.M.) 1 3: Washington (depart 8 A.M.) - Los Example 3 Angeles (arrive 11 A.M.) As a concrete example, consider the flights: 4: Urbana (depart 11 A.M.) - San Francisco (arrive 2 P.M.) 6 Boston (depart 6 A.M.) - Washington D.C. (arrive 7 A.M,). 4 5: San Francisco (depart 2:15 P.M.) - Washington (depart 8 A.M.) - Los Angeles (arrive 11 A.M.) Seattle (arrive 3:15 P.M.) 5 Las Vegas (depart 5 P.M.) - Seattle (arrive 6 P.M.) 6: Las Vegas (depart 5 P.M.) - Seattle This schedule can be served by a single airplane by adding the leg (arrive 6 P.M.). “Los Angeles (depart 12 noon)- Las Vegas (1 P,M.)” to this schedule. (i) (ii) Sariel (UIUC) CS573 3 Fall 2013 3 / 57 Sariel (UIUC) CS573 4 Fall 2013 4 / 57
Modeling the problem Solution model the feasibility constraints by a graph. Reduction to computation of circulation. 1 1 Build graph H . G : directed graph over flight legs. 2 2 ∀ leg i , two new vertices u i , v i ∈ VH . For i and j (legs), ( i → j ) ∈ E ( G ) ⇐ ⇒ same airplane can 3 3 s : source vertex. t : sink vertex. serve both i and j . Set demand at t to k , Demand at s to be − k . G is acyclic. 4 4 Each flight must be served. New edge e i = ( u i → v i ) , for leg i . Q: Can required legs can be served using only k airplanes? 5 5 Also ℓ ( e i ) = 1 and c ( e i ) = 1 . If same plane can so i and j (i.e., ( i → j ) ∈ E ( G ) ) then add 6 edge ( v i → u j ) with capacity 1 to H . Since any airplane can start the day with flight i : add an edge 7 ( s → u i ) with capacity 1 to H , ∀ i . Add edge ( v j → t ) with capacity 1 to G , ∀ j . 8 Overflow airplanes: “overflow” edge ( s → t ) with capacity k . 9 Let H denote the resulting graph. Sariel (UIUC) CS573 5 Fall 2013 5 / 57 Sariel (UIUC) CS573 6 Fall 2013 6 / 57 Example of resulting graph Lemma The resulting graph H for the instance of airline scheduling show before. Lemma k ∃ way perform all flights of F ≤ k planes ⇐ ⇒ ∃ circulation in H . 1 , 1 u 1 v 1 Proof. 1 , 1 u 2 v 2 Given feasible solution → translate into valid circulation. 1 1 , 1 Given feasible circulation... 2 u 3 v 3 ... extract paths from flow. 3 − k k 1 , 1 s t ... every path is a plane. 4 u 4 v 4 2 1 , 1 u 5 v 5 1 3 1 , 1 u 6 v 6 6 4 5 Sariel (UIUC) CS573 7 Fall 2013 7 / 57 Sariel (UIUC) CS573 8 Fall 2013 8 / 57
Extensions and limitations a lot of other considerations: 1 (i) airplanes have to undergo long term maintenance treatments every once in awhile, Part I (ii) one needs to allocate crew to these flights, (iii) schedule differ between days, and (iv) ultimately we interested in maximizing revenue. Image Segmentation Network flow is used in practice, real world problems are 2 complicated, and network flow can capture only a few aspects. ... a good starting point. 3 Sariel (UIUC) CS573 9 Fall 2013 9 / 57 Sariel (UIUC) CS573 10 Fall 2013 10 / 57 Image Segmentation What is the input... Input is a bitmap on a grid. 1 Input is an image. Every grid node represents a pixel Partition image into background and foreground. 2 Convert grid into a directed graph G , 3 Input: 4 (i) N × N bitmap. G = ( V , E ) . (ii) ∀ pixel i : foreground value f i ≥ 0 . (iii) ∀ pixel i : background value b i . (iv) ∀ i , j adjacent: separation penalty p ij . (i) (ii) (we assume that p ij = p ji ) The (i) input image, and (ii) a possible segmentation of the image. Sariel (UIUC) CS573 11 Fall 2013 11 / 57 Sariel (UIUC) CS573 12 Fall 2013 12 / 57
Problem statement Restating problem... Maximizing: Problem Given input as above, partition V (the set of pixels) into two disjoint � � � � . q ( F , B ) = ( f i + b i ) − f i + b j + subsets F and B , such that p ij i ∈ v i ∈ B j ∈ F ( i , j ) ∈ E , | F ∩{ i , j }| = 1 � � � q ( F , B ) = f i + b i − p ij . Equivalent to minimizing u ( F , B ) : i ∈ F i ∈ B ( i , j ) ∈ E , | F ∩{ i , j }| = 1 � � � is maximized. u ( F , B ) = f i + b j + p ij . (1) i ∈ B j ∈ F ( i , j ) ∈ E , | F ∩{ i , j }| = 1 Rewrite q ( F , B ) as: � � � q ( F , B ) = f i + b j − p ij i ∈ F j ∈ B ( i , j ) ∈ E , | F ∩{ i , j }| = 1 � � � � . = ( f i + b i ) − f i + b j + p ij i ∈ v i ∈ B j ∈ F ( i , j ) ∈ E , | F ∩{ i , j }| = 1 Sariel (UIUC) CS573 13 Fall 2013 13 / 57 Sariel (UIUC) CS573 14 Fall 2013 14 / 57 Solution continued... Solution continued... b i i Compute a minimum cut in a graph. Price = u ( F , B ) . f i 1 s t f i b i s i f j j A toy example: t b j 2 Two pixel bitmap: 1 two possible cuts in the graph: 3 Captures background/foreground prices. But... ignores 2 (i) ( { s , i } , { t } ) : price b i . separation penalties... (ii) ( { s } , { i , t } ) : price f i . ). In particular, b i f i i Every path of length 2 from s to t forces mincut to choose one p ij p ij s 4 t f j j of edges. b j 3 Mincut “prefers” the edge with lower price. Price of cut in graph is corresponding value of u ( F , B ) . 4 mincut-cut in the resulting graph would corresponds to the 5 required segmentation. Sariel (UIUC) CS573 15 Fall 2013 15 / 57 Sariel (UIUC) CS573 16 Fall 2013 16 / 57
Recap... Solution continues... Given directed grid graph G = ( V , E ) . By the above discussion: 1 s , y : add two special source and sink vertices. 2 Lemma ∀ i ∈ V ,: add edge e i = ( s → i ) . 3 A minimum cut ( F , B ) in H minimizes u ( F , B ) . c ( e i ) = f i . Add e ′ i = ( j → t ) with capacity c ( e ′ Using the minimum-cut max-flow theorem, we have: i ) = b i . 4 ∀ i . j adjacent: 5 Theorem assign the capacity p ij to the edges ( i → j ) and ( j → i ) One can solve the segmentation problem, in polynomial time, by H : resulting graph. computing the max flow in the graph H . Sariel (UIUC) CS573 17 Fall 2013 17 / 57 Sariel (UIUC) CS573 18 Fall 2013 18 / 57 Project Selection company which can carry out some projects. 1 P : set of possible projects. 2 ∀ i ∈ P : a revenue p i . Part II 3 p i > 0 is a profitable project and p i < 0 is a losing project. 4 There is dependency between projects. 5 Projection selection G = ( P , E ) : ( i → j ) ∈ E if and only if j is a prerequisite for i . 6 Sariel (UIUC) CS573 19 Fall 2013 19 / 57 Sariel (UIUC) CS573 20 Fall 2013 20 / 57
Definition Project selection example Definition ∞ − 2 − 3 − 5 − 8 A set X ⊂ P is feasible if for all i ∈ X , all the prerequisites of i are also in X . Formally, for all i ∈ X , with an edge ( i → j ) ∈ E , we have j ∈ X . The profit associated with a set of projects X ⊆ P is ∞ ∞ ∞ ∞ profit ( X ) = � i ∈ X p i . 4 6 2 3 Problem - Project Selection Problem ∞ ∞ Select a feasible set of projects maximizing the overall profit. Sariel (UIUC) CS573 21 Fall 2013 21 / 57 Sariel (UIUC) CS573 22 Fall 2013 22 / 57 The reduction Example: Resulting network Use mincut again. 1 t Add s and t to G . 2 Perform the following modifications: 2 8 3 3 5 ∀ i ∈ P with p i > 0 : add edge e i = ( s → i ) . 4 60 with c ( e i ) = p i . − 2 − 3 − 5 − 8 ∀ j ∈ P with p j < 0 : add edge e ′ j = ( j → t ) . 5 60 Set c ( e ′ j ) = − p j . 60 60 60 C = � i ∈ P , p i > 0 p i : upper bound on profit. 6 4 6 2 3 Set capacity of all original (dependency) edges in G to 4 C . 60 60 7 Let H denote the resulting network. 2 6 3 4 s Sariel (UIUC) CS573 23 Fall 2013 23 / 57 Sariel (UIUC) CS573 24 Fall 2013 24 / 57
Recommend
More recommend