CS 401 Max Flow Applications Xiaorui Sun 1
Survey Design
Survey Design Survey design. Design survey asking n 1 consumers about n 2 products. Can only survey consumer i about a product j if they own it. Ask consumer i between c i and c i ' questions. Ask between p j and p j ' consumers about product j. Goal. Design a survey that meets these specs, if possible. [c 1 , c 1 ’] = [2, 4] [p 1, p 1 ’] = [2, 4] 1 1' 2 2' [2, 4] [2, 4] [2, 4] [2, 4] 3 3' products 4 4' consumers [2, 4] [2, 4]
Survey Design Survey design. Design survey asking n 1 consumers about n 2 products. Can only survey consumer i about a product j if they own it. Ask consumer i between c i and c i ' questions. Ask between p j and p j ' consumers about product j. Goal. Design a survey that meets these specs, if possible. Bipartite perfect matching. Special case when c i = c i ' = p i = p i ' = 1.
Survey Design Algorithm. Formulate as a circulation problem with lower bounds. Include an edge (i, j) if customer own product i. Demands = 0 for all vertices Integer circulation Û feasible survey design. [0, ¥ ] [0, 1] 1 1' [p 1 , p 1 '] [c 1 , c 1 '] 2 2' s t 3 3' 4 4' products consumers 5 5'
Image Segmentation
Image Segmentation Given an image we want to separate foreground from background • Important problem in image processing. • Divide image into coherent regions. 7
Foreground / background segmentation Label each pixel as foreground/background. ! = set of pixels, " = pairs of neighboring pixels. # $ is the original image. # $ ≫ 0 means we prefer to label ' in foreground. ( $,* ≥ 0 is separation penalty for labeling one of ' and j as foreground, and the other as background. Goals: Find partition (-, -) that minimizes: − 0 # $ + 0 ( $,* $∈2 $,* ∈4 $∈2,*∈2 where - is the foreground. 8
Min cut Formulation !′ = (%′, '′). Add s to correspond to foreground; Add t to correspond to background; Use two anti-parallel edges instead of undirected edge. p ij p ij p ij p ij * + if * + > 0 i j s t −* + if * + < 0 !′ 9
Min cut Formulation (cont’d) Consider min cut (", ") in G’. ( " = foreground.) %&' ", " = ) −& * 1 / 0 12 + ) & * 1 / 0 42 + ) ' *,5 *∈, *,5 ∈6 *∈, *∈,,5∈, = − ∑ *∈, & * + ∑ *∈, & * 1 / 0 42 + ∑ *∈, & * 1 / 0 42 + ∑ ⋯ ' *,5 = − ∑ *∈, & * + ∑ * & * + ∑ ⋯ ' *,5 = − ∑ *∈, & * + ∑ ⋯ ' *,5 + constant Precisely, what we want to minimize. p ij & 5 if & 5 > 0 i j s t −& 5 if & 5 < 0 " ?′ 10
Reality The main difficulty is to come up with a good model. Segmentation may be real-valued instead of {0,1}. There are many more than 1 objects. May need labeling. Augmenting path is not great for GPU. 11
Summary Min s-t cut problem. Find an s-t cut of minimum capacity. Max flow problem. Find s-t flow of maximum value. Ford-Fulkerson Algorithm. Augment flow along augmenting path • O(nm) for unit capacity graph O(m 2 log C) for integer capacity graph • Max flow applications • Bipartite matching, disjoint paths, circulation, image segmentation • Techniques: add source/sink, reduce to circulation, turn negative values to (positive) capacities 12
Longest Common Subsequence Sequence alignment a g c d e f - - - - a - - - - f b c d e Common subsequence = af 2 matches, 8 gaps a - g c d e f a f b c d e - Common subsequence = acde 4 matches, 2 gaps, 1 mismatch Common subsequence length = # matches 13
Longest Common Subsequence LCS: alignment with largest number of matches Let !"#(%, ') be the number of matches for the best alignment ) * , … , ) , and - * , … , - . Case 1: OPT matches ) , , - . • !"#(% − 1, ' − 1) +1 if ) , = - . , otherwise !"#(% − 1, ' − 1) Case 2: OPT leaves ) , unmatched • !"# % − 1, ' Case 3: OPT leaves - . unmatched • !"#(%, ' − 1) 14
Recommend
More recommend